summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx115
1 files changed, 44 insertions, 71 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 14102ef..84ae726 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -10,6 +10,7 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmLinkLineComputer.h"
#include "cmLocalGenerator.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
@@ -1207,9 +1208,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
i != this->ExternalObjects.end(); ++i) {
object =
this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *i);
- *this->BuildFileStream << " " << lineContinue << "\n"
- << this->Makefile->GetSafeDefinition(
- "CMAKE_OBJECT_NAME");
+ *this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
i->c_str(), useWatcomQuote);
}
@@ -1217,21 +1216,16 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
<< "\n";
}
-void cmMakefileTargetGenerator::WriteObjectsString(std::string& buildObjs)
-{
- std::vector<std::string> objStrings;
- this->WriteObjectsStrings(objStrings);
- buildObjs = objStrings[0];
-}
-
class cmMakefileTargetGeneratorObjectStrings
{
public:
cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings,
- cmLocalUnixMakefileGenerator3* lg,
+ cmOutputConverter* outputConverter,
+ cmState::Directory stateDir,
std::string::size_type limit)
: Strings(strings)
- , LocalGenerator(lg)
+ , OutputConverter(outputConverter)
+ , StateDir(stateDir)
, LengthLimit(limit)
{
this->Space = "";
@@ -1239,10 +1233,8 @@ public:
void Feed(std::string const& obj)
{
// Construct the name of the next object.
- this->NextObject = this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), obj),
- cmOutputConverter::RESPONSE);
+ this->NextObject = this->OutputConverter->ConvertToOutputFormat(
+ this->MaybeConvertToRelativePath(obj), cmOutputConverter::RESPONSE);
// Roll over to next string if the limit will be exceeded.
if (this->LengthLimit != std::string::npos &&
@@ -1262,8 +1254,19 @@ public:
}
void Done() { this->Strings.push_back(this->CurrentString); }
private:
+ std::string MaybeConvertToRelativePath(std::string const& obj)
+ {
+ if (!cmOutputConverter::ContainedInDirectory(
+ this->StateDir.GetCurrentBinary(), obj, this->StateDir)) {
+ return obj;
+ }
+ return cmOutputConverter::ForceToRelativePath(
+ this->StateDir.GetCurrentBinary(), obj);
+ }
+
std::vector<std::string>& Strings;
- cmLocalUnixMakefileGenerator3* LocalGenerator;
+ cmOutputConverter* OutputConverter;
+ cmState::Directory StateDir;
std::string::size_type LengthLimit;
std::string CurrentString;
std::string NextObject;
@@ -1273,8 +1276,9 @@ private:
void cmMakefileTargetGenerator::WriteObjectsStrings(
std::vector<std::string>& objStrings, std::string::size_type limit)
{
- cmMakefileTargetGeneratorObjectStrings helper(objStrings,
- this->LocalGenerator, limit);
+ cmMakefileTargetGeneratorObjectStrings helper(
+ objStrings, this->LocalGenerator,
+ this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit);
for (std::vector<std::string>::const_iterator i = this->Objects.begin();
i != this->Objects.end(); ++i) {
helper.Feed(*i);
@@ -1416,52 +1420,6 @@ void cmMakefileTargetGenerator::CloseFileStreams()
delete this->FlagFileStream;
}
-void cmMakefileTargetGenerator::RemoveForbiddenFlags(
- const char* flagVar, const std::string& linkLang, std::string& linkFlags)
-{
- // check for language flags that are not allowed at link time, and
- // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
- // which fails, there may be more]
-
- std::string removeFlags = "CMAKE_";
- removeFlags += linkLang;
- removeFlags += flagVar;
- std::string removeflags = this->Makefile->GetSafeDefinition(removeFlags);
- std::vector<std::string> removeList;
- cmSystemTools::ExpandListArgument(removeflags, removeList);
-
- for (std::vector<std::string>::iterator i = removeList.begin();
- i != removeList.end(); ++i) {
- std::string tmp;
- std::string::size_type lastPosition = 0;
-
- for (;;) {
- std::string::size_type position = linkFlags.find(*i, lastPosition);
-
- if (position == std::string::npos) {
- tmp += linkFlags.substr(lastPosition);
- break;
- } else {
- std::string::size_type prefixLength = position - lastPosition;
- tmp += linkFlags.substr(lastPosition, prefixLength);
- lastPosition = position + i->length();
-
- bool validFlagStart =
- position == 0 || isspace(linkFlags[position - 1]);
-
- bool validFlagEnd =
- lastPosition == linkFlags.size() || isspace(linkFlags[lastPosition]);
-
- if (!validFlagStart || !validFlagEnd) {
- tmp += *i;
- }
- }
- }
-
- linkFlags = tmp;
- }
-}
-
void cmMakefileTargetGenerator::CreateLinkScript(
const char* name, std::vector<std::string> const& link_commands,
std::vector<std::string>& makefile_commands,
@@ -1583,15 +1541,28 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
return responseFileName;
}
+cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer(
+ cmOutputConverter* outputConverter, cmState::Directory stateDir)
+{
+ if (this->Makefile->IsOn("MSVC60")) {
+ return this->GlobalGenerator->CreateMSVC60LinkLineComputer(outputConverter,
+ stateDir);
+ }
+ return this->GlobalGenerator->CreateLinkLineComputer(outputConverter,
+ stateDir);
+}
+
void cmMakefileTargetGenerator::CreateLinkLibs(
- std::string& linkLibs, bool relink, bool useResponseFile,
- std::vector<std::string>& makefile_depends, bool useWatcomQuote)
+ cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
+ bool useResponseFile, std::vector<std::string>& makefile_depends)
{
std::string frameworkPath;
std::string linkPath;
- this->LocalGenerator->OutputLinkLibraries(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);
linkLibs = frameworkPath + linkPath + linkLibs;
if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) {
@@ -1665,7 +1636,9 @@ void cmMakefileTargetGenerator::CreateObjectLists(
}
} else if (useLinkScript) {
if (!useArchiveRules) {
- this->WriteObjectsString(buildObjs);
+ std::vector<std::string> objStrings;
+ this->WriteObjectsStrings(objStrings);
+ buildObjs = objStrings[0];
}
} else {
buildObjs = "$(";