summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-12-15 15:42:01 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-12-15 15:42:12 (GMT)
commit6fb568cef6c8eebe1730c51bee7f4f92ce805c39 (patch)
tree16a512568aa8fcb776894d6b0e6dde479271f0e9
parent44111e5cc04ee689627acf5468d08e05c12b33aa (diff)
parent7ab9a62572058d6cd8e5bf130d7aa27d5a2e50f2 (diff)
downloadCMake-6fb568cef6c8eebe1730c51bee7f4f92ce805c39.zip
CMake-6fb568cef6c8eebe1730c51bee7f4f92ce805c39.tar.gz
CMake-6fb568cef6c8eebe1730c51bee7f4f92ce805c39.tar.bz2
Merge topic 'makefile-simplify-fortran'
7ab9a625 Makefiles: Drop 'requires' step and its supporting infrastructure 5f2e2c38 Makefiles: Avoid nested make calls for Fortran module dependencies Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1523
-rw-r--r--Modules/CMakeFortranInformation.cmake5
-rw-r--r--Source/cmDependsFortran.cxx56
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx28
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h3
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx59
-rw-r--r--Source/cmMakefileTargetGenerator.h3
9 files changed, 22 insertions, 140 deletions
diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake
index b315d33..d422578 100644
--- a/Modules/CMakeFortranInformation.cmake
+++ b/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()
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index fdbc086..23f622b 100644
--- a/Source/cmDependsFortran.cxx
+++ b/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,22 +355,10 @@ 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
// changes.
- makeDepends << obj_m << ".provides.build:\n";
for (std::string const& i : info.Provides) {
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(i);
@@ -407,11 +377,25 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
stampFile += "/";
stampFile += m;
stampFile += ".mod.stamp";
- stampFile = this->LocalGenerator->ConvertToOutputFormat(
- this->MaybeConvertToRelativePath(binDir, stampFile),
- cmOutputConverter::SHELL);
+ stampFile = this->MaybeConvertToRelativePath(binDir, stampFile);
+ std::string const stampFileForShell =
+ this->LocalGenerator->ConvertToOutputFormat(stampFile,
+ cmOutputConverter::SHELL);
+ std::string const stampFileForMake =
+ cmSystemTools::ConvertToOutputPath(stampFile.c_str());
+
+ makeDepends << obj_m << ".provides.build"
+ << ": " << stampFileForMake << "\n";
+ // Note that when cmake_copy_f90_mod finds that a module file
+ // and the corresponding stamp file have no differences, the stamp
+ // file is not updated. In such case the stamp file will be always
+ // older than its prerequisite and trigger cmake_copy_f90_mod
+ // on each new build. This is expected behavior for incremental
+ // builds and can not be changed without preforming recursive make
+ // calls that would considerably slow down the building process.
+ makeDepends << stampFileForMake << ": " << obj_m << "\n";
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
- << " " << stampFile;
+ << " " << stampFileForShell;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID");
if (cid && *cid) {
@@ -419,8 +403,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
}
makeDepends << "\n";
}
- // After copying the modules update the timestamp file so that
- // copying will not be done again until the source rebuilds.
+ makeDepends << obj_m << ".provides.build:\n";
+ // After copying the modules update the timestamp file.
makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
<< ".provides.build\n";
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index be40126..236bb3d 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/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;
-}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index d601f88..f9ce88c 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/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"; }
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index e26182a..a389ad0 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1444,6 +1444,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
}
#ifdef CMAKE_BUILD_WITH_CMAKE
else if (lang == "Fortran") {
+ ruleFileStream << "# Note that incremental build could trigger "
+ << "a call to cmake_copy_f90_mod on each re-build\n";
scanner = new cmDependsFortran(this);
} else if (lang == "Java") {
scanner = new cmDependsJava();
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 801f72a..90d8c7f 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -69,9 +69,6 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
this->WriteExecutableRule(true);
}
- // Write the requires target.
- this->WriteTargetRequiresRules();
-
// Write clean target
this->WriteTargetCleanRules();
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 80c62d1..ab15daf 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -89,9 +89,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
break;
}
- // Write the requires target.
- this->WriteTargetRequiresRules();
-
// Write clean target
this->WriteTargetCleanRules();
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 82506d2..850b8b2 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -824,65 +824,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;
- std::string tgtMakefileName =
- this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- tgtMakefileName += "/build.make";
- r_commands.push_back(
- this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), temp));
-
- p_depends.clear();
- p_depends.push_back(objectRequires);
- 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()
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 5ab7e36..7af3cf3 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/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();