cmLinkLineComputer: Move FrameworkPath computation from cmLocalGenerator

Add UseWatcomQuote state, and remove corresponding method parameters.
This commit is contained in:
Stephen Kelly 2016-10-08 12:21:39 +02:00
parent 3444105f9f
commit f03d446e96
12 changed files with 39 additions and 34 deletions

View File

@ -367,10 +367,11 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
this->GetGlobalGenerator()->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
this->LocalGenerator->GetTargetFlags(
linkLineComputer.get(), config, linkLibraries, flags, linkFlags,
frameworkPath, linkPath, this->GeneratorTarget, useWatcomQuote);
frameworkPath, linkPath, this->GeneratorTarget);
linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
if (!linkPath.empty()) {

View File

@ -136,3 +136,19 @@ std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
}
return rpath;
}
std::string cmLinkLineComputer::ComputeFrameworkPath(
cmComputeLinkInformation& cli, std::string const& fwSearchFlag)
{
std::string frameworkPath;
if (!fwSearchFlag.empty()) {
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
fdi != fwDirs.end(); ++fdi) {
frameworkPath += fwSearchFlag;
frameworkPath += this->ConvertToOutputFormat(*fdi);
frameworkPath += " ";
}
}
return frameworkPath;
}

View File

@ -30,6 +30,9 @@ public:
std::string ComputeRPath(cmComputeLinkInformation& cli);
std::string ComputeFrameworkPath(cmComputeLinkInformation& cli,
std::string const& fwSearchFlag);
private:
std::string ConvertToOutputFormat(std::string const& input);
std::string ConvertToOutputForExisting(std::string const& input);

View File

@ -1151,8 +1151,7 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
void cmLocalGenerator::GetTargetFlags(
cmLinkLineComputer* linkLineComputer, const std::string& config,
std::string& linkLibs, std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target,
bool useWatcomQuote)
std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target)
{
const std::string buildType = cmSystemTools::UpperCase(config);
cmComputeLinkInformation* pcli = target->GetLinkInformation(config);
@ -1208,8 +1207,7 @@ void cmLocalGenerator::GetTargetFlags(
}
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath, false,
useWatcomQuote);
frameworkPath, linkPath, false);
}
} break;
case cmState::EXECUTABLE: {
@ -1231,8 +1229,7 @@ void cmLocalGenerator::GetTargetFlags(
this->AddLanguageFlags(flags, linkLanguage, buildType);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath, false,
useWatcomQuote);
frameworkPath, linkPath, false);
}
if (cmSystemTools::IsOn(
this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
@ -1400,10 +1397,8 @@ std::string cmLocalGenerator::GetTargetFortranFlags(
void cmLocalGenerator::OutputLinkLibraries(
cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries, std::string& frameworkPath,
std::string& linkPath, bool forResponseFile, bool useWatcomQuote)
std::string& linkPath, bool forResponseFile)
{
OutputFormat shellFormat =
(forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
cmComputeLinkInformation& cli = *pcli;
std::string linkLanguage = cli.GetLinkLanguage();
@ -1428,16 +1423,8 @@ void cmLocalGenerator::OutputLinkLibraries(
fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
std::string fwSearchFlag =
this->Makefile->GetSafeDefinition(fwSearchFlagVar);
if (!fwSearchFlag.empty()) {
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
fdi != fwDirs.end(); ++fdi) {
frameworkPath += fwSearchFlag;
frameworkPath += this->ConvertToOutputFormat(*fdi, shellFormat);
frameworkPath += " ";
}
}
frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag);
linkPath =
linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator);

View File

@ -318,7 +318,7 @@ public:
const std::string& config, std::string& linkLibs,
std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath,
cmGeneratorTarget* target, bool useWatcomQuote);
cmGeneratorTarget* target);
void GetTargetDefines(cmGeneratorTarget const* target,
std::string const& config, std::string const& lang,
std::set<std::string>& defines) const;
@ -352,7 +352,7 @@ protected:
cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath,
bool forResponseFile, bool useWatcomQuote);
bool forResponseFile);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,

View File

@ -315,7 +315,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Collect up flags to link in needed libraries.
std::string linkLibs;
this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
useResponseFileForLibs, depends, useWatcomQuote);
useResponseFileForLibs, depends);
// Construct object file lists that may be needed to expand the
// rule.

View File

@ -514,7 +514,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
linkLineComputer->SetRelink(relink);
this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
useResponseFileForLibs, depends, useWatcomQuote);
useResponseFileForLibs, depends);
}
// Construct object file lists that may be needed to expand the

View File

@ -1602,8 +1602,7 @@ cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer(
void cmMakefileTargetGenerator::CreateLinkLibs(
cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
bool useResponseFile, std::vector<std::string>& makefile_depends,
bool useWatcomQuote)
bool useResponseFile, std::vector<std::string>& makefile_depends)
{
std::string frameworkPath;
std::string linkPath;
@ -1612,7 +1611,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
this->GeneratorTarget->GetLinkInformation(config);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath,
useResponseFile, useWatcomQuote);
useResponseFile);
linkLibs = frameworkPath + linkPath + linkLibs;
if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) {

View File

@ -155,8 +155,7 @@ protected:
/** Create list of flags for link libraries. */
void CreateLinkLibs(cmLinkLineComputer* linkLineComputer,
std::string& linkLibs, bool useResponseFile,
std::vector<std::string>& makefile_depends,
bool useWatcomQuote);
std::vector<std::string>& makefile_depends);
/** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,

View File

@ -475,11 +475,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetGlobalGenerator()->CreateLinkLineComputer(
this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
localGen.GetTargetFlags(linkLineComputer.get(), this->GetConfigName(),
vars["LINK_LIBRARIES"], vars["FLAGS"],
vars["LINK_FLAGS"], frameworkPath, linkPath,
&genTarget, useWatcomQuote);
localGen.GetTargetFlags(
linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"],
vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget);
if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") &&
(gt.GetType() == cmState::SHARED_LIBRARY ||
gt.IsExecutableWithExports())) {

View File

@ -732,7 +732,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
cmLinkLineComputer linkLineComputer(lg,
lg->GetStateSnapshot().GetDirectory());
lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags,
linkFlags, frameworkPath, linkPath, target, false);
linkFlags, frameworkPath, linkPath, target);
linkLibs = cmSystemTools::TrimWhitespace(linkLibs);
linkFlags = cmSystemTools::TrimWhitespace(linkFlags);

View File

@ -586,7 +586,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmLinkLineComputer linkLineComputer(lg,
lg->GetStateSnapshot().GetDirectory());
lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags,
linkFlags, frameworkPath, linkPath, gtgt, false);
linkFlags, frameworkPath, linkPath, gtgt);
linkLibs = frameworkPath + linkPath + linkLibs;
printf("%s\n", linkLibs.c_str());