Browse Source

Refactoring: Abstract Makefile line continuation format

Marc Chevrier 5 years ago
parent
commit
afd0f6785d

+ 1 - 0
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -44,6 +44,7 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
 #endif
 
   this->IncludeDirective = "include";
+  this->LineContinueDirective = "\\\n";
   this->DefineWindowsNULL = false;
   this->PassMakeflags = false;
   this->UnixCD = true;

+ 1 - 0
Source/cmGlobalUnixMakefileGenerator3.h

@@ -170,6 +170,7 @@ public:
   void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
 
   std::string IncludeDirective;
+  std::string LineContinueDirective;
   bool DefineWindowsNULL;
   bool PassMakeflags;
   bool UnixCD;

+ 1 - 1
Source/cmGlobalWatcomWMakeGenerator.cxx

@@ -25,6 +25,7 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm)
 #endif
   cm->GetState()->SetWatcomWMake(true);
   this->IncludeDirective = "!include";
+  this->LineContinueDirective = "&\n";
   this->DefineWindowsNULL = true;
   this->UnixCD = false;
   this->MakeSilentFlag = "-h";
@@ -37,7 +38,6 @@ void cmGlobalWatcomWMakeGenerator::EnableLanguage(
   mf->AddDefinition("WATCOM", "1");
   mf->AddDefinition("CMAKE_QUOTE_INCLUDE_PATHS", "1");
   mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1");
-  mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&");
   mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC");
   mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386");
   mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386");

+ 3 - 8
Source/cmMakefileTargetGenerator.cxx

@@ -1544,12 +1544,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
                          << this->GeneratorTarget->GetName() << "\n"
                          << variableName << " =";
   std::string object;
-  std::string lineContinue;
-  if (cmProp p = this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE")) {
-    lineContinue = *p;
-  } else {
-    lineContinue = "\\";
-  }
+  const auto& lineContinue = this->GlobalGenerator->LineContinueDirective;
 
   cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
 
@@ -1557,7 +1552,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
     if (cmSystemTools::StringEndsWith(obj, cmToCStr(pchExtension))) {
       continue;
     }
-    *this->BuildFileStream << " " << lineContinue << "\n";
+    *this->BuildFileStream << " " << lineContinue;
     *this->BuildFileStream
       << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
            obj, useWatcomQuote);
@@ -1580,7 +1575,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
   for (std::string const& obj : this->ExternalObjects) {
     object =
       this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, obj);
-    *this->BuildFileStream << " " << lineContinue << "\n";
+    *this->BuildFileStream << " " << lineContinue;
     *this->BuildFileStream
       << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
            obj, useWatcomQuote);