mirror of
https://github.com/reactos/CMake.git
synced 2025-01-19 01:42:18 +00:00
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.
This commit is contained in:
parent
1528831bb1
commit
9e3164dfa2
@ -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
|
||||
|
7
Help/release/dev/vs-default-build-package.rst
Normal file
7
Help/release/dev/vs-default-build-package.rst
Normal file
@ -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`.
|
@ -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.
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake
Normal file
29
Tests/RunCMake/VSSolution/AddPackageToDefault-check.cmake
Normal file
@ -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()
|
2
Tests/RunCMake/VSSolution/AddPackageToDefault.cmake
Normal file
2
Tests/RunCMake/VSSolution/AddPackageToDefault.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
include(CPack)
|
||||
set(CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD TRUE)
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user