VS: Add a source file property to mark content for Windows App deployment

Create a VS_DEPLOYMENT_CONTENT source file property, supporting
generator expressions, to compute whether a source file should be marked
as DeploymentContent or ExcludedFromBuild in Windows Phone and Windows
Store projects.

Inspired-by: Minmin Gong <minmin.gong@gmail.com>
This commit is contained in:
Brad King 2014-07-29 14:03:35 -04:00
parent f063a914c6
commit 9b4dc2ad4a
3 changed files with 52 additions and 0 deletions

View File

@ -287,6 +287,7 @@ Properties on Source Files
/prop_sf/OBJECT_DEPENDS
/prop_sf/OBJECT_OUTPUTS
/prop_sf/SYMBOLIC
/prop_sf/VS_DEPLOYMENT_CONTENT
/prop_sf/WRAP_EXCLUDE
/prop_sf/XCODE_EXPLICIT_FILE_TYPE
/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE

View File

@ -0,0 +1,11 @@
VS_DEPLOYMENT_CONTENT
---------------------
Mark a source file as content for deployment with a Windows Phone or
Windows Store application when built with a Visual Studio generator.
The value must evaluate to either ``1`` or ``0`` and may use
:manual:`generator expressions <cmake-generator-expressions(7)>`
to make the choice based on the build configuration.
The ``.vcxproj`` file entry for the source file will be
marked either ``DeploymentContent`` or ``ExcludedFromBuild``
for values ``1`` and ``0``, respectively.

View File

@ -1035,10 +1035,50 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
tool = "XML";
}
std::string deployContent;
if(this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore())
{
const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
if(content && *content)
{
toolHasSettings = true;
deployContent = content;
}
}
if(toolHasSettings)
{
this->WriteSource(tool, sf, ">\n");
if(!deployContent.empty())
{
std::vector<std::string> const* configs =
this->GlobalGenerator->GetConfigurations();
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent);
for(size_t i = 0; i != configs->size(); ++i)
{
if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1"))
{
this->WriteString("<DeploymentContent Condition=\""
"'$(Configuration)|$(Platform)'=='", 3);
(*this->BuildFileStream) << (*configs)[i] << "|"
<< this->Platform << "'\">true";
this->WriteString("</DeploymentContent>\n", 0);
}
else
{
this->WriteString("<ExcludedFromBuild Condition=\""
"'$(Configuration)|$(Platform)'=='", 3);
(*this->BuildFileStream) << (*configs)[i] << "|"
<< this->Platform << "'\">true";
this->WriteString("</ExcludedFromBuild>\n", 0);
}
}
}
this->WriteString("</", 2);
(*this->BuildFileStream) << tool << ">\n";
}