cmLocalGenerator: Add response file option to OutputLinkLibraries

Response files require different path conversion to be threaded
through construction of the link libraries flags.
This commit is contained in:
Brad King 2014-03-04 13:20:04 -05:00
parent b9aa504198
commit 5e8e4d0f88
3 changed files with 17 additions and 11 deletions

@ -1671,7 +1671,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
} }
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false); *target, false, false);
} }
break; break;
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
@ -1696,7 +1696,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false); *target, false, false);
if(cmSystemTools::IsOn if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{ {
@ -1793,8 +1793,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
std::string& frameworkPath, std::string& frameworkPath,
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget &tgt, cmGeneratorTarget &tgt,
bool relink) bool relink,
bool forResponseFile)
{ {
OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
bool escapeAllowMakeVars = !forResponseFile;
cmOStringStream fout; cmOStringStream fout;
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
@ -1837,7 +1840,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
fdi != fwDirs.end(); ++fdi) fdi != fwDirs.end(); ++fdi)
{ {
frameworkPath += fwSearchFlag; frameworkPath += fwSearchFlag;
frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false); frameworkPath += this->Convert(fdi->c_str(), NONE, shellFormat, false);
frameworkPath += " "; frameworkPath += " ";
} }
} }
@ -1847,7 +1850,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
for(std::vector<std::string>::const_iterator libDir = libDirs.begin(); for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
libDir != libDirs.end(); ++libDir) libDir != libDirs.end(); ++libDir)
{ {
std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); std::string libpath = this->ConvertToOutputForExisting(libDir->c_str(),
START_OUTPUT,
shellFormat);
linkPath += " " + libPathFlag; linkPath += " " + libPathFlag;
linkPath += libpath; linkPath += libpath;
linkPath += libPathTerminator; linkPath += libPathTerminator;
@ -1865,7 +1870,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
} }
if(li->IsPath) if(li->IsPath)
{ {
linkLibs += this->ConvertToLinkReference(li->Value); linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
} }
else else
{ {
@ -1890,7 +1895,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
ri != runtimeDirs.end(); ++ri) ri != runtimeDirs.end(); ++ri)
{ {
rpath += cli.GetRuntimeFlag(); rpath += cli.GetRuntimeFlag();
rpath += this->Convert(ri->c_str(), NONE, SHELL, false); rpath += this->Convert(ri->c_str(), NONE, shellFormat, false);
rpath += " "; rpath += " ";
} }
fout << rpath; fout << rpath;
@ -1904,7 +1909,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!rpath.empty()) if(!rpath.empty())
{ {
fout << cli.GetRuntimeFlag(); fout << cli.GetRuntimeFlag();
fout << this->EscapeForShell(rpath.c_str(), true); fout << this->EscapeForShell(rpath.c_str(), escapeAllowMakeVars);
fout << " "; fout << " ";
} }
} }
@ -1914,7 +1919,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
{ {
fout << cli.GetRPathLinkFlag(); fout << cli.GetRPathLinkFlag();
fout << this->EscapeForShell(rpath_link.c_str(), true); fout << this->EscapeForShell(rpath_link.c_str(), escapeAllowMakeVars);
fout << " "; fout << " ";
} }

@ -372,7 +372,8 @@ protected:
std::string& frameworkPath, std::string& frameworkPath,
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget &, cmGeneratorTarget &,
bool relink); bool relink,
bool forResponseFile);
// Expand rule variables in CMake of the type found in language rules // Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string, void ExpandRuleVariables(std::string& string,

@ -1840,7 +1840,7 @@ cmMakefileTargetGenerator
std::string linkPath; std::string linkPath;
this->LocalGenerator this->LocalGenerator
->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*this->GeneratorTarget, relink); *this->GeneratorTarget, relink, false);
linkLibs = frameworkPath + linkPath + linkLibs; linkLibs = frameworkPath + linkPath + linkLibs;
} }