summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx392
1 files changed, 211 insertions, 181 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 82f4b99..5dd9e48 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -10,27 +10,6 @@
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
-#include "cmVS10CLFlagTable.h"
-#include "cmVS10LibFlagTable.h"
-#include "cmVS10LinkFlagTable.h"
-#include "cmVS10MASMFlagTable.h"
-#include "cmVS10RCFlagTable.h"
-#include "cmVS11CLFlagTable.h"
-#include "cmVS11LibFlagTable.h"
-#include "cmVS11LinkFlagTable.h"
-#include "cmVS11MASMFlagTable.h"
-#include "cmVS11RCFlagTable.h"
-#include "cmVS12CLFlagTable.h"
-#include "cmVS12LibFlagTable.h"
-#include "cmVS12LinkFlagTable.h"
-#include "cmVS12MASMFlagTable.h"
-#include "cmVS12RCFlagTable.h"
-#include "cmVS140CLFlagTable.h"
-#include "cmVS141CLFlagTable.h"
-#include "cmVS14LibFlagTable.h"
-#include "cmVS14LinkFlagTable.h"
-#include "cmVS14MASMFlagTable.h"
-#include "cmVS14RCFlagTable.h"
#include "cmVisualStudioGeneratorOptions.h"
#include "windows.h"
@@ -38,102 +17,6 @@
static std::string const kWINDOWS_7_1_SDK = "Windows7.1SDK";
-cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
-{
- if (this->MSTools) {
- cmGlobalVisualStudioGenerator::VSVersion v =
- this->LocalGenerator->GetVersion();
- if (v >= cmGlobalVisualStudioGenerator::VS14) {
- // FIXME: All flag table selection should be based on the toolset name.
- // See issue #16153. For now, treat VS 15's toolset as a special case.
- const char* toolset = this->GlobalGenerator->GetPlatformToolset();
- if (toolset && cmHasLiteralPrefix(toolset, "v141")) {
- return cmVS141CLFlagTable;
- }
- return cmVS140CLFlagTable;
- } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
- return cmVS12CLFlagTable;
- } else if (v == cmGlobalVisualStudioGenerator::VS11) {
- return cmVS11CLFlagTable;
- } else {
- return cmVS10CLFlagTable;
- }
- }
- return 0;
-}
-
-cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const
-{
- if (this->MSTools) {
- cmGlobalVisualStudioGenerator::VSVersion v =
- this->LocalGenerator->GetVersion();
- if (v >= cmGlobalVisualStudioGenerator::VS14) {
- return cmVS14RCFlagTable;
- } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
- return cmVS12RCFlagTable;
- } else if (v == cmGlobalVisualStudioGenerator::VS11) {
- return cmVS11RCFlagTable;
- } else {
- return cmVS10RCFlagTable;
- }
- }
- return 0;
-}
-
-cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
-{
- if (this->MSTools) {
- cmGlobalVisualStudioGenerator::VSVersion v =
- this->LocalGenerator->GetVersion();
- if (v >= cmGlobalVisualStudioGenerator::VS14) {
- return cmVS14LibFlagTable;
- } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
- return cmVS12LibFlagTable;
- } else if (v == cmGlobalVisualStudioGenerator::VS11) {
- return cmVS11LibFlagTable;
- } else {
- return cmVS10LibFlagTable;
- }
- }
- return 0;
-}
-
-cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
-{
- if (this->MSTools) {
- cmGlobalVisualStudioGenerator::VSVersion v =
- this->LocalGenerator->GetVersion();
- if (v >= cmGlobalVisualStudioGenerator::VS14) {
- return cmVS14LinkFlagTable;
- } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
- return cmVS12LinkFlagTable;
- } else if (v == cmGlobalVisualStudioGenerator::VS11) {
- return cmVS11LinkFlagTable;
- } else {
- return cmVS10LinkFlagTable;
- }
- }
- return 0;
-}
-
-cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const
-{
- if (this->MSTools) {
- cmGlobalVisualStudioGenerator::VSVersion v =
- this->LocalGenerator->GetVersion();
- if (v >= cmGlobalVisualStudioGenerator::VS14) {
- return cmVS14MASMFlagTable;
- } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
- return cmVS12MASMFlagTable;
- } else if (v == cmGlobalVisualStudioGenerator::VS11) {
- return cmVS11MASMFlagTable;
- } else {
- return cmVS10MASMFlagTable;
- }
- }
- return 0;
-}
-
static std::string cmVS10EscapeXML(std::string arg)
{
cmSystemTools::ReplaceString(arg, "&", "&");
@@ -170,6 +53,12 @@ static std::string cmVS10EscapeComment(std::string comment)
return echoable;
}
+static bool cmVS10IsTargetsFile(std::string const& path)
+{
+ std::string const ext = cmSystemTools::GetFilenameLastExtension(path);
+ return cmSystemTools::Strucmp(ext.c_str(), ".targets") == 0;
+}
+
cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
{
@@ -255,7 +144,7 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
void cmVisualStudio10TargetGenerator::Generate()
{
// do not generate external ms projects
- if (this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY ||
+ if (this->GeneratorTarget->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) {
return;
}
@@ -264,7 +153,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->Name.c_str());
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
".vcxproj");
- if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
+ if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
if (!this->ComputeClOptions()) {
return;
}
@@ -277,6 +166,9 @@ void cmVisualStudio10TargetGenerator::Generate()
if (!this->ComputeLinkOptions()) {
return;
}
+ if (!this->ComputeLibOptions()) {
+ return;
+ }
}
std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
path += "/";
@@ -329,13 +221,22 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteString("</PropertyGroup>\n", 1);
}
+ if (const char* hostArch =
+ this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) {
+ this->WriteString("<PropertyGroup>\n", 1);
+ this->WriteString("<PreferredToolArchitecture>", 2);
+ (*this->BuildFileStream) << cmVS10EscapeXML(hostArch)
+ << "</PreferredToolArchitecture>\n";
+ this->WriteString("</PropertyGroup>\n", 1);
+ }
+
this->WriteProjectConfigurations();
this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
this->WriteString("<ProjectGUID>", 2);
(*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
if (this->MSTools &&
- this->GeneratorTarget->GetType() <= cmState::GLOBAL_TARGET) {
+ this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) {
this->WriteApplicationTypeSettings();
this->VerifyNecessaryFiles();
}
@@ -472,6 +373,7 @@ void cmVisualStudio10TargetGenerator::Generate()
1);
this->WriteTargetSpecificReferences();
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
+ this->WriteTargetsFileReferences();
if (this->GlobalGenerator->IsMasmEnabled()) {
this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
"BuildCustomizations\\masm.targets\" />\n",
@@ -587,6 +489,31 @@ void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
}
}
+void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences()
+{
+ for (std::vector<TargetsFileAndConfigs>::iterator i =
+ this->TargetsFileAndConfigsVec.begin();
+ i != this->TargetsFileAndConfigsVec.end(); ++i) {
+ TargetsFileAndConfigs const& tac = *i;
+ this->WriteString("<Import Project=\"", 3);
+ (*this->BuildFileStream) << tac.File << "\" ";
+ (*this->BuildFileStream) << "Condition=\"";
+ (*this->BuildFileStream) << "Exists('" << tac.File << "')";
+ if (!tac.Configs.empty()) {
+ (*this->BuildFileStream) << " And (";
+ for (size_t j = 0; j < tac.Configs.size(); ++j) {
+ if (j > 0) {
+ (*this->BuildFileStream) << " Or ";
+ }
+ (*this->BuildFileStream) << "'$(Configuration)'=='" << tac.Configs[j]
+ << "'";
+ }
+ (*this->BuildFileStream) << ")";
+ }
+ (*this->BuildFileStream) << "\" />\n";
+ }
+}
+
void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
{
std::vector<std::string> references;
@@ -646,15 +573,15 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
configType += cmVS10EscapeXML(vsConfigurationType);
} else {
switch (this->GeneratorTarget->GetType()) {
- case cmState::SHARED_LIBRARY:
- case cmState::MODULE_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
configType += "DynamicLibrary";
break;
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY:
configType += "StaticLibrary";
break;
- case cmState::EXECUTABLE:
+ case cmStateEnums::EXECUTABLE:
if (this->NsightTegra &&
!this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
// Android executables are .so too.
@@ -663,8 +590,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
configType += "Application";
}
break;
- case cmState::UTILITY:
- case cmState::GLOBAL_TARGET:
+ case cmStateEnums::UTILITY:
+ case cmStateEnums::GLOBAL_TARGET:
if (this->NsightTegra) {
// Tegra-Android platform does not understand "Utility".
configType += "StaticLibrary";
@@ -672,8 +599,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
configType += "Utility";
}
break;
- case cmState::UNKNOWN_LIBRARY:
- case cmState::INTERFACE_LIBRARY:
+ case cmStateEnums::UNKNOWN_LIBRARY:
+ case cmStateEnums::INTERFACE_LIBRARY:
break;
}
}
@@ -701,7 +628,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
std::string useOfMfcValue = "false";
- if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
+ if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
if (mfcFlagValue == "1") {
useOfMfcValue = "Static";
} else if (mfcFlagValue == "2") {
@@ -712,14 +639,15 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
mfcLine += useOfMfcValue + "</UseOfMfc>\n";
this->WriteString(mfcLine.c_str(), 2);
- if ((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY &&
+ if ((this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY &&
this->ClOptions[config]->UsingUnicode()) ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore() ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
- } else if (this->GeneratorTarget->GetType() <= cmState::MODULE_LIBRARY &&
+ } else if (this->GeneratorTarget->GetType() <=
+ cmStateEnums::MODULE_LIBRARY &&
this->ClOptions[config]->UsingSBCS()) {
this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
} else {
@@ -1342,7 +1270,7 @@ void cmVisualStudio10TargetGenerator::WriteSources(
void cmVisualStudio10TargetGenerator::WriteAllSources()
{
- if (this->GeneratorTarget->GetType() > cmState::UTILITY) {
+ if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) {
return;
}
this->WriteString("<ItemGroup>\n", 1);
@@ -1462,8 +1390,13 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
objectName = this->GeneratorTarget->GetObjectName(&sf);
}
std::string flags;
+ bool configDependentFlags = false;
std::string defines;
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
+
+ if (cmGeneratorExpression::Find(cflags) != std::string::npos) {
+ configDependentFlags = true;
+ }
flags += cflags;
}
if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
@@ -1519,20 +1452,31 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
// if we have flags or defines for this config then
// use them
- if (!flags.empty() || !configDefines.empty() || compileAs || noWinRT) {
+ if (!flags.empty() || configDependentFlags || !configDefines.empty() ||
+ compileAs || noWinRT) {
(*this->BuildFileStream) << firstString;
firstString = ""; // only do firstString once
hasFlags = true;
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
cmVisualStudioGeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
- this->GetClFlagTable(), 0, this);
+ gg->GetClFlagTable(), 0, this);
if (compileAs) {
clOptions.AddFlag("CompileAs", compileAs);
}
if (noWinRT) {
clOptions.AddFlag("CompileAsWinRT", "false");
}
- clOptions.Parse(flags.c_str());
+ if (configDependentFlags) {
+ cmGeneratorExpression ge;
+ CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
+ std::string evaluatedFlags =
+ cge->Evaluate(this->LocalGenerator, *config);
+ clOptions.Parse(evaluatedFlags.c_str());
+ } else {
+ clOptions.Parse(flags.c_str());
+ }
if (clOptions.HasFlag("AdditionalIncludeDirectories")) {
clOptions.AppendFlag("AdditionalIncludeDirectories",
"%(AdditionalIncludeDirectories)");
@@ -1564,8 +1508,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
{
- cmState::TargetType ttype = this->GeneratorTarget->GetType();
- if (ttype > cmState::GLOBAL_TARGET) {
+ cmStateEnums::TargetType ttype = this->GeneratorTarget->GetType();
+ if (ttype > cmStateEnums::GLOBAL_TARGET) {
return;
}
@@ -1576,7 +1520,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
for (std::vector<std::string>::const_iterator config =
this->Configurations.begin();
config != this->Configurations.end(); ++config) {
- if (ttype >= cmState::UTILITY) {
+ if (ttype >= cmStateEnums::UTILITY) {
this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
*this->BuildFileStream
<< "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
@@ -1589,7 +1533,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
intermediateDir += "/";
std::string outDir;
std::string targetNameFull;
- if (ttype == cmState::OBJECT_LIBRARY) {
+ if (ttype == cmStateEnums::OBJECT_LIBRARY) {
outDir = intermediateDir;
targetNameFull = this->GeneratorTarget->GetName();
targetNameFull += ".lib";
@@ -1636,8 +1580,8 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
}
// static libraries and things greater than modules do not need
// to set this option
- if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
- this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) {
return;
}
Options& linkOptions = *(this->LinkOptions[configName]);
@@ -1686,8 +1630,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
// copied from cmLocalVisualStudio7Generator.cxx 805
// TODO: Integrate code below with cmLocalVisualStudio7Generator.
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::Compiler, this->GetClFlagTable()));
+ this->LocalGenerator, Options::Compiler, gg->GetClFlagTable()));
Options& clOptions = *pOptions;
std::string flags;
@@ -1758,8 +1704,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
clOptions.AddFlag("CompileAsWinRT", "true");
// For WinRT components, add the _WINRT_DLL define to produce a lib
- if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
- this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
clOptions.AddDefine("_WINRT_DLL");
}
} else if (this->GlobalGenerator->TargetsWindowsStore() ||
@@ -1851,8 +1797,10 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
std::string const& configName)
{
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::ResourceCompiler, this->GetRcFlagTable()));
+ this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable()));
Options& rcOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
@@ -1908,8 +1856,10 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
std::string const& configName)
{
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::MasmCompiler, this->GetMasmFlagTable()));
+ this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable()));
Options& masmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
@@ -1949,8 +1899,8 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
void cmVisualStudio10TargetGenerator::WriteLibOptions(
std::string const& config)
{
- if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY &&
- this->GeneratorTarget->GetType() != cmState::OBJECT_LIBRARY) {
+ if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ this->GeneratorTarget->GetType() != cmStateEnums::OBJECT_LIBRARY) {
return;
}
std::string libflags;
@@ -1958,9 +1908,11 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget);
if (!libflags.empty()) {
this->WriteString("<Lib>\n", 2);
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
cmVisualStudioGeneratorOptions libOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker,
- this->GetLibFlagTable(), 0, this);
+ gg->GetLibFlagTable(), 0, this);
libOptions.Parse(libflags.c_str());
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
@@ -1983,9 +1935,9 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
void cmVisualStudio10TargetGenerator::WriteManifestOptions(
std::string const& config)
{
- if (this->GeneratorTarget->GetType() != cmState::EXECUTABLE &&
- this->GeneratorTarget->GetType() != cmState::SHARED_LIBRARY &&
- this->GeneratorTarget->GetType() != cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE &&
+ this->GeneratorTarget->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GeneratorTarget->GetType() != cmStateEnums::MODULE_LIBRARY) {
return;
}
@@ -2136,9 +2088,9 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
{
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
- this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
- this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE ||
+ this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
for (std::vector<std::string>::const_iterator i =
this->Configurations.begin();
i != this->Configurations.end(); ++i) {
@@ -2153,8 +2105,10 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string const& config)
{
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::Linker, this->GetLinkFlagTable(), 0, this));
+ this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), 0, this));
Options& linkOptions = *pOptions;
const std::string& linkLanguage =
@@ -2169,10 +2123,10 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string CONFIG = cmSystemTools::UpperCase(config);
const char* linkType = "SHARED";
- if (this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
linkType = "MODULE";
}
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
linkType = "EXE";
}
std::string flags;
@@ -2229,9 +2183,16 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
// add the libraries for the target to libs string
cmComputeLinkInformation& cli = *pcli;
- this->AddLibraries(cli, libVec);
+ std::vector<std::string> vsTargetVec;
+ this->AddLibraries(cli, libVec, vsTargetVec);
linkOptions.AddFlag("AdditionalDependencies", libVec);
+ // Populate TargetsFileAndConfigsVec
+ for (std::vector<std::string>::iterator ti = vsTargetVec.begin();
+ ti != vsTargetVec.end(); ++ti) {
+ this->AddTargetsFileAndConfigPair(*ti, config);
+ }
+
std::vector<std::string> const& ldirs = cli.GetDirectories();
std::vector<std::string> linkDirs;
for (std::vector<std::string>::const_iterator d = ldirs.begin();
@@ -2249,7 +2210,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string targetNameFull;
std::string targetNameImport;
std::string targetNamePDB;
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull,
targetNameImport, targetNamePDB,
config.c_str());
@@ -2265,7 +2226,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
if (this->GlobalGenerator->TargetsWindowsCE()) {
linkOptions.AddFlag("SubSystem", "WindowsCE");
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
if (this->ClOptions[config]->UsingUnicode()) {
linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup");
} else {
@@ -2278,7 +2239,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
} else {
if (this->GlobalGenerator->TargetsWindowsCE()) {
linkOptions.AddFlag("SubSystem", "WindowsCE");
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
if (this->ClOptions[config]->UsingUnicode()) {
linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup");
} else {
@@ -2316,7 +2277,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
// A Windows Runtime component uses internal .NET metadata,
// so does not have an import library.
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") &&
- this->GeneratorTarget->GetType() != cmState::EXECUTABLE) {
+ this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE) {
linkOptions.AddFlag("GenerateWindowsMetadata", "true");
} else if (this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore()) {
@@ -2347,7 +2308,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
"%(IgnoreSpecificDefaultLibraries)");
}
- if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+ if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GeneratorTarget->IsExecutableWithExports()) &&
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
if (this->GeneratorTarget->GetPropertyAsBool(
@@ -2386,11 +2347,54 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
return true;
}
+bool cmVisualStudio10TargetGenerator::ComputeLibOptions()
+{
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ for (std::vector<std::string>::const_iterator i =
+ this->Configurations.begin();
+ i != this->Configurations.end(); ++i) {
+ if (!this->ComputeLibOptions(*i)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
+ std::string const& config)
+{
+ cmComputeLinkInformation* pcli =
+ this->GeneratorTarget->GetLinkInformation(config.c_str());
+ if (!pcli) {
+ cmSystemTools::Error(
+ "CMake can not compute cmComputeLinkInformation for target: ",
+ this->Name.c_str());
+ return false;
+ }
+
+ cmComputeLinkInformation& cli = *pcli;
+ typedef cmComputeLinkInformation::ItemVector ItemVector;
+ const ItemVector& libs = cli.GetItems();
+ std::string currentBinDir =
+ this->LocalGenerator->GetCurrentBinaryDirectory();
+ for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
+ if (l->IsPath && cmVS10IsTargetsFile(l->Value)) {
+ std::string path = this->LocalGenerator->ConvertToRelativePath(
+ currentBinDir, l->Value.c_str());
+ this->ConvertToWindowsSlash(path);
+ this->AddTargetsFileAndConfigPair(path, config);
+ }
+ }
+
+ return true;
+}
+
void cmVisualStudio10TargetGenerator::WriteLinkOptions(
std::string const& config)
{
- if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
- this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) {
return;
}
Options& linkOptions = *(this->LinkOptions[config]);
@@ -2410,10 +2414,11 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(
}
void cmVisualStudio10TargetGenerator::AddLibraries(
- cmComputeLinkInformation& cli, std::vector<std::string>& libVec)
+ cmComputeLinkInformation& cli, std::vector<std::string>& libVec,
+ std::vector<std::string>& vsTargetVec)
{
typedef cmComputeLinkInformation::ItemVector ItemVector;
- ItemVector libs = cli.GetItems();
+ ItemVector const& libs = cli.GetItems();
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
@@ -2421,14 +2426,38 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
std::string path = this->LocalGenerator->ConvertToRelativePath(
currentBinDir, l->Value.c_str());
this->ConvertToWindowsSlash(path);
- libVec.push_back(path);
+ if (cmVS10IsTargetsFile(l->Value)) {
+ vsTargetVec.push_back(path);
+ } else {
+ libVec.push_back(path);
+ }
} else if (!l->Target ||
- l->Target->GetType() != cmState::INTERFACE_LIBRARY) {
+ l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
libVec.push_back(l->Value);
}
}
}
+void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
+ std::string const& targetsFile, std::string const& config)
+{
+ for (std::vector<TargetsFileAndConfigs>::iterator i =
+ this->TargetsFileAndConfigsVec.begin();
+ i != this->TargetsFileAndConfigsVec.end(); ++i) {
+ if (cmSystemTools::ComparePath(targetsFile, i->File)) {
+ if (std::find(i->Configs.begin(), i->Configs.end(), config) ==
+ i->Configs.end()) {
+ i->Configs.push_back(config);
+ }
+ return;
+ }
+ }
+ TargetsFileAndConfigs entry;
+ entry.File = targetsFile;
+ entry.Configs.push_back(config);
+ this->TargetsFileAndConfigsVec.push_back(entry);
+}
+
void cmVisualStudio10TargetGenerator::WriteMidlOptions(
std::string const& /*config*/, std::vector<std::string> const& includes)
{
@@ -2487,7 +2516,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
*this->BuildFileStream << "\n";
// output cl compile flags <ClCompile></ClCompile>
- if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
+ if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
this->WriteClOptions(*i, includes);
// output rc compile flags <ResourceCompile></ResourceCompile>
this->WriteRCOptions(*i, includes);
@@ -2504,7 +2533,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
// output manifest flags <Manifest></Manifest>
this->WriteManifestOptions(*i);
if (this->NsightTegra &&
- this->GeneratorTarget->GetType() == cmState::EXECUTABLE &&
+ this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE &&
this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
this->WriteAntBuildOptions(*i);
}
@@ -2516,7 +2545,7 @@ void cmVisualStudio10TargetGenerator::WriteEvents(
std::string const& configName)
{
bool addedPrelink = false;
- if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+ if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GeneratorTarget->IsExecutableWithExports()) &&
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
if (this->GeneratorTarget->GetPropertyAsBool(
@@ -2583,7 +2612,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
for (OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i) {
cmGeneratorTarget const* dt = *i;
- if (dt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// skip fortran targets as they can not be processed by MSBuild
@@ -2719,7 +2748,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
{
if ((this->GlobalGenerator->TargetsWindowsStore() ||
this->GlobalGenerator->TargetsWindowsPhone()) &&
- (cmState::EXECUTABLE == this->GeneratorTarget->GetType())) {
+ (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType())) {
std::string pfxFile;
std::vector<cmSourceFile const*> certificates;
this->GeneratorTarget->GetCertificates(certificates, "");
@@ -2844,7 +2873,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
"</MinimumVisualStudioVersion>\n",
2);
- if (this->GeneratorTarget->GetType() < cmState::UTILITY) {
+ if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
} else if (v == "8.1") {
@@ -2856,7 +2885,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
"</MinimumVisualStudioVersion>\n",
2);
- if (this->GeneratorTarget->GetType() < cmState::UTILITY) {
+ if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
} else if (v == "8.0") {
@@ -2869,10 +2898,11 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
2);
if (isWindowsStore &&
- this->GeneratorTarget->GetType() < cmState::UTILITY) {
+ this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
} else if (isWindowsPhone &&
- this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ this->GeneratorTarget->GetType() ==
+ cmStateEnums::EXECUTABLE) {
this->WriteString("<XapOutputs>true</XapOutputs>\n", 2);
this->WriteString("<XapFilename>", 2);
(*this->BuildFileStream)
@@ -2922,7 +2952,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
{
// For Windows and Windows Phone executables, we will assume that if a
// manifest is not present that we need to add all the necessary files
- if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
std::vector<cmSourceFile const*> manifestSources;
this->GeneratorTarget->GetAppManifest(manifestSources, "");
{