Ninja: move -LIBPATH behind -link option
Don' pass linker option to the compile
This commit is contained in:
parent
dbd99d6fbb
commit
8d674e7844
@ -676,9 +676,13 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
|
|||||||
// Static Library:
|
// Static Library:
|
||||||
// Shared Module:
|
// Shared Module:
|
||||||
std::string linkLibs; // should be set
|
std::string linkLibs; // should be set
|
||||||
|
std::string frameworkPath;
|
||||||
|
std::string linkPath;
|
||||||
std::string flags; // should be set
|
std::string flags; // should be set
|
||||||
std::string linkFlags; // should be set
|
std::string linkFlags; // should be set
|
||||||
this->GetTargetFlags(linkLibs, flags, linkFlags, &target);
|
this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
|
||||||
|
&target);
|
||||||
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
||||||
cmLocalGenerator::RuleVariables vars;
|
cmLocalGenerator::RuleVariables vars;
|
||||||
vars.Language = llang;
|
vars.Language = llang;
|
||||||
vars.Objects = objs.c_str();
|
vars.Objects = objs.c_str();
|
||||||
@ -1450,6 +1454,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
|||||||
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
||||||
std::string& flags,
|
std::string& flags,
|
||||||
std::string& linkFlags,
|
std::string& linkFlags,
|
||||||
|
std::string& frameworkPath,
|
||||||
|
std::string& linkPath,
|
||||||
cmGeneratorTarget* target)
|
cmGeneratorTarget* target)
|
||||||
{
|
{
|
||||||
std::string buildType =
|
std::string buildType =
|
||||||
@ -1531,9 +1537,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||||||
linkFlags += " ";
|
linkFlags += " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmOStringStream linklibsStr;
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
||||||
this->OutputLinkLibraries(linklibsStr, *target, false);
|
*target, false);
|
||||||
linkLibs = linklibsStr.str();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cmTarget::EXECUTABLE:
|
case cmTarget::EXECUTABLE:
|
||||||
@ -1557,9 +1562,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
|
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
|
||||||
cmOStringStream linklibs;
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
||||||
this->OutputLinkLibraries(linklibs, *target, false);
|
*target, false);
|
||||||
linkLibs = linklibs.str();
|
|
||||||
if(cmSystemTools::IsOn
|
if(cmSystemTools::IsOn
|
||||||
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
|
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
|
||||||
{
|
{
|
||||||
@ -1651,10 +1655,13 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
|
|||||||
* targetLibrary should be a NULL pointer. For libraries, it should point
|
* 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.
|
* to the name of the library. This will not link a library against itself.
|
||||||
*/
|
*/
|
||||||
void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
||||||
cmGeneratorTarget& tgt,
|
std::string& frameworkPath,
|
||||||
|
std::string& linkPath,
|
||||||
|
cmGeneratorTarget &tgt,
|
||||||
bool relink)
|
bool relink)
|
||||||
{
|
{
|
||||||
|
cmOStringStream fout;
|
||||||
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
||||||
cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config);
|
cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config);
|
||||||
if(!pcli)
|
if(!pcli)
|
||||||
@ -1688,9 +1695,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||||||
for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
|
for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
|
||||||
fdi != fwDirs.end(); ++fdi)
|
fdi != fwDirs.end(); ++fdi)
|
||||||
{
|
{
|
||||||
linkLibs += "-F";
|
frameworkPath = " -F";
|
||||||
linkLibs += this->Convert(fdi->c_str(), NONE, SHELL, false);
|
frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
|
||||||
linkLibs += " ";
|
frameworkPath += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the library search path flags.
|
// Append the library search path flags.
|
||||||
@ -1699,10 +1706,10 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||||||
libDir != libDirs.end(); ++libDir)
|
libDir != libDirs.end(); ++libDir)
|
||||||
{
|
{
|
||||||
std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
|
std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
|
||||||
linkLibs += libPathFlag;
|
linkPath += " " + libPathFlag;
|
||||||
linkLibs += libpath;
|
linkPath += libpath;
|
||||||
linkLibs += libPathTerminator;
|
linkPath += libPathTerminator;
|
||||||
linkLibs += " ";
|
linkPath += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the link items.
|
// Append the link items.
|
||||||
@ -1774,6 +1781,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||||||
{
|
{
|
||||||
fout << stdLibs << " ";
|
fout << stdLibs << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkLibraries = fout.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,11 +335,16 @@ public:
|
|||||||
void GetTargetFlags(std::string& linkLibs,
|
void GetTargetFlags(std::string& linkLibs,
|
||||||
std::string& flags,
|
std::string& flags,
|
||||||
std::string& linkFlags,
|
std::string& linkFlags,
|
||||||
|
std::string& frameworkPath,
|
||||||
|
std::string& linkPath,
|
||||||
cmGeneratorTarget* target);
|
cmGeneratorTarget* target);
|
||||||
|
|
||||||
protected:
|
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&, cmGeneratorTarget&,
|
virtual void OutputLinkLibraries(std::string& linkLibraries,
|
||||||
|
std::string& frameworkPath,
|
||||||
|
std::string& linkPath,
|
||||||
|
cmGeneratorTarget &,
|
||||||
bool relink);
|
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
|
||||||
|
@ -318,10 +318,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
||||||
|
|
||||||
// Collect up flags to link in needed libraries.
|
// Collect up flags to link in needed libraries.
|
||||||
cmOStringStream linklibs;
|
std::string linkLibs;
|
||||||
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->GeneratorTarget,
|
std::string frameworkPath;
|
||||||
|
std::string linkPath;
|
||||||
|
this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
||||||
|
*this->GeneratorTarget,
|
||||||
relink);
|
relink);
|
||||||
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
||||||
// Construct object file lists that may be needed to expand the
|
// Construct object file lists that may be needed to expand the
|
||||||
// rule.
|
// rule.
|
||||||
std::string buildObjs;
|
std::string buildObjs;
|
||||||
@ -360,8 +363,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
|||||||
vars.TargetVersionMajor = targetVersionMajor.c_str();
|
vars.TargetVersionMajor = targetVersionMajor.c_str();
|
||||||
vars.TargetVersionMinor = targetVersionMinor.c_str();
|
vars.TargetVersionMinor = targetVersionMinor.c_str();
|
||||||
|
|
||||||
std::string linkString = linklibs.str();
|
vars.LinkLibraries = linkLibs.c_str();
|
||||||
vars.LinkLibraries = linkString.c_str();
|
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
vars.LinkFlags = linkFlags.c_str();
|
vars.LinkFlags = linkFlags.c_str();
|
||||||
// Expand placeholders in the commands.
|
// Expand placeholders in the commands.
|
||||||
|
@ -542,11 +542,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
|
||||||
|
|
||||||
// Collect up flags to link in needed libraries.
|
// Collect up flags to link in needed libraries.
|
||||||
cmOStringStream linklibs;
|
std::string linkLibs;
|
||||||
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
||||||
{
|
{
|
||||||
|
std::string frameworkPath;
|
||||||
|
std::string linkPath;
|
||||||
this->LocalGenerator
|
this->LocalGenerator
|
||||||
->OutputLinkLibraries(linklibs, *this->GeneratorTarget, relink);
|
->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
||||||
|
*this->GeneratorTarget, relink);
|
||||||
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct object file lists that may be needed to expand the
|
// Construct object file lists that may be needed to expand the
|
||||||
@ -587,8 +591,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||||||
cmLocalGenerator::SHELL);
|
cmLocalGenerator::SHELL);
|
||||||
vars.ObjectDir = objdir.c_str();
|
vars.ObjectDir = objdir.c_str();
|
||||||
vars.Target = targetOutPathReal.c_str();
|
vars.Target = targetOutPathReal.c_str();
|
||||||
std::string linkString = linklibs.str();
|
vars.LinkLibraries = linkLibs.c_str();
|
||||||
vars.LinkLibraries = linkString.c_str();
|
|
||||||
vars.ObjectsQuoted = buildObjs.c_str();
|
vars.ObjectsQuoted = buildObjs.c_str();
|
||||||
if (this->Target->HasSOName(this->ConfigName))
|
if (this->Target->HasSOName(this->ConfigName))
|
||||||
{
|
{
|
||||||
|
@ -420,12 +420,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||||||
cmNinjaDeps explicitDeps = this->GetObjects();
|
cmNinjaDeps explicitDeps = this->GetObjects();
|
||||||
cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
|
cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
|
||||||
|
|
||||||
|
std::string frameworkPath;
|
||||||
|
std::string linkPath;
|
||||||
this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
|
this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
|
||||||
vars["FLAGS"],
|
vars["FLAGS"],
|
||||||
vars["LINK_FLAGS"],
|
vars["LINK_FLAGS"],
|
||||||
|
frameworkPath,
|
||||||
|
linkPath,
|
||||||
this->GetGeneratorTarget());
|
this->GetGeneratorTarget());
|
||||||
|
|
||||||
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
|
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
|
||||||
|
vars["LINK_FLAGS"] += frameworkPath + linkPath;
|
||||||
|
|
||||||
// Compute architecture specific link flags. Yes, these go into a different
|
// Compute architecture specific link flags. Yes, these go into a different
|
||||||
// variable for executables, probably due to a mistake made when duplicating
|
// variable for executables, probably due to a mistake made when duplicating
|
||||||
|
@ -628,10 +628,14 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
|
|
||||||
std::string linkLibs;
|
std::string linkLibs;
|
||||||
|
std::string frameworkPath;
|
||||||
|
std::string linkPath;
|
||||||
std::string flags;
|
std::string flags;
|
||||||
std::string linkFlags;
|
std::string linkFlags;
|
||||||
cmGeneratorTarget gtgt(tgt);
|
cmGeneratorTarget gtgt(tgt);
|
||||||
lg->GetTargetFlags(linkLibs, flags, linkFlags, >gt);
|
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
|
||||||
|
>gt);
|
||||||
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
||||||
|
|
||||||
printf("%s\n", linkLibs.c_str() );
|
printf("%s\n", linkLibs.c_str() );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user