summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileLibraryTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefileLibraryTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx144
1 files changed, 76 insertions, 68 deletions
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d6a0cd4..80473f6 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -131,17 +131,14 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_STATIC_LIBRARY";
if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
- this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str()))
+ this->Makefile->GetDefinition(linkRuleVar+"_IPO"))
{
linkRuleVar += "_IPO";
}
@@ -149,7 +146,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
std::string extraFlags;
this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
cmSystemTools::UpperCase(this->ConfigName), this->Target);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, false);
}
//----------------------------------------------------------------------------
@@ -160,13 +157,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->WriteFrameworkRules(relink);
return;
}
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_SHARED_LIBRARY";
std::string extraFlags;
@@ -175,25 +169,22 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
this->AddModuleDefinitionFlag(extraFlags);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_SHARED_MODULE";
std::string extraFlags;
@@ -202,24 +193,21 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
this->AddModuleDefinitionFlag(extraFlags);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
std::string extraFlags;
@@ -228,16 +216,16 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteLibraryRules
-(const char* linkRuleVar, const char* extraFlags, bool relink)
+(const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
{
// TODO: Merge the methods that call this method to avoid
// code duplication.
@@ -248,14 +236,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->AppendLinkDepends(depends);
// Get the language to use for linking this library.
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
// Make sure we have a link language.
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error("Cannot determine link language for target \"",
- this->Target->GetName(), "\".");
+ this->Target->GetName().c_str(), "\".");
return;
}
@@ -321,7 +309,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
}
- std::string pdbOutputPath = this->Target->GetPDBDirectory();
+ std::string compilePdbOutputPath =
+ this->Target->GetCompilePDBDirectory(this->ConfigName);
+ cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+ std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
pdbOutputPath += "/";
@@ -334,19 +326,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Construct the output path version of the names for use in command
// arguments.
std::string targetOutPathPDB =
- this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+ this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
std::string targetOutPath =
- this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathSO =
- this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathReal =
- this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathImport =
- this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
if(!this->NoRuleMessages)
@@ -390,31 +382,31 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Clean files associated with this library.
std::vector<std::string> libCleanFiles;
- libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPath,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
if(targetNameReal != targetName)
{
- libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(targetNameSO != targetName &&
targetNameSO != targetNameReal)
{
- libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathSO,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(!targetNameImport.empty())
{
- libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathImport,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
std::string implib;
if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
{
- libCleanFiles.push_back(this->Convert(implib.c_str(),
+ libCleanFiles.push_back(this->Convert(implib,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
@@ -424,7 +416,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back
- (this->Convert(targetFullPathPDB.c_str(),
+ (this->Convert(targetFullPathPDB,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
@@ -470,14 +462,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
// Select whether to use a response file for objects.
- bool useResponseFile = false;
+ bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
- if(this->Makefile->IsOn(responseVar.c_str()))
+ if(this->Makefile->IsOn(responseVar))
{
- useResponseFile = true;
+ useResponseFileForObjects = true;
+ }
+ }
+
+ // Select whether to use a response file for libraries.
+ bool useResponseFileForLibs = false;
+ {
+ std::string responseVar = "CMAKE_";
+ responseVar += linkLanguage;
+ responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+ if(this->Makefile->IsOn(responseVar))
+ {
+ useResponseFileForLibs = true;
}
}
@@ -494,21 +498,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string arCreateVar = "CMAKE_";
arCreateVar += linkLanguage;
arCreateVar += "_ARCHIVE_CREATE";
- if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arCreateVar))
{
cmSystemTools::ExpandListArgument(rule, archiveCreateCommands);
}
std::string arAppendVar = "CMAKE_";
arAppendVar += linkLanguage;
arAppendVar += "_ARCHIVE_APPEND";
- if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arAppendVar))
{
cmSystemTools::ExpandListArgument(rule, archiveAppendCommands);
}
std::string arFinishVar = "CMAKE_";
arFinishVar += linkLanguage;
arFinishVar += "_ARCHIVE_FINISH";
- if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arFinishVar))
{
cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
}
@@ -524,7 +528,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
useLinkScript = true;
// Archiving rules never use a response file.
- useResponseFile = false;
+ useResponseFileForObjects = false;
// Limit the length of individual object lists to less than the
// 32K command line length limit on Windows. We could make this a
@@ -535,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Expand the rule variables.
std::vector<std::string> real_link_commands;
{
+ bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
@@ -542,19 +548,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string linkLibs;
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{
- std::string frameworkPath;
- std::string linkPath;
- this->LocalGenerator
- ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *this->GeneratorTarget, relink);
- linkLibs = frameworkPath + linkPath + linkLibs;
+ this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+ useWatcomQuote);
}
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
- this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile,
- buildObjs, depends);
+ this->CreateObjectLists(useLinkScript, useArchiveRules,
+ useResponseFileForObjects, buildObjs, depends,
+ useWatcomQuote);
cmLocalGenerator::RuleVariables vars;
vars.TargetPDB = targetOutPathPDB.c_str();
@@ -578,14 +581,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->Target;
- vars.Language = linkLanguage;
+ vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str();
std::string objectDir = this->Target->GetSupportDirectory();
- objectDir = this->Convert(objectDir.c_str(),
+ objectDir = this->Convert(objectDir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
- vars.Target = targetOutPathReal.c_str();
+ cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+ cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+ std::string target = this->Convert(targetFullPathReal,
+ cmLocalGenerator::START_OUTPUT,
+ output);
+ vars.Target = target.c_str();
vars.LinkLibraries = linkLibs.c_str();
vars.ObjectsQuoted = buildObjs.c_str();
if (this->Target->HasSOName(this->ConfigName))
@@ -612,7 +620,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
// Convert to a path for the native build tool.
install_name_dir =
- this->LocalGenerator->Convert(install_name_dir.c_str(),
+ this->LocalGenerator->Convert(install_name_dir,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL, false);
vars.TargetInstallNameDir = install_name_dir.c_str();
@@ -746,7 +754,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- targetFullPathReal.c_str(),
+ targetFullPathReal,
depends, commands, false);
// Some targets have more than one output file. Create rules to
@@ -765,7 +773,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
// Write the main driver rule to build everything in this target.
- this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
+ this->WriteTargetDriverRule(targetFullPath, relink);
// Clean all the possible library names and symlinks.
this->CleanFiles.insert(this->CleanFiles.end(),
@@ -775,7 +783,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
//----------------------------------------------------------------------------
void
cmMakefileLibraryTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const char* lang,
+::AppendOSXVerFlag(std::string& flags, const std::string& lang,
const char* name, bool so)
{
// Lookup the flag to specify the version.
@@ -784,7 +792,7 @@ cmMakefileLibraryTargetGenerator
fvar += "_OSX_";
fvar += name;
fvar += "_VERSION_FLAG";
- const char* flag = this->Makefile->GetDefinition(fvar.c_str());
+ const char* flag = this->Makefile->GetDefinition(fvar);
// Skip if no such flag.
if(!flag)
@@ -802,6 +810,6 @@ cmMakefileLibraryTargetGenerator
// Append the flag since a non-zero version is specified.
cmOStringStream vflag;
vflag << flag << major << "." << minor << "." << patch;
- this->LocalGenerator->AppendFlags(flags, vflag.str().c_str());
+ this->LocalGenerator->AppendFlags(flags, vflag.str());
}
}