diff options
author | Michael Stürmer <michael.stuermer@schaeffler.com> | 2016-11-21 12:25:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-29 13:46:27 (GMT) |
commit | 9e3164dfa2747bd15c3d3e780875a9b286b765c6 (patch) | |
tree | 2b567572d36559c839609185ae7c059bb452d005 | |
parent | 1528831bb1330cc539004f9fb3068e871f109d34 (diff) | |
download | CMake-9e3164dfa2747bd15c3d3e780875a9b286b765c6.zip CMake-9e3164dfa2747bd15c3d3e780875a9b286b765c6.tar.gz CMake-9e3164dfa2747bd15c3d3e780875a9b286b765c6.tar.bz2 |
VS: Add option to place `PACKAGE` target in solution default build
Add a `CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD` variable to control
this behavior.
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/release/dev/vs-default-build-package.rst | 7 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD.rst | 8 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 35 | ||||
-rw-r--r-- | Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake | 29 | ||||
-rw-r--r-- | Tests/RunCMake/VSSolution/AddPackageToDefault.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/VSSolution/RunCMakeTest.cmake | 1 |
7 files changed, 69 insertions, 14 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index d68265d..c621d3a 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -328,6 +328,7 @@ Variables that Control the Build /variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD + /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD /variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS /variable/CMAKE_WIN32_EXECUTABLE /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute diff --git a/Help/release/dev/vs-default-build-package.rst b/Help/release/dev/vs-default-build-package.rst new file mode 100644 index 0000000..62c66e0 --- /dev/null +++ b/Help/release/dev/vs-default-build-package.rst @@ -0,0 +1,7 @@ +vs-default-build-package +------------------------ + +* The :ref:`Visual Studio Generators` for VS 2010 and above now support + adding the PACKAGE target to the targets which are built by default. + The behavior is similar to :variable:`CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD` + and can be toggled using :variable:`CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD`. diff --git a/Help/variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD.rst b/Help/variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD.rst new file mode 100644 index 0000000..693ba45 --- /dev/null +++ b/Help/variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD.rst @@ -0,0 +1,8 @@ +CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD +----------------------------------------- + +Include ``PACKAGE`` target to default build. + +In Visual Studio solution, by default the ``PACKAGE`` target will not be part +of the default build. Setting this variable will enable the ``PACKAGE`` target +to be part of the default build. diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c60a1ff..602666e 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -681,20 +681,27 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( // default build if another target depends on it int type = target->GetType(); if (type == cmStateEnums::GLOBAL_TARGET) { - // check if INSTALL target is part of default build - if (target->GetName() == "INSTALL") { - // inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties - for (std::vector<std::string>::const_iterator i = configs.begin(); - i != configs.end(); ++i) { - const char* propertyValue = - target->Target->GetMakefile()->GetDefinition( - "CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD"); - cmGeneratorExpression ge; - CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = - ge.Parse(propertyValue); - if (cmSystemTools::IsOn( - cge->Evaluate(target->GetLocalGenerator(), *i))) { - activeConfigs.insert(*i); + std::list<std::string> targetNames; + targetNames.push_back("INSTALL"); + targetNames.push_back("PACKAGE"); + for (std::list<std::string>::const_iterator t = targetNames.begin(); + t != targetNames.end(); ++t) { + // check if target <*t> is part of default build + if (target->GetName() == *t) { + const std::string propertyName = + "CMAKE_VS_INCLUDE_" + *t + "_TO_DEFAULT_BUILD"; + // inspect CMAKE_VS_INCLUDE_<*t>_TO_DEFAULT_BUILD properties + for (std::vector<std::string>::const_iterator i = configs.begin(); + i != configs.end(); ++i) { + const char* propertyValue = + target->Target->GetMakefile()->GetDefinition(propertyName); + cmGeneratorExpression ge; + CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = + ge.Parse(propertyValue); + if (cmSystemTools::IsOn( + cge->Evaluate(target->GetLocalGenerator(), *i))) { + activeConfigs.insert(*i); + } } } } diff --git a/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake b/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake new file mode 100644 index 0000000..7265900 --- /dev/null +++ b/Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake @@ -0,0 +1,29 @@ +set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/AddPackageToDefault.sln") +if(NOT EXISTS "${vcSlnFile}") + set(RunCMake_TEST_FAILED "Project file ${vcSlnFile} does not exist.") + return() +endif() + +set(packageGuidFound FALSE) +set(packageGuid "") +set(packageInBuild FALSE) +file(STRINGS "${vcSlnFile}" lines) +foreach(line IN LISTS lines) + if(NOT packageGuidFound) + if(line MATCHES "^Project.*\"PACKAGE.vcx?proj\".*\"{([A-F0-9-]+)}\"$") + set(packageGuidFound TRUE) + set(packageGuid ${CMAKE_MATCH_1}) + endif() + else() + if(line MATCHES ".*{${packageGuid}}.*") + if(line MATCHES "^[ \t]*{${packageGuid}}\\..*\\.Build.0 = .*$") + set(packageInBuild TRUE) + endif() + endif() + endif() +endforeach() + +if(NOT packageInBuild) + set(RunCMake_TEST_FAILED "PACKAGE is not in default build") + return() +endif() diff --git a/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake b/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake new file mode 100644 index 0000000..5f69ec5 --- /dev/null +++ b/Tests/RunCMake/VSSolution/AddPackageToDefault.cmake @@ -0,0 +1,2 @@ +include(CPack) +set(CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD TRUE) diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index afd74a1..4ec3e3b 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cmake(Override1) run_cmake(Override2) run_cmake(StartupProject) run_cmake(StartupProjectMissing) +run_cmake(AddPackageToDefault) if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) run_cmake(StartupProjectUseFolders) |