mirror of
https://github.com/reactos/CMake.git
synced 2025-02-07 12:26:40 +00:00
Merge topic 'vs-sln-deploy'
7c944da757 VS: Add target property to explicitly control solution deployment Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4357
This commit is contained in:
commit
85c1b2b6dd
@ -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
|
||||
|
29
Help/prop_tgt/VS_SOLUTION_DEPLOY.rst
Normal file
29
Help/prop_tgt/VS_SOLUTION_DEPLOY.rst
Normal file
@ -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>>")
|
6
Help/release/dev/vs-sln-deploy.rst
Normal file
6
Help/release/dev/vs-sln-deploy.rst
Normal file
@ -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.
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -30,6 +30,7 @@ run_cmake(VsDpiAware)
|
||||
run_cmake(VsDpiAwareBadParam)
|
||||
run_cmake(VsPrecompileHeaders)
|
||||
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
|
||||
run_cmake(VsDeployEnabled)
|
||||
|
||||
run_cmake(VsWinRTByDefault)
|
||||
|
||||
|
58
Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake
Normal file
58
Tests/RunCMake/VS10Project/VsDeployEnabled-check.cmake
Normal file
@ -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()
|
12
Tests/RunCMake/VS10Project/VsDeployEnabled.cmake
Normal file
12
Tests/RunCMake/VS10Project/VsDeployEnabled.cmake
Normal file
@ -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>>
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user