summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Farrier <john.farrier@digitalinblue.com>2013-04-29 14:48:22 (GMT)
committerBrad King <brad.king@kitware.com>2013-05-16 17:06:44 (GMT)
commit79ec7868d0f08c9ff2e6fa6454b205132acecc24 (patch)
treea5526400e3ac907c10b42cfd28fbcd419a11a020 /Source
parentc80594ba1274c3dc44c3f2efd70bd5c3d9066bf5 (diff)
downloadCMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.zip
CMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.tar.gz
CMake-79ec7868d0f08c9ff2e6fa6454b205132acecc24.tar.bz2
VS: Add Windows Forms Support
Add support to maintain designer functionality for Visual Studio C++ Windows Forms projects. Also add a test project showing how to use the CMakeLists.txt file and, when successfully configured, will allow use of the designer for the included form.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx12
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx66
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h3
4 files changed, 82 insertions, 3 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 335ba0f..f5d1560 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -98,6 +98,18 @@ void cmGeneratorTarget::ClassifySources()
this->IDLSources.push_back(sf);
if(isObjLib) { badObjLib.push_back(sf); }
}
+ else if(ext == "resx")
+ {
+ // Build and save the name of the corresponding .h file
+ // This relationship will be used later when building the project files.
+ // Both names would have been auto generated from Visual Studio
+ // where the user supplied the file name and Visual Studio
+ // appended the suffix.
+ std::string resx = sf->GetFullPath();
+ std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
+ this->ExpectedResxHeaders.insert(hFileName);
+ this->ResxSources.push_back(sf);
+ }
else if(header.find(sf->GetFullPath().c_str()))
{
this->HeaderSources.push_back(sf);
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index cbcd8a5..5f7019d 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -44,11 +44,15 @@ public:
std::vector<cmSourceFile*> ObjectSources;
std::vector<cmSourceFile*> ExternalObjects;
std::vector<cmSourceFile*> IDLSources;
+ std::vector<cmSourceFile*> ResxSources;
+
std::string ModuleDefinitionFile;
std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
+ std::set<std::string> ExpectedResxHeaders;
+
/** Full path with trailing slash to the top-level directory
holding object files for this target. Includes the build
time config name placeholder if needed for the generator. */
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 1cb9f23..933bf95 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -291,6 +291,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteCustomCommands();
this->WriteAllSources();
this->WriteDotNetReferences();
+
this->WriteWinRTReferences();
this->WriteProjectReferences();
this->WriteString(
@@ -455,6 +456,12 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
this->WriteString("<WindowsAppContainer>true"
"</WindowsAppContainer>\n", 2);
}
+
+ if(!this->GeneratorTarget->ResxSources.empty())
+ {
+ this->WriteString("<CLRSupport>true</CLRSupport>\n", 2);
+ }
+
this->WriteString("</PropertyGroup>\n", 1);
}
}
@@ -647,6 +654,23 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
}
+ std::vector<cmSourceFile*> resxObjs = this->GeneratorTarget->ResxSources;
+ if(!resxObjs.empty())
+ {
+ this->WriteString("<ItemGroup>\n", 1);
+ for(std::vector<cmSourceFile*>::iterator oi = resxObjs.begin();
+ oi != resxObjs.end(); ++oi)
+ {
+ std::string obj = (*oi)->GetFullPath();
+ this->WriteString("<EmbeddedResource Include=\"", 2);
+ this->ConvertToWindowsSlash(obj);
+ (*this->BuildFileStream ) << obj << "\">\n";
+ this->WriteString("<Filter>Resource Files</Filter>\n", 3);
+ this->WriteString("</EmbeddedResource>\n", 2);
+ }
+ this->WriteString("</ItemGroup>\n", 1);
+ }
+
// Add object library contents as external objects.
std::vector<std::string> objs;
this->GeneratorTarget->UseObjectLibraries(objs);
@@ -701,6 +725,23 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
<< "</UniqueIdentifier>\n";
this->WriteString("</Filter>\n", 2);
}
+
+ if(!this->GeneratorTarget->ResxSources.empty())
+ {
+ this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
+ std::string guidName = "SG_Filter_Resource Files";
+ this->GlobalGenerator->CreateGUID(guidName.c_str());
+ this->WriteString("<UniqueIdentifier>", 3);
+ std::string guid =
+ this->GlobalGenerator->GetGUID(guidName.c_str());
+ (*this->BuildFileStream) << "{" << guid << "}"
+ << "</UniqueIdentifier>\n";
+ this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3);
+ (*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;";
+ (*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n";
+ this->WriteString("</Filter>\n", 2);
+ }
+
this->WriteString("</ItemGroup>\n", 1);
this->WriteString("</Project>\n", 0);
// restore stream pointer
@@ -832,8 +873,20 @@ void cmVisualStudio10TargetGenerator::WriteSource(
}
this->ConvertToWindowsSlash(sourceFile);
this->WriteString("<", 2);
- (*this->BuildFileStream ) << tool <<
- " Include=\"" << sourceFile << "\"" << (end? end : " />\n");
+ (*this->BuildFileStream ) << tool << " Include=\"" << sourceFile << "\"";
+
+ if(sf->GetExtension() == "h" &&
+ this->IsResxHeader(sf->GetFullPath()))
+ {
+ (*this->BuildFileStream ) << ">\n";
+ this->WriteString("<FileType>CppForm</FileType>\n", 3);
+ this->WriteString("</ClInclude>\n", 2);
+ }
+ else
+ {
+ (*this->BuildFileStream ) << (end? end : " />\n");
+ }
+
ToolSource toolSource = {sf, forceRelative};
this->Tools[tool].push_back(toolSource);
}
@@ -1718,3 +1771,12 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
}
this->WriteString("</ItemGroup>\n", 1);
}
+
+bool cmVisualStudio10TargetGenerator::
+ IsResxHeader(const std::string& headerFile)
+{
+ std::set<std::string>::iterator it =
+ this->GeneratorTarget->ExpectedResxHeaders.find(headerFile);
+
+ return it != this->GeneratorTarget->ExpectedResxHeaders.end();
+}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 55a850a..73d5961 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -62,6 +62,7 @@ private:
void WriteWinRTReferences();
void WritePathAndIncrementalLinkOptions();
void WriteItemDefinitionGroups();
+
bool ComputeClOptions();
bool ComputeClOptions(std::string const& configName);
void WriteClOptions(std::string const& config,
@@ -91,7 +92,7 @@ private:
std::vector<cmSourceGroup>& );
void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed,
const std::vector<cmSourceGroup>& allGroups);
-
+ bool IsResxHeader(const std::string& headerFile);
private:
typedef cmVisualStudioGeneratorOptions Options;