diff options
author | Stephen Kelly <steveire@gmail.com> | 2016-10-08 10:21:38 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2016-10-10 18:38:59 (GMT) |
commit | 77c4202edc242c96087295585a85a20700bdb26f (patch) | |
tree | fd0c780e1e758ed43e5b2958cd467cca9ad78c7a /Source | |
parent | 09b6cc66b09b9689ca01faee5e33ef101b46f972 (diff) | |
download | CMake-77c4202edc242c96087295585a85a20700bdb26f.zip CMake-77c4202edc242c96087295585a85a20700bdb26f.tar.gz CMake-77c4202edc242c96087295585a85a20700bdb26f.tar.bz2 |
cmLinkLineComputer: Move RPath computation from cmLocalGenerator
Add state for Relink and populate it at the point of cmLinkLineComputer
initialization. This allows removal of the parameter in go-between
methods.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLinkLineComputer.cxx | 36 | ||||
-rw-r--r-- | Source/cmLinkLineComputer.h | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 33 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 2 |
8 files changed, 52 insertions, 36 deletions
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index a5e8b72..3675887 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 d38213f..d33e832 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 ab3d3b6..63c8aef 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 12b2b69..75e01cb 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 eaa5061..f17e012 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 ccc6d9f..e0934b5 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 d9102a6..2c0c91c 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 0930d89..846b310 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); |