Repository navigation
Prevent self-destructing build system - #989
robertosfield merged 1 commit into
Conversation
|
Other users have been working with VisualStudio without major problems. Are you doing something different or using a different build combination? Is the "Build Solution" a new feature that others aren't using? I would like to know what is going with other users vs what you are doing to know whether this is local issue or a general issue that others just workaround. |
|
It would seem to be me that if we do include EXCLUDE_FROM_DEFAULT_BUILD TRUE entries, then perhaps a helper macro might be appropriate, as there are a range of build targets meant to be run explicitly and not done by default. |
|
I've built VSG with this build system before without issue, but I was doing so from the command-line, where CMake was running its own MSVC is much easier to use from the command-line than it once was, especially for CMake projects, so it might just be that most Windows developers working on VSG stuff aren't using VS as their IDE, and those that are are just building individual targets and their direct dependencies most of the time instead of everything at once. |
|
I have now had time to do another review and see the changes are made to the macros so will help the other projects as well. I'll merge as is, but it looks to me like other targets would be appropriate to add as well. |
Description
Prevent clobber and uninstall targets running when pressing the Build Solution hotkey in Visual Studio.
This function is usually analogous to
make all, but there's a slight difference with when transitive dependencies of things get built, so for consistency, CMake creates anALL_BUILDVS project in the VS solution that does exactly whatmake allwould, and leaves the hotkey doing what it normally does.For under-the-hood reasons, targets that are excluded from all (the
EXCLUDE_FROM_ALLtarget property, on by default for custom targets) haveEXCLUDE_FROM_DEFAULT_BUILDimplicitly off if they're a dependency of another target, and implicitly on if they're not. This means that using Build Solution skipsuninstallandclobber, but runsuninstall-vsg(which will fail if an install hasn't happened yet asinstall_manifest.txtwon't exist) andclobber-vsg(which wipes out the build system, causing all kinds of havoc).Explicitly setting
EXCLUDE_FROM_DEFAULT_BUILDfor the overall and project-specificuninstallandclobbertargets prevents them from running when they're not explicitly requested. Unfortunately, thanks to VS being dumb here, this also applies to when you run the overall target - you didn't explicitly request its project-specific dependencies, so they aren't built. You can get around this by usingcmake --build . --target uninstallinstead of running the uninstall project from the VS GUI, though, so it's not a huge problem like a surprisegit clean -dxfcan be when theclobbertarget runs unexpectedly.The only alternatives I've thought of would be entirely removing the
clobbertarget (git clean -dxfisn't a wildly difficult command to remember, and can be a pretty big problem if run accidentally, which is more likely when there's a build system target for it) and modifying the uninstall target so it doesn't fail the whole build, or adding CMake option(s) to disable them (and potentially defaulting it to true when using a VS generator).Fixes N/A - there's nothing on the tracker for this.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I've built the project a bunch of times.
Test Configuration:
Checklist: