Browse Source

cmLocalGenerator: Pass link library info to OutputLinkLibraries

Remove the cmGeneratorTarget from the interface.

This is simplification of the OutputLinkLibraries responsibilities so
that it can be broken apart into multiple methods.
pull/275/head
Stephen Kelly 9 years ago
parent
commit
7ef8346825
  1. 30
      Source/cmLocalGenerator.cxx
  2. 8
      Source/cmLocalGenerator.h
  3. 9
      Source/cmMakefileTargetGenerator.cxx

30
Source/cmLocalGenerator.cxx

@ -1155,6 +1155,7 @@ void cmLocalGenerator::GetTargetFlags(
bool useWatcomQuote)
{
const std::string buildType = cmSystemTools::UpperCase(config);
cmComputeLinkInformation* pcli = target->GetLinkInformation(config);
const char* libraryLinkVariable =
"CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
@ -1205,9 +1206,11 @@ void cmLocalGenerator::GetTargetFlags(
linkFlags += " ";
}
}
this->OutputLinkLibraries(linkLineComputer, linkLibs, frameworkPath,
linkPath, *target, false, false,
useWatcomQuote);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath, false, false,
useWatcomQuote);
}
} break;
case cmState::EXECUTABLE: {
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
@ -1226,9 +1229,11 @@ void cmLocalGenerator::GetTargetFlags(
return;
}
this->AddLanguageFlags(flags, linkLanguage, buildType);
this->OutputLinkLibraries(linkLineComputer, linkLibs, frameworkPath,
linkPath, *target, false, false,
useWatcomQuote);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath, false, false,
useWatcomQuote);
}
if (cmSystemTools::IsOn(
this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") +
@ -1393,19 +1398,16 @@ std::string cmLocalGenerator::GetTargetFortranFlags(
* to the name of the library. This will not link a library against itself.
*/
void cmLocalGenerator::OutputLinkLibraries(
cmLinkLineComputer* linkLineComputer, std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget& tgt,
bool relink, bool forResponseFile, bool useWatcomQuote)
cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries, std::string& frameworkPath,
std::string& linkPath, bool relink, bool forResponseFile,
bool useWatcomQuote)
{
OutputFormat shellFormat =
(forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
bool escapeAllowMakeVars = !forResponseFile;
std::ostringstream fout;
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config);
if (!pcli) {
return;
}
cmComputeLinkInformation& cli = *pcli;
std::string linkLanguage = cli.GetLinkLanguage();

8
Source/cmLocalGenerator.h

@ -19,6 +19,7 @@
#include <string>
#include <vector>
class cmComputeLinkInformation;
class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGenerator;
@ -347,11 +348,12 @@ public:
protected:
///! put all the libraries for a target on into the given stream
void OutputLinkLibraries(cmLinkLineComputer* linkLineComputer,
void OutputLinkLibraries(cmComputeLinkInformation* pcli,
cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath,
cmGeneratorTarget&, bool relink,
bool forResponseFile, bool useWatcomQuote);
bool relink, bool forResponseFile,
bool useWatcomQuote);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,

9
Source/cmMakefileTargetGenerator.cxx

@ -1605,9 +1605,12 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
{
std::string frameworkPath;
std::string linkPath;
this->LocalGenerator->OutputLinkLibraries(
linkLineComputer, linkLibs, frameworkPath, linkPath,
*this->GeneratorTarget, relink, useResponseFile, useWatcomQuote);
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli =
this->GeneratorTarget->GetLinkInformation(config);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath, relink,
useResponseFile, useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs;
if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) {

Loading…
Cancel
Save