浏览代码

Makefiles: Drop 'requires' step and its supporting infrastructure

The 'requires' step was used to provide implicit dependencies between
the generated Fortran module files and a Fortran target that needs these
module files to ensure the correct compilation order.  After recent
refactoring to resolve all dependencies explicitly through `.mod.stamp`
make targets, the separate 'requires' step is not needed anymore.
Yurii Batrak 7 年之前
父节点
当前提交
7ab9a62572

+ 0 - 5
Modules/CMakeFortranInformation.cmake

@@ -67,11 +67,6 @@ if(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran)
   set(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran "${_override}")
 endif()
 
-
-# Fortran needs cmake to do a requires step during its build process to
-# catch any modules
-set(CMAKE_NEEDS_REQUIRES_STEP_Fortran_FLAG 1)
-
 if(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIC)
   set(CMAKE_Fortran_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC})
 endif()

+ 1 - 31
Source/cmDependsFortran.cxx

@@ -331,24 +331,6 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
       continue;
     }
 
-    // If the module is provided in this target special handling is
-    // needed.
-    if (this->Internal->TargetProvides.find(i) !=
-        this->Internal->TargetProvides.end()) {
-      // The module is provided by a different source in the same
-      // target.  Add the proxy dependency to make sure the other
-      // source builds first.
-      std::string proxy = stamp_dir;
-      proxy += "/";
-      proxy += i;
-      proxy += ".mod.proxy";
-      proxy = cmSystemTools::ConvertToOutputPath(
-        this->MaybeConvertToRelativePath(binDir, proxy).c_str());
-
-      // since we require some things add them to our list of requirements
-      makeDepends << obj_m << ".requires: " << proxy << std::endl;
-    }
-
     // The object file should depend on timestamped files for the
     // modules it uses.
     TargetRequiresMap::const_iterator required =
@@ -373,17 +355,6 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
     }
   }
 
-  // Write provided modules to the output stream.
-  for (std::string const& i : info.Provides) {
-    std::string proxy = stamp_dir;
-    proxy += "/";
-    proxy += i;
-    proxy += ".mod.proxy";
-    proxy = cmSystemTools::ConvertToOutputPath(
-      this->MaybeConvertToRelativePath(binDir, proxy).c_str());
-    makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
-  }
-
   // If any modules are provided then they must be converted to stamp files.
   if (!info.Provides.empty()) {
     // Create a target to copy the module after the object file
@@ -433,8 +404,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
       makeDepends << "\n";
     }
     makeDepends << obj_m << ".provides.build:\n";
-    // After copying the modules update the timestamp file so that
-    // copying will not be done again until the source rebuilds.
+    // After copying the modules update the timestamp file.
     makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
                 << ".provides.build\n";
 

+ 0 - 28
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -21,7 +21,6 @@
 #include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
-#include "cmTarget.h"
 #include "cmTargetDepend.h"
 #include "cmake.h"
 
@@ -630,8 +629,6 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
       makefileName = localName;
       makefileName += "/build.make";
 
-      bool needRequiresStep = this->NeedRequiresStep(gtarget);
-
       lg->WriteDivider(ruleFileStream);
       ruleFileStream << "# Target rules for target " << localName << "\n\n";
 
@@ -641,13 +638,6 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
       commands.push_back(
         lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
 
-      // add requires if we need it for this generator
-      if (needRequiresStep) {
-        makeTargetName = localName;
-        makeTargetName += "/requires";
-        commands.push_back(
-          lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
-      }
       makeTargetName = localName;
       makeTargetName += "/build";
       commands.push_back(
@@ -952,21 +942,3 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
                     commands, true);
   ruleFileStream << "\n\n";
 }
-
-bool cmGlobalUnixMakefileGenerator3::NeedRequiresStep(
-  const cmGeneratorTarget* target)
-{
-  std::set<std::string> languages;
-  target->GetLanguages(
-    languages,
-    target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-  for (std::string const& l : languages) {
-    std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
-    var += l;
-    var += "_FLAG";
-    if (target->Target->GetMakefile()->GetDefinition(var)) {
-      return true;
-    }
-  }
-  return false;
-}

+ 0 - 3
Source/cmGlobalUnixMakefileGenerator3.h

@@ -174,9 +174,6 @@ protected:
   void AppendGlobalTargetDepends(std::vector<std::string>& depends,
                                  cmGeneratorTarget* target);
 
-  // does this generator need a requires step for any of its targets
-  bool NeedRequiresStep(cmGeneratorTarget const*);
-
   // Target name hooks for superclass.
   const char* GetAllTargetName() const override { return "all"; }
   const char* GetInstallTargetName() const override { return "install"; }

+ 0 - 3
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -69,9 +69,6 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
     this->WriteExecutableRule(true);
   }
 
-  // Write the requires target.
-  this->WriteTargetRequiresRules();
-
   // Write clean target
   this->WriteTargetCleanRules();
 

+ 0 - 3
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -89,9 +89,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
       break;
   }
 
-  // Write the requires target.
-  this->WriteTargetRequiresRules();
-
   // Write clean target
   this->WriteTargetCleanRules();
 

+ 0 - 55
Source/cmMakefileTargetGenerator.cxx

@@ -818,61 +818,6 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
                                           commands, false);
     }
   }
-
-  // If the language needs provides-requires mode, create the
-  // corresponding targets.
-  std::string objectRequires = relativeObj;
-  objectRequires += ".requires";
-  std::vector<std::string> p_depends;
-  // always provide an empty requires target
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
-                                      objectRequires, p_depends, no_commands,
-                                      true);
-
-  // write a build rule to recursively build what this obj provides
-  std::string objectProvides = relativeObj;
-  objectProvides += ".provides";
-  std::string temp = relativeObj;
-  temp += ".provides.build";
-  std::vector<std::string> r_commands;
-
-  p_depends.clear();
-  p_depends.push_back(objectRequires);
-  p_depends.push_back(temp);
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
-                                      objectProvides, p_depends, r_commands,
-                                      true);
-
-  // write the provides.build rule dependency on the obj file
-  p_depends.clear();
-  p_depends.push_back(relativeObj);
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, temp,
-                                      p_depends, no_commands, false);
-}
-
-void cmMakefileTargetGenerator::WriteTargetRequiresRules()
-{
-  std::vector<std::string> depends;
-  std::vector<std::string> no_commands;
-
-  // Construct the name of the dependency generation target.
-  std::string depTarget =
-    this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
-  depTarget += "/requires";
-
-  // This target drives dependency generation for all object files.
-  std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
-  std::string objTarget;
-  for (std::string const& obj : this->Objects) {
-    objTarget = relPath;
-    objTarget += obj;
-    objTarget += ".requires";
-    depends.push_back(objTarget);
-  }
-
-  // Write the rule.
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
-                                      depTarget, depends, no_commands, true);
 }
 
 void cmMakefileTargetGenerator::WriteTargetCleanRules()

+ 0 - 3
Source/cmMakefileTargetGenerator.h

@@ -63,9 +63,6 @@ protected:
   void WriteCommonCodeRules();
   void WriteTargetLanguageFlags();
 
-  // write the provide require rules for this target
-  void WriteTargetRequiresRules();
-
   // write the clean rules for this target
   void WriteTargetCleanRules();