summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorGilles Khouzam <gillesk@microsoft.com>2015-03-31 20:49:39 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-03 17:40:35 (GMT)
commit01a9ab0def07ecddbc1bdfa67fec1bd3e6d030ea (patch)
treed5ae25dcf79d63031f26f2b879a30c19d388020f /Source/cmVisualStudio10TargetGenerator.cxx
parent84136c5a83bf9e1caf158a37f987465a8f39f8d0 (diff)
downloadCMake-01a9ab0def07ecddbc1bdfa67fec1bd3e6d030ea.zip
CMake-01a9ab0def07ecddbc1bdfa67fec1bd3e6d030ea.tar.gz
CMake-01a9ab0def07ecddbc1bdfa67fec1bd3e6d030ea.tar.bz2
VS: Add support for XAML source files
XAML files are by default of type Page in the vcxproj and can be overriden by setting the VS_XAML_TYPE property. The .cpp and .h file of the same name are automatically added as depending on the XAML file. New VSXaml test builds a basic XAML WindowsStore 8.1 app with VS2013.
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx80
1 files changed, 77 insertions, 3 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 19444ed..dad6f93 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -461,6 +461,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteAllSources();
this->WriteDotNetReferences();
this->WriteEmbeddedResourceGroup();
+ this->WriteXamlFilesGroup();
this->WriteWinRTReferences();
this->WriteProjectReferences();
this->WriteString(
@@ -522,8 +523,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
this->WriteString("<DependentUpon>", 3);
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
- (*this->BuildFileStream ) << hFileName;
- this->WriteString("</DependentUpon>\n", 3);
+ (*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
std::vector<std::string> const * configs =
this->GlobalGenerator->GetConfigurations();
@@ -546,6 +546,38 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
}
}
+void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
+{
+ std::vector<cmSourceFile const*> xamlObjs;
+ this->GeneratorTarget->GetXamlSources(xamlObjs, "");
+ if (!xamlObjs.empty())
+ {
+ this->WriteString("<ItemGroup>\n", 1);
+ for (std::vector<cmSourceFile const*>::const_iterator
+ oi = xamlObjs.begin(); oi != xamlObjs.end(); ++oi)
+ {
+ std::string obj = (*oi)->GetFullPath();
+ std::string xamlType;
+ const char * xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE");
+ if (xamlTypeProperty)
+ {
+ xamlType = xamlTypeProperty;
+ }
+ else
+ {
+ xamlType = "Page";
+ }
+
+ this->WriteSource(xamlType, *oi, ">\n");
+ this->WriteString("<SubType>Designer</SubType>\n", 3);
+ this->WriteString("</", 2);
+ (*this->BuildFileStream) << xamlType << ">\n";
+
+ }
+ this->WriteString("</ItemGroup>\n", 1);
+ }
+}
+
void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
{
if(this->MSTools)
@@ -1192,12 +1224,21 @@ WriteGroupSources(const char* name,
void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf)
{
- if(this->IsResxHeader(sf->GetFullPath()))
+ std::string const& fileName = sf->GetFullPath();
+ if (this->IsResxHeader(fileName))
{
this->WriteSource("ClInclude", sf, ">\n");
this->WriteString("<FileType>CppForm</FileType>\n", 3);
this->WriteString("</ClInclude>\n", 2);
}
+ else if (this->IsXamlHeader(fileName))
+ {
+ this->WriteSource("ClInclude", sf, ">\n");
+ this->WriteString("<DependentUpon>", 3);
+ std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
+ (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
+ this->WriteString("</ClInclude>\n", 2);
+ }
else
{
this->WriteSource("ClInclude", sf);
@@ -1669,6 +1710,17 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
" ", "\n", lang);
}
}
+ if (this->IsXamlSource(source->GetFullPath()))
+ {
+ (*this->BuildFileStream) << firstString;
+ firstString = ""; // only do firstString once
+ hasFlags = true;
+ this->WriteString("<DependentUpon>", 3);
+ const std::string& fileName = source->GetFullPath();
+ std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
+ (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
+ }
+
return hasFlags;
}
@@ -2749,6 +2801,28 @@ bool cmVisualStudio10TargetGenerator::
return it != expectedResxHeaders.end();
}
+bool cmVisualStudio10TargetGenerator::
+IsXamlHeader(const std::string& headerFile)
+{
+ std::set<std::string> expectedXamlHeaders;
+ this->GeneratorTarget->GetExpectedXamlHeaders(expectedXamlHeaders, "");
+
+ std::set<std::string>::const_iterator it =
+ expectedXamlHeaders.find(headerFile);
+ return it != expectedXamlHeaders.end();
+}
+
+bool cmVisualStudio10TargetGenerator::
+IsXamlSource(const std::string& sourceFile)
+{
+ std::set<std::string> expectedXamlSources;
+ this->GeneratorTarget->GetExpectedXamlSources(expectedXamlSources, "");
+
+ std::set<std::string>::const_iterator it =
+ expectedXamlSources.find(sourceFile);
+ return it != expectedXamlSources.end();
+}
+
void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
{
bool isAppContainer = false;