Commit f03d446e authored by Stephen Kelly's avatar Stephen Kelly
Browse files

cmLinkLineComputer: Move FrameworkPath computation from cmLocalGenerator

Add UseWatcomQuote state, and remove corresponding method parameters.
parent 3444105f
Pipeline #30049 passed with stage
......@@ -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()) {
......
......@@ -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;
}
......@@ -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);
......
......@@ -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);
......
......@@ -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,
......
......@@ -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.
......
......@@ -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
......
......@@ -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) {
......
......@@ -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,
......
......@@ -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())) {
......
......@@ -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);
......
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment