Issue
I made an effort to stop using Visual Studio and instead making a C++ project using CMake and VSCode. Now the build times are 10 times slower...
My own code is relatively small bust has dependencies on a lot of libraries that are placed in the precompiled header.
I am in a position waiting a very long time until something is compiled before it was 8 seconds now it is 40 seconds and sometimes goes up to 2 minutes. Any minor code changed is really nightmare. The problem is that I do not know where to start optimizing it. I enable precompiled headers which reduces the speed from 2 min to 38 seconds, but is nowhere near as 8 seconds.
Can someone give me an advice how can I start finding out what library is causing such long delays?
Several answers to comments below:
1. I am comparing "native" Visual Studio project vs the CMake project.
2. I am using MSVC
3. Parallel build reduces the time from 38 to 24 seconds "--parallel 4"
My main CMakeLists looks like this:
########################################################################
#
# CONFIGURE THE PROJECT
#
########################################################################
###############################################################################
#EXECUTABLE LINK HEADER ONLY DIRECTORY
###############################################################################
SET(BUILD_MY_PROJECTS "" CACHE STRING "Build Project")
if (BUILD_MY_PROJECTS)
message(AUTHOR_WARNING "BUILD_MY_PROJECTS_" ${BUILD_MY_PROJECTS})
###############################################################################
# CREATE EXE
###############################################################################
add_executable(${PROJECT_NAME} main.cpp
"${CMAKE_SOURCE_DIR}/wood/include/wood_joint.cpp"
"${CMAKE_SOURCE_DIR}/wood/include/wood_test.cpp"
"${CMAKE_SOURCE_DIR}/wood/include/wood_xml.cpp"
"${CMAKE_SOURCE_DIR}/wood/include/cgal_mesh_boolean.cpp"
)
###############################################################################
# LIBRARIES
###############################################################################
###############################################################################
# OPENGL
###############################################################################
find_package(OpenGL REQUIRED)
###############################################################################
# CDT
###############################################################################
# set(CDT_INC
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/CDT.h"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/CDT.hpp"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/CDTUtils.h"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/CDTUtils.hpp"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/KDTree.h"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/LocatorKDTree.h"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/predicates.h"
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/remove_at.hpp"
# )
# set(CDT_SRC
# "${CMAKE_BINARY_DIR}/install/cdt/CDT/src/CDT.cpp"
# )
# add_library(CDT STATIC ${CDT_INC} ${CDT_SRC} )
# target_include_directories(CDT PUBLIC "${CMAKE_BINARY_DIR}/install/cdt/CDT/include/") #link headers to clipper library
###############################################################################
# CLIPPER
###############################################################################
set(CLIPPER2_INC
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/clipper2/clipper.core.h"
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/clipper2/clipper.engine.h"
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/clipper2/clipper.h"
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/clipper2/clipper.minkowski.h"
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/clipper2/clipper.offset.h"
)
set(CLIPPER2_SRC
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/src/clipper.engine.cpp"
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/src/clipper.offset.cpp"
)
add_library(Clipper2 STATIC ${CLIPPER2_INC} ${CLIPPER2_SRC} )
target_include_directories(Clipper2 PUBLIC "${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/") #link headers to clipper library
###############################################################################
# IMGUI
###############################################################################
list(APPEND IMGUI_INC
"${CMAKE_BINARY_DIR}/install/glfw/include/"
"${CMAKE_BINARY_DIR}/install/imgui/"
"${CMAKE_BINARY_DIR}/install/imgui/backends/"
)
set(IMGUI_SRC
"${CMAKE_BINARY_DIR}/install/imgui/imgui_demo.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/imgui_draw.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/imgui_tables.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/imgui_widgets.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/imgui.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/backends/imgui_impl_opengl3.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/backends/imgui_impl_glfw.cpp"
"${CMAKE_BINARY_DIR}/install/imgui/backends/imgui_impl_glfw.cpp"
)
add_library(imgui STATIC ${IMGUI_INC} ${IMGUI_SRC} )
target_include_directories(imgui PUBLIC ${IMGUI_INC}) #link headers to clipper library
###############################################################################
# STB
###############################################################################
set(STB_INC
"${CMAKE_SOURCE_DIR}/viewer/include/stb/stb_image.h"
"${CMAKE_SOURCE_DIR}/viewer/include/stb/stb_image_write.h"
)
set(STB_SRC
"${CMAKE_SOURCE_DIR}/viewer/src/stb/stb_image.cpp"
"${CMAKE_SOURCE_DIR}/viewer/src/stb/stb_image_write.cpp"
)
add_library(STB STATIC ${STB_INC} ${STB_SRC} )
target_include_directories(STB PUBLIC "${CMAKE_SOURCE_DIR}/viewer/include/stb/") #link headers to clipper library
###############################################################################
# CGAL
###############################################################################
#target_link_libraries(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/cgal/auxiliary/gmp/lib/" ) # WINDOWS
if(COMPILER_NINJA)
target_link_directories(${PROJECT_NAME} PUBLIC "C:/msys64/mingw64/lib/" )
else()
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/cgal/auxiliary/gmp/lib/" )
endif()
if(NOT COMPILER_NINJA)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${CMAKE_BINARY_DIR}/install/cgal/auxiliary/gmp/lib/libgmp-10.dll" # <--this is in-file
"${CMAKE_BINARY_DIR}/Release") # <--this is out-file path
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${CMAKE_BINARY_DIR}/install/cgal/auxiliary/gmp/lib/libmpfr-4.dll" # <--this is in-file
"${CMAKE_BINARY_DIR}/Release") # <--this is out-file path
endif()
###############################################################################
# BOOST
###############################################################################
###############################################################################
# EIGEN
###############################################################################
###############################################################################
# LINK HEADERS TO EXE
# check path:
# message(AUTHOR_WARNING "${CMAKE_SOURCE_DIR}/viewer/include/stb")
###############################################################################
list(APPEND petras_include_paths
#my_code
"${CMAKE_SOURCE_DIR}/viewer/include/"
"${CMAKE_SOURCE_DIR}/viewer/include/stb/"
"${CMAKE_SOURCE_DIR}/viewer/include/pipe/"
"${CMAKE_SOURCE_DIR}/viewer/include/opengl/"
"${CMAKE_SOURCE_DIR}/viewer/include/imgui/"
#cdt
"${CMAKE_BINARY_DIR}/install/cdt/CDT/include/"
#clipper
"${CMAKE_BINARY_DIR}/install/clipper_2/CPP/Clipper2Lib/include/"
#imgui
"${CMAKE_BINARY_DIR}/install/imgui/"
"${CMAKE_BINARY_DIR}/install/imgui/backends/"
#glfw
"${CMAKE_BINARY_DIR}/install/glfw/include/"
#glad
"${CMAKE_BINARY_DIR}/install/glad/include/"
"${CMAKE_BINARY_DIR}/install/glad/include/glad"
#glm
"${CMAKE_BINARY_DIR}/install/glm/"
#assimp
"${CMAKE_BINARY_DIR}/install/assimp/include/"
"${CMAKE_BINARY_DIR}/install/assimp/contrib/zlib/"# WINDOWS
#boost
"${CMAKE_BINARY_DIR}/install/boost/include/boost-1_78/"
#eigen
"${CMAKE_BINARY_DIR}/install/eigen/"
#cgal
"${CMAKE_BINARY_DIR}/install/cgal/include"
"${CMAKE_BINARY_DIR}/install/cgal/auxiliary/gmp/include"
#"C:/msys64/mingw64/lib/" #GCC
)
target_include_directories(${PROJECT_NAME} PRIVATE "$<BUILD_INTERFACE:${petras_include_paths}>") #header for the library
###############################################################################
# LINK LIBRARIES TO EXE, STATIC LIBRARIES PATHS MUST BE AT THE END
###############################################################################
if(COMPILER_NINJA)
message(STATUS "COMPILER_NINJA ON")
target_link_libraries(${PROJECT_NAME} PRIVATE
Clipper2
opengl32
imgui
glfw3
glad
assimp
stb
zlibstatic
gmp
mpfr
) #gmp mpfr link library | zlibstatic WINDOWS
else()
message(STATUS "COMPILER_NINJA OFF")
target_link_libraries(${PROJECT_NAME} PRIVATE
Clipper2
opengl32
imgui
glfw3
glad
assimp
stb
zlibstatic
libgmp-10
libmpfr-4
) #gmp mpfr link library | zlibstatic WINDOWS
endif()
###############################################################################
# GLFW
###############################################################################
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/glfw/src/" )
###############################################################################
# GLAD
###############################################################################
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/glad/")
###############################################################################
# ASSIMP
###############################################################################
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/assimp/lib/" )
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/install/assimp/contrib/zlib/" ) # WINDOWS
###############################################################################
# STB
###############################################################################
target_link_directories(${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/" )
###############################################################################
# PCH support
###############################################################################
#option(KDV_BUILD_USING_PCH "Build using pre-compile header support" ON)
#if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND KDV_BUILD_USING_PCH) # support for PCHs in CMake was added in 3.16
message(STATUS "Compiling using pre-compiled header support")
target_precompile_headers(${PROJECT_NAME} PRIVATE stdafx.h) # With PUBLIC they will be used by targets using this target
#target_precompile_headers(${PROJECT_NAME} PRIVATE "C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/CMakeFiles/compas_wood.dir/Release/cmake_pch.hxx")
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
If that helps following is the verbose compilation process:
Executing task in folder compas_wood: cmake --build c:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ -v --config Release --parallel 6 && c:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\wood.exe
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/26/2022 9:02:28 PM.
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" on node 1 (defaul
t targets).
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (1) is building "
C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ZERO_CHECK.vcxproj" (2) on node 1 (default ta
rgets).
2>InitializeBuildStatus:
Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
All outputs are up-to-date.
FinalizeBuildStatus:
Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
2>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ZERO_CHECK.vcxproj" (d
efault targets).
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (1) is building "
C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Clipper2.vcxproj" (3) on node 1 (default targ
ets).
3>InitializeBuildStatus:
Creating "Clipper2.dir\Release\Clipper2.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
All outputs are up-to-date.
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (1) is building "
C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\imgui.vcxproj" (4) on node 3 (default targets
).
4>InitializeBuildStatus:
Creating "imgui.dir\Release\imgui.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (1) is building "
C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\STB.vcxproj" (6) on node 2 (default targets).
6>InitializeBuildStatus:
Creating "STB.dir\Release\STB.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
4>CustomBuild:
All outputs are up-to-date.
6>CustomBuild:
All outputs are up-to-date.
4>ClCompile:
All outputs are up-to-date.
6>ClCompile:
All outputs are up-to-date.
4>Lib:
All outputs are up-to-date.
6>Lib:
All outputs are up-to-date.
4>Lib:
imgui.vcxproj -> C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\imgui.lib
6>Lib:
STB.vcxproj -> C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\STB.lib
3>ClCompile:
All outputs are up-to-date.
Lib:
All outputs are up-to-date.
Clipper2.vcxproj -> C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\Clipper2.lib
FinalizeBuildStatus:
Deleting file "Clipper2.dir\Release\Clipper2.tlog\unsuccessfulbuild".
Touching "Clipper2.dir\Release\Clipper2.tlog\Clipper2.lastbuildstate".
3>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Clipper2.vcxproj" (def
ault targets).
6>FinalizeBuildStatus:
Deleting file "STB.dir\Release\STB.tlog\unsuccessfulbuild".
Touching "STB.dir\Release\STB.tlog\STB.lastbuildstate".
4>FinalizeBuildStatus:
Deleting file "imgui.dir\Release\imgui.tlog\unsuccessfulbuild".
Touching "imgui.dir\Release\imgui.tlog\imgui.lastbuildstate".
6>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\STB.vcxproj" (default
targets).
4>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\imgui.vcxproj" (defaul
t targets).
1>Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (1) is building "
C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\wood.vcxproj" (5) on node 4 (default targets)
.
5>InitializeBuildStatus:
Creating "wood.dir\Release\wood.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
All outputs are up-to-date.
ClCompile:
All outputs are up-to-date.
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\CL.exe /c /IC:\
IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\viewer\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\sup
er_build\compas_wood\viewer\include\stb /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\viewer\incl
ude\pipe /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\viewer\include\opengl /IC:\IBOIS57\_Code\S
oftware\CPP\CMAKE\super_build\compas_wood\viewer\include\imgui /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\
compas_wood\build_win\install\cdt\CDT\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build
_win\install\clipper_2\CPP\Clipper2Lib\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\buil
d_win\install\imgui /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\imgui\backend
s /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\glfw\include /IC:\IBOIS57\_Code
\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\glad\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\
super_build\compas_wood\build_win\install\glad\include\glad /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\com
pas_wood\build_win\install\glm /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\as
simp\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\assimp\contrib\zlib
/I"C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\boost\include\boost-1_78" /IC:\I
BOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\install\eigen /IC:\IBOIS57\_Code\Software\CPP\C
MAKE\super_build\compas_wood\build_win\install\cgal\include /IC:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\com
pas_wood\build_win\install\cgal\auxiliary\gmp\include /nologo /W1 /WX- /diagnostics:column /O2 /Ob2 /D _MBCS /D W
IN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope
/Zc:inline /std:c++20 /Yu"C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/CMakeFiles/wood.d
ir/Release/cmake_pch.hxx" /Fp"C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/wood.dir/Rele
ase/cmake_pch.pch" /Fo"wood.dir\Release\\" /Fd"wood.dir\Release\vc143.pdb" /external:W1 /Gd /TP /FIC:/IBOIS57/_Co
de/Software/CPP/CMAKE/super_build/compas_wood/build_win/CMakeFiles/wood.dir/Release/cmake_pch.hxx /errorReport:qu
eue C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\main.cpp
main.cpp
Link:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\link.exe /ERROR
REPORT:QUEUE /OUT:"C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\wood.exe" /INCRE
MENTAL:NO /NOLOGO /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/install/cgal/aux
iliary/gmp/lib /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/install/cgal/auxili
ary/gmp/lib/Release /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/install/glfw/s
rc /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/install/glfw/src/Release /LIBPA
TH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/install/glad /LIBPATH:C:/IBOIS57/_Code/S
oftware/CPP/CMAKE/super_build/compas_wood/build_win/install/glad/Release /LIBPATH:C:/IBOIS57/_Code/Software/CPP/C
MAKE/super_build/compas_wood/build_win/install/assimp/lib /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_buil
d/compas_wood/build_win/install/assimp/lib/Release /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compa
s_wood/build_win/install/assimp/contrib/zlib /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood
/build_win/install/assimp/contrib/zlib/Release /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wo
od/build_win /LIBPATH:C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/Release Release\Clipp
er2.lib opengl32.lib Release\imgui.lib glfw3.lib glad.lib assimp.lib stb.lib zlibstatic.lib "libgmp-10.lib" "libm
pfr-4.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.li
b advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/IBOIS57/_Code
/Software/CPP/CMAKE/super_build/compas_wood/build_win/Release/wood.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE
/NXCOMPAT /IMPLIB:"C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compas_wood/build_win/Release/wood.lib" /MACHI
NE:X64 /machine:x64 wood.dir\Release\cmake_pch.obj
wood.dir\Release\main.obj
wood.dir\Release\wood_joint.obj
wood.dir\Release\wood_test.obj
wood.dir\Release\wood_xml.obj
wood.dir\Release\cgal_mesh_boolean.obj
wood.vcxproj -> C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\Release\wood.exe
PostBuildEvent:
setlocal
"C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compa
s_wood/build_win/install/cgal/auxiliary/gmp/lib/libgmp-10.dll C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/com
pas_wood/build_win/Release
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/compa
s_wood/build_win/install/cgal/auxiliary/gmp/lib/libmpfr-4.dll C:/IBOIS57/_Code/Software/CPP/CMAKE/super_build/com
pas_wood/build_win/Release
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd
FinalizeBuildStatus:
Deleting file "wood.dir\Release\wood.tlog\unsuccessfulbuild".
Touching "wood.dir\Release\wood.tlog\wood.lastbuildstate".
5>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\wood.vcxproj" (default
targets).
1>InitializeBuildStatus:
Creating "x64\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
All outputs are up-to-date.
FinalizeBuildStatus:
Deleting file "x64\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
Touching "x64\Release\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".
1>Done Building Project "C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\compas_wood\build_win\ALL_BUILD.vcxproj" (de
fault targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:24.45
Solution
I think every commenter gave good comments to optimize the code. I added:
- parallel
- split files to .cpp files and .h, inline methods increases compilation time, it is a fact
- never compile static libraries in the same cmakelists as for building exe, do it in to steps
- the biggest problem was, that I was using a .h file with hard coded data-set. I will read data from files instead of doing this 🤦♂️, this added 10-12 sec of compilation time (does not matter if this is part of precompiled header or not...):
- now the time is back to 8 seconds
Answered By - PetrasVestartasEPFL Answer Checked By - Senaida (WPSolving Volunteer)