Open WillisMedwell opened 3 months ago
Im on a 8 thread system and these few lines improved compile times from 1minute & 10 secs to 10secs.
if(MSVC)
target_compile_options(Catch2 PUBLIC /MP)
endif()
target_compile_features(Catch2 PRIVATE cxx_std_17)
set_target_properties(Catch2
PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_BATCH_SIZE 25
)
But I think with a little bit of effort it could easily get down to 5 secs for most systems
Description Sort the sources in the src/CmakeLists.txt by compile times. When doing parallel builds in conjunction with unity builds it makes sense to have the biggest sources first.
Additional context When building the lib, msvc generated projects should specify c++17. This is because, for c++20 msvc does a prepass search for module dependencies but this can double the compile times and it doesn't need to do this.
If we were really serious about improving compile times... Instead of just compiling all files individually or using cmake's unity build generated files, I would create 4 source files that included the actual sources. This would allow maintainers to distribute the sources so that each custom source file would compile in roughly the same time. And the reason to use 4 source files is coz most people have at least 4 threads.