STYLE: restructure OutputLinkLibraries() a bit, so that new there is a
function which returns the RPATH, so e.g. the install rpath can be queried when the command for the build rpath is created. This is a first step for supporting chrpath. Alex
This commit is contained in:
parent
bde7f6c023
commit
f2bb0af819
|
@ -1476,15 +1476,15 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool cmLocalGenerator::GetLinkerArgs(std::string& rpath,
|
||||||
* Output the linking rules on a command line. For executables,
|
std::string& linkLibs,
|
||||||
* targetLibrary should be a NULL pointer. For libraries, it should point
|
|
||||||
* to the name of the library. This will not link a library against itself.
|
|
||||||
*/
|
|
||||||
void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
|
||||||
cmTarget& tgt,
|
cmTarget& tgt,
|
||||||
bool relink)
|
bool relink)
|
||||||
{
|
{
|
||||||
|
rpath = "";
|
||||||
|
// collect all the flags needed for linking libraries
|
||||||
|
linkLibs = "";
|
||||||
|
|
||||||
// Try to emit each search path once
|
// Try to emit each search path once
|
||||||
std::set<cmStdString> emitted;
|
std::set<cmStdString> emitted;
|
||||||
// Embed runtime search paths if possible and if required.
|
// Embed runtime search paths if possible and if required.
|
||||||
|
@ -1500,7 +1500,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
cmSystemTools::
|
cmSystemTools::
|
||||||
Error("CMake can not determine linker language for target:",
|
Error("CMake can not determine linker language for target:",
|
||||||
tgt.GetName());
|
tgt.GetName());
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
std::string runTimeFlagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
std::string runTimeFlagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
||||||
runTimeFlagVar += linkLanguage;
|
runTimeFlagVar += linkLanguage;
|
||||||
|
@ -1535,8 +1535,6 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
|
this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
|
||||||
std::string libLinkFlag =
|
std::string libLinkFlag =
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
|
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
|
||||||
// collect all the flags needed for linking libraries
|
|
||||||
std::string linkLibs;
|
|
||||||
|
|
||||||
// Flags to link an executable to shared libraries.
|
// Flags to link an executable to shared libraries.
|
||||||
std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
|
std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
|
||||||
|
@ -1635,29 +1633,60 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
linkLibs += " ";
|
linkLibs += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
fout << linkLibs;
|
|
||||||
|
|
||||||
if(!runtimeDirs.empty())
|
if(!runtimeDirs.empty())
|
||||||
{
|
{
|
||||||
// For the runtime search directories, do a "-Wl,-rpath,a:b:c" or
|
// For the runtime search directories, do a "-Wl,-rpath,a:b:c" or
|
||||||
// a "-R a -R b -R c" type link line
|
// a "-R a -R b -R c" type link line
|
||||||
fout << runtimeFlag;
|
rpath += runtimeFlag;
|
||||||
std::vector<std::string>::iterator itr = runtimeDirs.begin();
|
std::vector<std::string>::iterator itr = runtimeDirs.begin();
|
||||||
fout << *itr;
|
rpath += *itr;
|
||||||
++itr;
|
++itr;
|
||||||
for( ; itr != runtimeDirs.end(); ++itr )
|
for( ; itr != runtimeDirs.end(); ++itr )
|
||||||
{
|
{
|
||||||
if(runtimeConcatenate)
|
if(runtimeConcatenate)
|
||||||
{
|
{
|
||||||
fout << runtimeSep << *itr;
|
rpath += runtimeSep;
|
||||||
|
rpath += *itr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fout << " " << runtimeFlag << *itr;
|
rpath += " ";
|
||||||
|
rpath += runtimeFlag;
|
||||||
|
rpath += *itr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fout << " ";
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the linking rules on a command line. For executables,
|
||||||
|
* targetLibrary should be a NULL pointer. For libraries, it should point
|
||||||
|
* to the name of the library. This will not link a library against itself.
|
||||||
|
*/
|
||||||
|
void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||||
|
cmTarget& tgt,
|
||||||
|
bool relink)
|
||||||
|
{
|
||||||
|
std::string rpath;
|
||||||
|
std::string linkLibs;
|
||||||
|
if (!this->GetLinkerArgs(rpath, linkLibs, tgt, relink))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* linkLanguage =
|
||||||
|
tgt.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||||
|
if(!linkLanguage)
|
||||||
|
{
|
||||||
|
cmSystemTools::
|
||||||
|
Error("CMake can not determine linker language for target:",
|
||||||
|
tgt.GetName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fout << linkLibs;
|
||||||
|
fout << rpath << " ";
|
||||||
|
|
||||||
// Add standard libraries for this language.
|
// Add standard libraries for this language.
|
||||||
std::string standardLibsVar = "CMAKE_";
|
std::string standardLibsVar = "CMAKE_";
|
||||||
|
|
|
@ -258,6 +258,10 @@ protected:
|
||||||
///! put all the libraries for a target on into the given stream
|
///! put all the libraries for a target on into the given stream
|
||||||
virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink);
|
virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink);
|
||||||
|
|
||||||
|
///! Determine the arguments for the linker call
|
||||||
|
bool GetLinkerArgs(std::string& rpath, std::string& linkLibs,
|
||||||
|
cmTarget& tgt, bool relink);
|
||||||
|
|
||||||
// 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,
|
||||||
const RuleVariables& replaceValues);
|
const RuleVariables& replaceValues);
|
||||||
|
|
Loading…
Reference in New Issue