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

Adding CMakePresets.json for default Visual Studio configs #39

Closed

Conversation

DarkWanderer
Copy link
Contributor

Allows to switch:

  • x86/x64
  • Debug/Release

Without restarting Visual Studio / regenerating solution. (need to open directory, rather than solution file, in VS)

@mschweiger
Copy link
Collaborator

Is this required for the CI run? I had deliberately left out the CMakeSettings.json file from the repository, since it contains user-specific settings, e.g. regarding building documentation etc. Also, I hate having the build directory inside the source tree, so my buildRoot and installRoot entries are different. I've also got a reference to the vcpkg toolchain file in there.

Is there an argument for including it in the repository?

@DarkWanderer
Copy link
Contributor Author

DarkWanderer commented Aug 3, 2021

It is not required for CI (hence separate PR). Having this file committed to repository will allow developers to select from 4 configurations - x86-Debug, x86-Release, x64-Debug, x64-Release - in Visual Studio without having to:

  • exit VS
  • run cmake to regenerate projects/solution
  • open Visual Studio again.

This is purely a convenience feature for Visual Studio

P.S. Your point about personal settings being stored there is entirely valid, however. I think same level of convenience can be achieved by using CMakePreset.json - will explore that

@DarkWanderer
Copy link
Contributor Author

DarkWanderer commented Aug 4, 2021

Added CMakePresets.json instead, see:

The idea behind this PR is to avoid having every developer setting up CMakeSettings.json for themselves (which might be tricky for some). CMakePresets.json has the advantage of storing default configuration + allowing custom CMakeUserPresets.json which advanced users can customize for themselves.

Here's how it looks in Visual Studio:
image

P.S. In some distant future, this will allow for Linux builds straight out of VS as well

@DarkWanderer DarkWanderer changed the title Adding CMakeSettings.json file Adding CMakePresets.json for default Visual Studio configs Aug 4, 2021
@DarkWanderer DarkWanderer reopened this Aug 4, 2021
@dbeachy1
Copy link
Member

@DarkWanderer Is is possible to configure the defaults to put the build directory default to be outside the source tree (or maybe just leave it blank?). If I understand @mschweiger correctly, the major concern with using defaults is that the build directory would be inside the source tree.

Regarding the other concern, what about even just leaving the default fields blank? The way, developers would still need to fill in settings in before building. I understand that sort of defeats the purpose of the presets file in the first place, but this would still allow developers to have all four build configurations (x86 Debug, x86 Release, x64 Debug, x64 Release) all in the same solution, if I understand correctly -- which, to be honest, is the big thing that I like :).

@DarkWanderer
Copy link
Contributor Author

DarkWanderer commented Aug 19, 2021

What is the issue with having build artifacts inside the source directory, given that it's ring-fenced (all items are in subdirectories of out/build)? To be honest it feels strange to me to have build artifacts outside source dir, given that basically any language build process produces something which is inside the source dir by default. In fact, I'd be surprised (not in a good way) if code I build starts changing filesystem outside of source directory - unless I explicitly asked for it

Perhaps I can document a way to place build/install directories to arbitrary location - so everyone can set it up to their liking - while retaining "least surprise" defaults? CMakeUserPresets.json should work for that

@DarkWanderer
Copy link
Contributor Author

Let me rephrase this: I appreciate that this question is essentially matter of taste and do not claim that a particular way is unconditionally better. My suggestion comes from a standpoint that adding CMakePresets allows for new capabilities, while also helping to:

  • streamline process for new contributors (they will not have to generate CMakeSettings.json)
  • improve CI consistency (at the moment parameters are passed externally via command line)
  • add capability for "remote" Linux development in future

In my opinion, having a default of building within source directory is the "least friction" option, while capability to build outside of source dir is retained, for cases where it is a concern

Of course, the decision is ultimately with you

@dbeachy1
Copy link
Member

FWIW, I don't feel strongly about this either way, and I agree it's a matter of personal taste. I'm going to close this PR for now since @mschweiger prefers the build settings as they currently are and this PR has been open for 22 days. We can always reopen this in the future if this resurfaces.

@dbeachy1 dbeachy1 closed this Aug 25, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants