-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Modernised CMakePresets.json to make it more useful for developers #1723
Modernised CMakePresets.json to make it more useful for developers #1723
Conversation
FYI, Luigi previously stated a preference for repetition over inheritance in #1209 (comment) |
I might be wrong but I think that the |
Qualified with a "maybe" 😄 I don't have enough experience with cmake, so if you don't mind I'll let you people work out for a while what is common practice in cmake world and what is preference. Let's regroup after I release 1.31. |
Note that none of the proposed presets are multi-config. The Windows ones are all using the Ninja generator (which is a good bit faster and works well with the Visual Studio built-in CMake support, and also with VSCode). And Makefiles / Ninja on Linux are also single-config. Generator expressions work fine in this case. Hence with these presets, we wouldn't need the build presets. |
Note that the current CMake-based Visual Studio MSBuild generators (multi-config), for example when using the CMake GUI to generate projects and solutions, show very poor build performance. Only a little more than 1 core is used for the build. It's barely usable as it is. On a multi-core machine, the Ninja generator with the associated build parallelism is a lot faster, as all cores are 100% utilised for the full duration of the build. To compare - on a box with 18 cores (36 hyperthreads), with CMake-generated VS2022 project files, fresh release build (Xeon W-2295 CPU):
We believe using Ninja only in the shipped presets in Windows makes this a lot more usable out of the box for Windows users. If developers need other settings, they can always use |
.github/workflows/cmake.yml
Outdated
sudo cmake --build --preset linux-ci-build-with-nonstandard-options --target install | ||
cd build/linux-ci-build-with-nonstandard-options | ||
cmake --build . --verbose | ||
cmake --build . --target install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sudo
was there because /usr/local/lib
is not writable by the CI user on this VM. You'll need to add it back to get the CI passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - that's done.
You're right, I forgot that you switched the Windows generator to Ninja in #1429. Probably we should have removed the
What if somebody adds a configuration preset for the multi-config |
Unfortunately we didn't try that - macOS presets should probably be added as well. Very likely the Linux/Clang ones will work just fine on macOS as well though, using Ninja, as we can see from this CI build. Perhaps someone actively using macOS can test and contribute macOS presets if required separately? For any configurations that aren't covered by the provided presets, there's always We can't cover all combinations (Eclipse, CLion, etc.), but the purpose here is to cover usable common presets that work straight out of the box. |
Sounds good. I don't have any more comments at this time. |
@lballabio - It looks like we've reached a consensus on this. The failing check for doc generation seems to have nothing to do with this change - perhaps it just needs to be re-run? |
Ok, thanks. I'm rerunning the failed check. |
This PR modernises the
CMakePresets.json
to make it more useful and less repetitive for developers (not just for CI/CD).Configure Presets
It defines a set of hidden, base configurations, and uses
inherit
to combine them into user-accessible configure presets for each Windows/Linux with MSVC/Clang/GCC. This makes the dropdown with the Visual Studio "Open Folder" feature look like this for a Windows target:When selecting a remote or WSL Linux target machine, the drop-down looks like this:
For Linux, both Unix Makefiles (default) and Ninja generator presets are there.
The same configuration presets are of course also available on the command-line with
cmake --preset xxxx
.The build directory is set to
${sourceDir}/build/${presetName}
, so all presets can live side-by-side. The corresponding CI/CD workflow jobs have been adjusted to use the new path.Build Presets
The build presets have been removed - they didn't add any additional configuration to what's already covered by the configure presets and were quite repetitive. The Visual Studio IDE works just fine without, and for building on the command-line, users can just do:
Developer-specific Adjustments
Often developers want to add their own configurations or settings in their own presets. This can be done if they add a
CMakeUserPresets.json
file to the QuantLib root and add additional configurations. With the new hidden base configurations in this PR, it makes it easier to inherit combinations that users need and add new settings, for example:CMakeUserPresets.json
Build Speedup Visual Studio
The current CMake-based Visual Studio MSBuild generators (multi-config), for example when using the CMake GUI to generate projects and solutions, show very poor build performance. It's barely usable as it is. This PR makes the presets much more usable out of the box for Windows users.
To compare - on a box with 18 cores (36 hyperthreads), with CMake-generated VS2022 project files, fresh release build (Xeon W-2295 CPU):
MSBuild project files: 24min 36sec
Ninja : 3min 5sec (nearly 8x faster)
Documentation Changes
Once this PR is accepted, we will prepare a change to the QuantLib build doc on the website which will explain better how to use the presets and how to setup user presets.