-
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
Add CMake Presets #1209
Add CMake Presets #1209
Conversation
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
… into add-cmake-presets
Hmm — frankly I'm a little less warm to the idea now that I see the presets spelled out. It looks like a lot of code, mostly restating defaults. And half of the |
I agree that the CMakePresets.json format can be a bit verbose, especially with a lot of hidden presets the way I’ve structured it. The advantage of this approach is easy composability to new unhidden presets based on users’ requirements with minimal copy-paste. The alternative would be fewer hidden presets but perhaps less composability or reusability. Regarding the yml file, the name of the preset can be shortened if that’s what you’re referring to. The advantage of using presets in the yml (to me at least) is less statefulness - all commands are run from the root directory as opposed to creating and changing build directories. Last but not least, the killer feature of presets is being able to switch IDEs or even use command line tools with no additional cache configuration. This is a big help for cross platform projects such as quantlib. Thanks for taking the time to look at the change and I’m open to any other comments you may have. |
Thanks, I see. If we can provide some useful reusable blocks, that's ok of course — I'm just not sure if we need to add presets like, for instance,
that (as far as I can see) only contains defaults that you would get even without specifying any presets. ( What would you think about starting with some presets that we would use for the more complex CI builds, for examples, without thinking too much about abstracting out basic pieces yet? We can add more as we find use cases. Also, for the CI jobs without options, I'd leave the usual What do you think? |
The four presets you mentioned in the PR description look useful, too — but maybe I wouldn't explode them over this many levels of inheritance... |
Sure, I can collapse some of the inheritance if you prefer, but just be aware that this will probably result in a lot of duplicated content between related presets. For example, when you factor in the Maybe I can just remove all the presets except for two presets containing all the values required for the two 'options' CI jobs and you can see how it looks before we decide on the next steps. Another idea would be to move all the layers of inheritance to For the CI jobs without options, I can certainly revert back to the original commands. Generally being able to specify a preset when building on command line is considered a benefit, but I can understand the desire to ensure that the traditional way of doing things still works for the majority of users. |
Hmm, adding Would the four presets work without specifying "debug" or "release"? What would the default be, if any? |
This is what the https://gist.github.com/sweemer/c86f205058ad4d3de54b33ad2afb827e As you can see I also removed all the inheritance (i.e. hidden presets) so that you can evaluate each preset in isolation. A few things to note:
Let me know what you think of the gist so that I can push new commits to the merge request accordingly. [1] https://cmake.org/cmake/help/v3.20/manual/cmake-presets.7.html |
Yup, I like this a lot better. Thanks! |
I would use this preset-based approach for #1205 instead of hard-coding cmake settiings. |
Agreed. |
With the preset functionality, I would go even further and remove all compile flags from the Platform.cmake file, reducing it to a nominal no-flag baseline, and then create a series of useful presets, adding flags via presets. I think @lballabio knows where we both stand on this point now -- let's just let him arbitrate. |
I'd try to make the experience smooth for people that just say "oh, there's a CMakeLists" and runs Other stuff can go into presets, or even user presets. |
I've pushed up some more commits with the following changes:
Could you approve the checks workflows one more time for me @lballabio? I am also now marking this pull request as ready for review. From my perspective, I'm fine with merging this as a first round of migrating existing build configurations over to presets. You mentioned possibly doing the same thing for some of the example projects, which I propose we do in a separate merge request. Regarding a smooth user experience, I think you have two main types of users - those that use CMake on the command line, and those that use IDEs. I agree that the classic approach of |
Hi @lballabio, do you have any other comments before this change gets merged? |
No, thanks — I might try and think of a more explicit name for the CI builds, but if I do I can change it myself. |
Congratulations on your first merged pull request! |
Closes #1207.
To start with, it includes the following presets:
Unfortunately I do not have a Mac, so was unable to add or test presets for that platform.