summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Boczar <boczar@hotmail.com>2020-02-18 20:07:39 (GMT)
committerBrad King <brad.king@kitware.com>2020-02-25 15:24:23 (GMT)
commit7c944da75700a2f68879551a253093b73f2d7951 (patch)
tree75c9a3052e3e6056a43719440c789d887d531b0c
parent8625ffd939b3c74944f6da9652777f7ca137b856 (diff)
downloadCMake-7c944da75700a2f68879551a253093b73f2d7951.zip
CMake-7c944da75700a2f68879551a253093b73f2d7951.tar.gz
CMake-7c944da75700a2f68879551a253093b73f2d7951.tar.bz2
VS: Add target property to explicitly control solution deployment
Add a `VS_SOLUTION_DEPLOY` property to control solution deploy mark. Fixes: #20346
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/prop_tgt/VS_SOLUTION_DEPLOY.rst29
-rw-r--r--Help/release/dev/vs-sln-deploy.rst6
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx36
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h4
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake58
-rw-r--r--Tests/RunCMake/VS10Project/VsDeployEnabled.cmake12
8 files changed, 129 insertions, 18 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index fb84378..37f8678 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -375,6 +375,7 @@ Properties on Targets
/prop_tgt/VS_SCC_PROJECTNAME
/prop_tgt/VS_SCC_PROVIDER
/prop_tgt/VS_SDK_REFERENCES
+ /prop_tgt/VS_SOLUTION_DEPLOY
/prop_tgt/VS_USER_PROPS
/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
/prop_tgt/VS_WINRT_COMPONENT
diff --git a/Help/prop_tgt/VS_SOLUTION_DEPLOY.rst b/Help/prop_tgt/VS_SOLUTION_DEPLOY.rst
new file mode 100644
index 0000000..7906d75
--- /dev/null
+++ b/Help/prop_tgt/VS_SOLUTION_DEPLOY.rst
@@ -0,0 +1,29 @@
+VS_SOLUTION_DEPLOY
+------------------
+
+Specify that the target should be marked for deployment when not targeting
+Windows CE, Windows Phone or a Windows Store application.
+
+If the target platform doesn't support deployment, this property won't have any effect.
+
+Generator expressions are supported.
+
+Example 1
+^^^^^^^^^
+
+This shows setting the variable for the target foo.
+
+.. code-block:: cmake
+
+ add_executable(foo SHARED foo.cpp)
+ set_property(TARGET foo PROPERTY VS_SOLUTION_DEPLOY ON)
+
+Example 2
+^^^^^^^^^
+
+This shows setting the variable for the Release configuration only.
+
+.. code-block:: cmake
+
+ add_executable(foo SHARED foo.cpp)
+ set_property(TARGET foo PROPERTY VS_SOLUTION_DEPLOY "$<NOT:$<CONFIG:Release>>")
diff --git a/Help/release/dev/vs-sln-deploy.rst b/Help/release/dev/vs-sln-deploy.rst
new file mode 100644
index 0000000..2e83e52
--- /dev/null
+++ b/Help/release/dev/vs-sln-deploy.rst
@@ -0,0 +1,6 @@
+vs-sln-deploy
+-------------
+
+* The :prop_tgt:`VS_SOLUTION_DEPLOY` target property was added to tell
+ :ref:`Visual Studio Generators` for VS 2010 and above to mark a
+ target for deployment even when not building for Windows Phone/Store/CE.
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 1c62fbd..fa0e935 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -275,23 +275,31 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
bool cmGlobalVisualStudio8Generator::NeedsDeploy(
cmGeneratorTarget const& target, const char* config) const
{
- cmStateEnums::TargetType type = target.GetType();
- bool noDeploy = DeployInhibited(target, config);
- return !noDeploy &&
- (type == cmStateEnums::EXECUTABLE ||
- type == cmStateEnums::SHARED_LIBRARY) &&
- this->TargetSystemSupportsDeployment();
-}
+ cmStateEnums::TargetType const type = target.GetType();
+ if (type != cmStateEnums::EXECUTABLE &&
+ type != cmStateEnums::SHARED_LIBRARY) {
+ // deployment only valid on executables and shared libraries.
+ return false;
+ }
-bool cmGlobalVisualStudio8Generator::DeployInhibited(
- cmGeneratorTarget const& target, const char* config) const
-{
- bool rVal = false;
- if (const char* prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
- rVal = cmIsOn(
+ if (const char* prop = target.GetProperty("VS_SOLUTION_DEPLOY")) {
+ // If set, it dictates behavior
+ return cmIsOn(
cmGeneratorExpression::Evaluate(prop, target.LocalGenerator, config));
}
- return rVal;
+
+ // To be deprecated, disable deployment even if target supports it.
+ if (const char* prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
+ if (cmIsOn(cmGeneratorExpression::Evaluate(prop, target.LocalGenerator,
+ config))) {
+ // If true, always disable deployment
+ return false;
+ }
+ }
+
+ // Legacy behavior, enabled deployment based on 'hard-coded' target
+ // platforms.
+ return this->TargetSystemSupportsDeployment();
}
bool cmGlobalVisualStudio8Generator::TargetSystemSupportsDeployment() const
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 8f8e33b..6ce67d3 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -57,10 +57,6 @@ protected:
virtual bool NeedsDeploy(cmGeneratorTarget const& target,
const char* config) const;
- /** Returns true if deployment has been disabled in cmake file. */
- bool DeployInhibited(cmGeneratorTarget const& target,
- const char* config) const;
-
/** Returns true if the target system support debugging deployment. */
virtual bool TargetSystemSupportsDeployment() const;
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 8a04f78..ff31a74 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -30,6 +30,7 @@ run_cmake(VsDpiAware)
run_cmake(VsDpiAwareBadParam)
run_cmake(VsPrecompileHeaders)
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
+run_cmake(VsDeployEnabled)
run_cmake(VsWinRTByDefault)
diff --git a/Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake b/Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake
new file mode 100644
index 0000000..0ff8678
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake
@@ -0,0 +1,58 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+#
+# Test solution file for deployment.
+#
+
+set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/VsDeployEnabled.sln")
+if(NOT EXISTS "${vcSlnFile}")
+ set(RunCMake_TEST_FAILED "Solution file ${vcSlnFile} does not exist.")
+ return()
+endif()
+
+
+
+set(FooProjGUID "")
+set(FoundFooProj FALSE)
+set(InFooProj FALSE)
+set(FoundReleaseDeploy FALSE)
+set(DeployConfigs Debug MinSizeRel RelWithDebInfo )
+
+file(STRINGS "${vcSlnFile}" lines)
+foreach(line IN LISTS lines)
+#message(STATUS "${line}")
+ if( (NOT InFooProj ) AND (line MATCHES "^[ \\t]*Project\\(\"{[A-F0-9-]+}\"\\) = \"foo\", \"foo.vcxproj\", \"({[A-F0-9-]+})\"[ \\t]*$"))
+ # First, identify the GUID for the foo project, and record it.
+ set(FoundFooProj TRUE)
+ set(InFooProj TRUE)
+ set(FooProjGUID ${CMAKE_MATCH_1})
+ elseif(InFooProj AND line MATCHES "EndProject")
+ set(InFooProj FALSE)
+ elseif((NOT InFooProj) AND line MATCHES "${FooProjGUID}\\.Release.*\\.Deploy\\.0")
+ # If foo's Release configuration is set to deploy, this is the error.
+ set(FoundReleaseDeploy TRUE)
+ endif()
+ if( line MATCHES "{[A-F0-9-]+}\\.([^\\|]+).*\\.Deploy\\.0" )
+ # Check that the other configurations ARE set to deploy.
+ list( REMOVE_ITEM DeployConfigs ${CMAKE_MATCH_1})
+ endif()
+endforeach()
+
+if(FoundReleaseDeploy)
+ set(RunCMake_TEST_FAILED "Release deployment enabled.")
+ return()
+endif()
+
+if(NOT FoundFooProj)
+ set(RunCMake_TEST_FAILED "Failed to find foo project in the solution.")
+ return()
+endif()
+
+list(LENGTH DeployConfigs length)
+if( length GREATER 0 )
+ set(RunCMake_TEST_FAILED "Failed to find Deploy lines for non-Release configurations. (${length})")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsDeployEnabled.cmake b/Tests/RunCMake/VS10Project/VsDeployEnabled.cmake
new file mode 100644
index 0000000..02b42b2
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDeployEnabled.cmake
@@ -0,0 +1,12 @@
+enable_language(CXX)
+
+set(DEPLOY_DIR
+ "temp\\foodir"
+)
+
+add_library(foo SHARED foo.cpp)
+
+set_target_properties(foo
+ PROPERTIES
+ VS_SOLUTION_DEPLOY $<NOT:$<CONFIG:Release>>
+)