Commit 917c035a authored by Wil Stark's avatar Wil Stark Committed by Brad King
Browse files

VS: support suppressing deployment of selected targets

Add a `VS_NO_SOLUTION_DEPLOY` target property to explicitly specify for
each target whether to suppress VS solution deployment of the generated
target project.

Fixes: #18953
parent 7574e160
......@@ -334,6 +334,7 @@ Properties on Targets
/prop_tgt/VS_IOT_STARTUP_TASK
/prop_tgt/VS_KEYWORD
/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
/prop_tgt/VS_NO_SOLUTION_DEPLOY
/prop_tgt/VS_SCC_AUXPATH
/prop_tgt/VS_SCC_LOCALPATH
/prop_tgt/VS_SCC_PROJECTNAME
......
VS_NO_SOLUTION_DEPLOY
---------------------
Specify that the target should not be marked for deployment to a Windows CE
or Windows Phone device in the generated Visual Studio solution.
Be default, all EXE and shared library (DLL) targets are marked to deploy to
the target device in the generated Visual Studio solution.
Generator expressions are supported.
There are reasons one might want to exclude a target / generated project from
deployment:
- The library or executable may not be necessary in the primary deploy/debug
scenario, and excluding from deployment saves time in the
develop/download/debug cycle.
- There may be insufficient space on the target device to accommodate all of
the build products.
- Visual Studio 2013 requires a target device IP address be entered for each
target marked for deployment. For large numbers of targets, this can be
tedious.
NOTE: Visual Studio *will* deploy all project dependencies of a project
tagged for deployment to the IP address configured for that project even
if those dependencies are not tagged for deployment.
Example 1
^^^^^^^^^
This shows setting the variable for the target foo.
.. code-block:: cmake
add_library(foo SHARED foo.cpp)
set_property(TARGET foo PROPERTY VS_NO_SOLUTION_DEPLOY ON)
Example 2
^^^^^^^^^
This shows setting the variable for the Release configuration only.
.. code-block:: cmake
add_library(foo SHARED foo.cpp)
set_property(TARGET foo PROPERTY VS_NO_SOLUTION_DEPLOY "$<CONFIG:Release>")
vs_wince_no_deploy
------------------
* A :prop_tgt:`VS_NO_SOLUTION_DEPLOY` target property was added to
tell :ref:`Visual Studio Generators` whether to deploy an artifact
to the WinCE or Windows Phone target device.
......@@ -252,15 +252,10 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
return ret;
}
bool cmGlobalVisualStudio11Generator::NeedsDeploy(
cmStateEnums::TargetType type) const
bool cmGlobalVisualStudio11Generator::TargetSystemSupportsDeployment() const
{
if ((type == cmStateEnums::EXECUTABLE ||
type == cmStateEnums::SHARED_LIBRARY) &&
(this->SystemIsWindowsPhone || this->SystemIsWindowsStore)) {
return true;
}
return cmGlobalVisualStudio10Generator::NeedsDeploy(type);
return this->SystemIsWindowsPhone || this->SystemIsWindowsStore ||
cmGlobalVisualStudio10Generator::TargetSystemSupportsDeployment();
}
bool cmGlobalVisualStudio11Generator::IsWindowsDesktopToolsetInstalled() const
......
......@@ -45,8 +45,8 @@ protected:
bool UseFolderProperty() const override;
static std::set<std::string> GetInstalledWindowsCESDKs();
/** Return true if the configuration needs to be deployed */
bool NeedsDeploy(cmStateEnums::TargetType type) const override;
/** Return true if target system supports debugging deployment. */
bool TargetSystemSupportsDeployment() const override;
private:
class Factory;
......
......@@ -273,7 +273,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
: this->GetPlatformName())
<< "\n";
}
if (this->NeedsDeploy(target.GetType())) {
if (this->NeedsDeploy(target, dstConfig)) {
fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".Deploy.0 = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
......@@ -284,11 +284,32 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
}
bool cmGlobalVisualStudio8Generator::NeedsDeploy(
cmStateEnums::TargetType type) const
cmGeneratorTarget const& target, const char* config) const
{
bool needsDeploy =
(type == cmStateEnums::EXECUTABLE || type == cmStateEnums::SHARED_LIBRARY);
return this->TargetsWindowsCE() && needsDeploy;
cmStateEnums::TargetType type = target.GetType();
bool noDeploy = DeployInhibited(target, config);
return !noDeploy &&
(type == cmStateEnums::EXECUTABLE ||
type == cmStateEnums::SHARED_LIBRARY) &&
this->TargetSystemSupportsDeployment();
}
bool cmGlobalVisualStudio8Generator::DeployInhibited(
cmGeneratorTarget const& target, const char* config) const
{
bool rVal = false;
if (const char* propStr = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(propStr);
std::string prop = cge->Evaluate(target.LocalGenerator, config);
rVal = cmSystemTools::IsOn(prop);
}
return rVal;
}
bool cmGlobalVisualStudio8Generator::TargetSystemSupportsDeployment() const
{
return this->TargetsWindowsCE();
}
bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
......
......@@ -54,7 +54,15 @@ protected:
bool AddCheckTarget();
/** Return true if the configuration needs to be deployed */
virtual bool NeedsDeploy(cmStateEnums::TargetType type) const;
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;
static cmIDEFlagTable const* GetExtraFlagTableVS8();
void WriteSolutionConfigurations(
......
......@@ -40,3 +40,62 @@ if(NOT FoundToolsVersion4)
set(RunCMake_TEST_FAILED "Failed to find correct ToolsVersion=\"4.0\" .")
return()
endif()
#
# Test solution file deployment items.
#
set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/VsCEDebuggerDeploy.sln")
if(NOT EXISTS "${vcSlnFile}")
set(RunCMake_TEST_FAILED "Solution file ${vcSlnFile} does not exist.")
return()
endif()
if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" )
set(RunCMake_TEST_FAILED "Test only valid for WindowsCE")
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 not inhibited by VS_NO_SOLUTION_DEPLOY_Release.")
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()
......@@ -4,10 +4,11 @@ set(DEPLOY_DIR
"temp\\foodir"
)
add_library(foo foo.cpp)
add_library(foo SHARED foo.cpp)
set_target_properties(foo
PROPERTIES
DEPLOYMENT_ADDITIONAL_FILES "foo.dll|\\foo\\src\\dir\\on\\host|$(RemoteDirectory)|0;bar.dll|\\bar\\src\\dir|$(RemoteDirectory)bardir|0"
DEPLOYMENT_REMOTE_DIRECTORY ${DEPLOY_DIR}
VS_NO_SOLUTION_DEPLOY $<CONFIG:Release>
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment