4
votes

I have a Visual Studio 2015 solution generated by CMake. CMake created a "INSTALL" project that copies all the files I requested (using Cmake's install command in my CMakeLists.txt files).

This "INSTALL" project is skipped when I request a full solution build

I tried to add set_target_properties(INSTALL PROPERTIES EXCLUDE_FROM_ALL FALSE) but this reports set_target_properties Can not find target to add properties to: INSTALL.

How can I make "INSTALL" be generated by default? I'd like the checkbox surrounded in red in screenshot below to be enabled automatically:

enter image description here

3

3 Answers

10
votes

You can use CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD:

set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
2
votes

After some checking, it seems that there is a single common function that sets which projects are part of default build.

cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild

Here is the part that does the check:

const std::string propertyName =
          "CMAKE_VS_INCLUDE_" + *t + "_TO_DEFAULT_BUILD";
// inspect CMAKE_VS_INCLUDE_<*t>_TO_DEFAULT_BUILD properties

So as was mentioned in Florian's answer, you should be able to use CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD as well any custom project using

set(CMAKE_VS_INCLUDE_<custom project name>_TO_DEFAULT_BUILD 1)

1
votes

Moreover, the variable can be added as an option on cmake launch from command line. For VS 2017:

cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD=ON ..