Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Time Improvements #2894

Open
WillisMedwell opened this issue Aug 5, 2024 · 1 comment
Open

Compile Time Improvements #2894

WillisMedwell opened this issue Aug 5, 2024 · 1 comment

Comments

@WillisMedwell
Copy link

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.

@WillisMedwell
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant