summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmLinkLineComputer.cxx36
-rw-r--r--Source/cmLinkLineComputer.h4
-rw-r--r--Source/cmLocalGenerator.cxx33
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx4
-rw-r--r--Source/cmMakefileTargetGenerator.h2
8 files changed, 52 insertions, 36 deletions
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index a5e8b722b9..3675887d8e 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -12,6 +12,7 @@ cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter,
, OutputConverter(outputConverter)
, ForResponse(false)
, UseWatcomQuote(false)
+ , Relink(false)
{
}
@@ -29,6 +30,11 @@ void cmLinkLineComputer::SetForResponse(bool forResponse)
this->ForResponse = forResponse;
}
+void cmLinkLineComputer::SetRelink(bool relink)
+{
+ this->Relink = relink;
+}
+
std::string cmLinkLineComputer::ConvertToLinkReference(
std::string const& lib) const
{
@@ -100,3 +106,33 @@ std::string cmLinkLineComputer::ComputeLinkPath(
}
return linkPath;
}
+
+std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
+{
+ std::string rpath;
+ // Check what kind of rpath flags to use.
+ if (cli.GetRuntimeSep().empty()) {
+ // Each rpath entry gets its own option ("-R a -R b -R c")
+ std::vector<std::string> runtimeDirs;
+ cli.GetRPath(runtimeDirs, this->Relink);
+
+ for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
+ ri != runtimeDirs.end(); ++ri) {
+ rpath += cli.GetRuntimeFlag();
+ rpath += this->ConvertToOutputFormat(*ri);
+ rpath += " ";
+ }
+ } else {
+ // All rpath entries are combined ("-Wl,-rpath,a:b:c").
+ std::string rpathString = cli.GetRPathString(this->Relink);
+
+ // Store the rpath option in the stream.
+ if (!rpathString.empty()) {
+ rpath += cli.GetRuntimeFlag();
+ rpath +=
+ this->OutputConverter->EscapeForShell(rpathString, !this->ForResponse);
+ rpath += " ";
+ }
+ }
+ return rpath;
+}
diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h
index d38213fe97..d33e832965 100644
--- a/Source/cmLinkLineComputer.h
+++ b/Source/cmLinkLineComputer.h
@@ -18,6 +18,7 @@ public:
void SetUseWatcomQuote(bool useWatcomQuote);
void SetForResponse(bool forResponse);
+ void SetRelink(bool relink);
virtual std::string ConvertToLinkReference(std::string const& input) const;
@@ -27,6 +28,8 @@ public:
std::string const& libPathFlag,
std::string const& libPathTerminator);
+ std::string ComputeRPath(cmComputeLinkInformation& cli);
+
private:
std::string ConvertToOutputFormat(std::string const& input);
std::string ConvertToOutputForExisting(std::string const& input);
@@ -36,6 +39,7 @@ private:
bool ForResponse;
bool UseWatcomQuote;
+ bool Relink;
};
#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ab3d3b6922..63c8aef039 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1208,7 +1208,7 @@ void cmLocalGenerator::GetTargetFlags(
}
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
- frameworkPath, linkPath, false, false,
+ frameworkPath, linkPath, false,
useWatcomQuote);
}
} break;
@@ -1231,7 +1231,7 @@ void cmLocalGenerator::GetTargetFlags(
this->AddLanguageFlags(flags, linkLanguage, buildType);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
- frameworkPath, linkPath, false, false,
+ frameworkPath, linkPath, false,
useWatcomQuote);
}
if (cmSystemTools::IsOn(
@@ -1400,8 +1400,7 @@ std::string cmLocalGenerator::GetTargetFortranFlags(
void cmLocalGenerator::OutputLinkLibraries(
cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries, std::string& frameworkPath,
- std::string& linkPath, bool relink, bool forResponseFile,
- bool useWatcomQuote)
+ std::string& linkPath, bool forResponseFile, bool useWatcomQuote)
{
OutputFormat shellFormat =
(forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
@@ -1446,31 +1445,7 @@ void cmLocalGenerator::OutputLinkLibraries(
std::string linkLibs = linkLineComputer->ComputeLinkLibs(cli);
- std::string rpath;
-
- // Check what kind of rpath flags to use.
- if (cli.GetRuntimeSep().empty()) {
- // Each rpath entry gets its own option ("-R a -R b -R c")
- std::vector<std::string> runtimeDirs;
- cli.GetRPath(runtimeDirs, relink);
-
- for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
- ri != runtimeDirs.end(); ++ri) {
- rpath += cli.GetRuntimeFlag();
- rpath += this->ConvertToOutputFormat(*ri, shellFormat);
- rpath += " ";
- }
- } else {
- // All rpath entries are combined ("-Wl,-rpath,a:b:c").
- std::string rpathString = cli.GetRPathString(relink);
-
- // Store the rpath option in the stream.
- if (!rpathString.empty()) {
- rpath += cli.GetRuntimeFlag();
- rpath += this->EscapeForShell(rpathString, escapeAllowMakeVars);
- rpath += " ";
- }
- }
+ std::string rpath = linkLineComputer->ComputeRPath(cli);
std::ostringstream fout;
fout << rpath;
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 12b2b69945..75e01cbc1c 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -352,8 +352,7 @@ protected:
cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath,
- bool relink, bool forResponseFile,
- bool useWatcomQuote);
+ bool forResponseFile, bool useWatcomQuote);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index eaa50616f1..f17e012c76 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -310,10 +310,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetForResponse(useResponseFileForLibs);
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
+ linkLineComputer->SetRelink(relink);
// Collect up flags to link in needed libraries.
std::string linkLibs;
- this->CreateLinkLibs(linkLineComputer.get(), linkLibs, relink,
+ this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
useResponseFileForLibs, depends, useWatcomQuote);
// Construct object file lists that may be needed to expand the
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index ccc6d9f253..e0934b5391 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -511,8 +511,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetForResponse(useResponseFileForLibs);
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
+ linkLineComputer->SetRelink(relink);
- this->CreateLinkLibs(linkLineComputer.get(), linkLibs, relink,
+ this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
useResponseFileForLibs, depends, useWatcomQuote);
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index d9102a6816..2c0c91c4d2 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1601,7 +1601,7 @@ cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer(
}
void cmMakefileTargetGenerator::CreateLinkLibs(
- cmLinkLineComputer* linkLineComputer, std::string& linkLibs, bool relink,
+ cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
bool useResponseFile, std::vector<std::string>& makefile_depends,
bool useWatcomQuote)
{
@@ -1611,7 +1611,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
cmComputeLinkInformation* pcli =
this->GeneratorTarget->GetLinkInformation(config);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
- frameworkPath, linkPath, relink,
+ frameworkPath, linkPath,
useResponseFile, useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs;
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 0930d896de..846b310467 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -154,7 +154,7 @@ protected:
/** Create list of flags for link libraries. */
void CreateLinkLibs(cmLinkLineComputer* linkLineComputer,
- std::string& linkLibs, bool relink, bool useResponseFile,
+ std::string& linkLibs, bool useResponseFile,
std::vector<std::string>& makefile_depends,
bool useWatcomQuote);