summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-06-28 22:29:54 (GMT)
committerBrad King <brad.king@kitware.com>2013-06-28 22:29:54 (GMT)
commit4e5cb398ae392079031ae6a880569349c29770a6 (patch)
tree55b13e53e2368e0425602fb8527936accc50ac9a /Source/cmVisualStudio10TargetGenerator.cxx
parent78fdbbcb4130eedc2cb48ec9e67fad5c2beffb0e (diff)
parentdaaf6283f5c0e8b7ea7ee93f983ad56d4498788d (diff)
downloadCMake-4e5cb398ae392079031ae6a880569349c29770a6.zip
CMake-4e5cb398ae392079031ae6a880569349c29770a6.tar.gz
CMake-4e5cb398ae392079031ae6a880569349c29770a6.tar.bz2
Merge branch 'master' into vs12-generator
Resolve conflicts in Tests/Preprocess/CMakeLists.txt by keeping the side from 'master'.
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx125
1 files changed, 103 insertions, 22 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9cfb370..c70bf3a 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -274,6 +274,15 @@ void cmVisualStudio10TargetGenerator::Generate()
"</Keyword>\n";
}
+ const char* vsGlobalRootNamespace =
+ this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
+ if(vsGlobalRootNamespace)
+ {
+ this->WriteString("<RootNamespace>", 2);
+ (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace) <<
+ "</RootNamespace>\n";
+ }
+
this->WriteString("<Platform>", 2);
(*this->BuildFileStream) << this->Platform << "</Platform>\n";
const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
@@ -283,6 +292,13 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("<ProjectName>", 2);
(*this->BuildFileStream) << projLabel << "</ProjectName>\n";
+ if(const char* targetFrameworkVersion = this->Target->GetProperty(
+ "VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
+ {
+ this->WriteString("<TargetFrameworkVersion>", 2);
+ (*this->BuildFileStream) << targetFrameworkVersion
+ << "</TargetFrameworkVersion>\n";
+ }
this->WriteString("</PropertyGroup>\n", 1);
this->WriteString("<Import Project="
"\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
@@ -303,6 +319,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteCustomCommands();
this->WriteAllSources();
this->WriteDotNetReferences();
+
this->WriteWinRTReferences();
this->WriteProjectReferences();
this->WriteString(
@@ -467,6 +484,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);
}
}
@@ -659,6 +682,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);
@@ -713,6 +753,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
@@ -844,8 +901,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);
}
@@ -1192,7 +1261,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
if(!linkLanguage)
{
cmSystemTools::Error
- ("CMake can not determine linker language for target:",
+ ("CMake can not determine linker language for target: ",
this->Name.c_str());
return false;
}
@@ -1219,17 +1288,16 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
{
flags += " /TP ";
}
+ this->LocalGenerator->AddCompileOptions(flags, this->Target,
+ linkLanguage, configName.c_str());
}
- // Add the target-specific flags.
- if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
- {
- flags += " ";
- flags += targetFlags;
- }
+
// Get preprocessor definitions for this directory.
std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
clOptions.FixExceptionHandlingDefault();
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+ std::string asmLocation = configName + "/";
+ clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
clOptions.Parse(flags.c_str());
clOptions.Parse(defineFlags.c_str());
clOptions.AddDefines(this->Target->GetCompileDefinitions(
@@ -1272,18 +1340,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "CXX");
- this->WriteString("<AssemblerListingLocation>", 3);
- *this->BuildFileStream << configName
- << "</AssemblerListingLocation>\n";
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
- if(this->Target->GetType() != cmTarget::OBJECT_LIBRARY)
- {
- this->WriteString("<ProgramDataBaseFileName>", 3);
- *this->BuildFileStream << this->Target->GetPDBDirectory(configName.c_str())
- << "/"
- << this->Target->GetPDBName(configName.c_str())
- << "</ProgramDataBaseFileName>\n";
- }
this->WriteString("</ClCompile>\n", 2);
}
@@ -1377,7 +1434,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
if(!linkLanguage)
{
cmSystemTools::Error
- ("CMake can not determine linker language for target:",
+ ("CMake can not determine linker language for target: ",
this->Name.c_str());
return false;
}
@@ -1459,7 +1516,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
if(!pcli)
{
cmSystemTools::Error
- ("CMake can not compute cmComputeLinkInformation for target:",
+ ("CMake can not compute cmComputeLinkInformation for target: ",
this->Name.c_str());
return false;
}
@@ -1591,6 +1648,21 @@ void cmVisualStudio10TargetGenerator::
WriteMidlOptions(std::string const& /*config*/,
std::vector<std::string> const & includes)
{
+ // This processes *any* of the .idl files specified in the project's file
+ // list (and passed as the item metadata %(Filename) expressing the rule
+ // input filename) into output files at the per-config *build* dir
+ // ($(IntDir)) each.
+ //
+ // IOW, this MIDL section is intended to provide a fully generic syntax
+ // content suitable for most cases (read: if you get errors, then it's quite
+ // probable that the error is on your side of the .idl setup).
+ //
+ // Also, note that the marked-as-generated _i.c file in the Visual Studio
+ // generator case needs to be referred to as $(IntDir)\foo_i.c at the
+ // project's file list, otherwise the compiler-side processing won't pick it
+ // up (for non-directory form, it ends up looking in project binary dir
+ // only). Perhaps there's something to be done to make this more automatic
+ // on the CMake side?
this->WriteString("<Midl>\n", 2);
this->OutputIncludes(includes);
this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
@@ -1730,3 +1802,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();
+}