[Cmake-commits] CMake branch, next, updated. v3.6.0-rc2-348-g6ba4954

Brad King brad.king at kitware.com
Thu Jun 16 11:56:08 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  6ba4954cb9787ea034f3f8d56003aad8130e4465 (commit)
       via  3d41797a9bbfede841844606eda168c5b18cd49d (commit)
       via  e1c8567cdc8bdaa8a205dde67f42eea1022d3a17 (commit)
       via  7fa9190d606b4f97d0929562f1f5854d7a3d8693 (commit)
       via  27fcb61ba413811df0649cbf4244081564ebc614 (commit)
       via  52572a26dfdfb7eaa0d28870e215bd00dcc1ec55 (commit)
      from  590681ade20a66d7ec2750c4acd510dcdad26e3e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ba4954cb9787ea034f3f8d56003aad8130e4465
commit 6ba4954cb9787ea034f3f8d56003aad8130e4465
Merge: 590681a 3d41797
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 16 11:56:07 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jun 16 11:56:07 2016 -0400

    Merge topic 'refactor-flags' into next
    
    3d41797a cmLocalCommonGenerator: Adopt target compile flag generation
    e1c8567c cmLocalCommonGenerator: Adopt language and feature flag generation
    7fa9190d cmLocalCommonGenerator: Adopt Fortran flag generation
    27fcb61b cmGeneratorTarget: Adopt Fortran module directory generation
    52572a26 Refactor Makefile/Ninja tool working directory storage


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3d41797a9bbfede841844606eda168c5b18cd49d
commit 3d41797a9bbfede841844606eda168c5b18cd49d
Author:     Tobias Hunger <tobias.hunger at qt.io>
AuthorDate: Fri Jun 10 18:04:58 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 16 11:53:27 2016 -0400

    cmLocalCommonGenerator: Adopt target compile flag generation
    
    Factor the flag generation out of cmCommonTargetGenerator::GetFlags
    into a new cmLocalCommonGenerator::GetTargetCompileFlags method.
    This will allow it to be used without a target generator available.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 402c49f..69fd363 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -109,37 +109,9 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
   ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
   if (i == this->FlagsByLanguage.end()) {
     std::string flags;
-    const char* lang = l.c_str();
 
-    // Add language feature flags.
-    this->LocalGenerator->AddFeatureFlags(flags, lang, this->GeneratorTarget);
-
-    this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
-                                               lang, this->ConfigName);
-
-    // Fortran-specific flags computed for this target.
-    if (l == "Fortran") {
-      this->LocalGenerator->AppendFlags(
-        flags, this->LocalGenerator->GetFortranFlags(this->GeneratorTarget));
-    }
-
-    this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
-                                          this->ConfigName);
-
-    this->LocalGenerator->AddVisibilityPresetFlags(
-      flags, this->GeneratorTarget, lang);
-
-    // Append old-style preprocessor definition flags.
-    this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
-
-    // Add framework directory flags.
-    this->LocalGenerator->AppendFlags(
-      flags, this->LocalGenerator->GetFrameworkFlags(l, this->ConfigName,
-                                                     this->GeneratorTarget));
-
-    // Add target-specific flags.
-    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
-                                            this->ConfigName);
+    this->LocalGenerator->GetTargetCompileFlags(this->GeneratorTarget, l,
+                                                flags);
 
     ByLanguageMap::value_type entry(l, flags);
     i = this->FlagsByLanguage.insert(entry).first;
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 2bfaea1..9086013 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -95,3 +95,23 @@ std::string cmLocalCommonGenerator::GetFortranFlags(
 
   return flags;
 }
+
+void cmLocalCommonGenerator::GetTargetCompileFlags(cmGeneratorTarget* target,
+                                                   std::string const& lang,
+                                                   std::string& flags)
+{
+  cmMakefile* mf = this->GetMakefile();
+
+  this->AddFeatureFlags(flags, lang, target);
+  this->AddArchitectureFlags(flags, target, lang, this->ConfigName);
+
+  if (lang == "Fortran") {
+    this->AppendFlags(flags, this->GetFortranFlags(target));
+  }
+
+  this->AddCMP0018Flags(flags, target, lang, this->ConfigName);
+  this->AddVisibilityPresetFlags(flags, target, lang);
+  this->AppendFlags(flags, mf->GetDefineFlags());
+  this->AppendFlags(flags, GetFrameworkFlags(lang, this->ConfigName, target));
+  this->AddCompileOptions(flags, target, lang, this->ConfigName);
+}
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index c89db17..5ca81f1 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -38,6 +38,9 @@ public:
 
   std::string GetFortranFlags(cmGeneratorTarget const* target);
 
+  void GetTargetCompileFlags(cmGeneratorTarget* target,
+                             std::string const& lang, std::string& flags);
+
 protected:
   cmOutputConverter::RelativeRoot WorkingDirectory;
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e1c8567cdc8bdaa8a205dde67f42eea1022d3a17
commit e1c8567cdc8bdaa8a205dde67f42eea1022d3a17
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 16 11:29:07 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 16 11:43:30 2016 -0400

    cmLocalCommonGenerator: Adopt language and feature flag generation
    
    Move the AddFeatureFlags method from cmCommonTargetGenerator so it can
    be used without having a target generator available.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 0f87d89..402c49f 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -56,17 +56,6 @@ bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature)
   return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName);
 }
 
-void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags,
-                                              const std::string& lang)
-{
-  // Add language-specific flags.
-  this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName);
-
-  if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) {
-    this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
-  }
-}
-
 void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
 {
   if (!this->ModuleDefinitionFile) {
@@ -123,7 +112,7 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
     const char* lang = l.c_str();
 
     // Add language feature flags.
-    this->AddFeatureFlags(flags, lang);
+    this->LocalGenerator->AddFeatureFlags(flags, lang, this->GeneratorTarget);
 
     this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
                                                lang, this->ConfigName);
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index 0bafde9..32dffa2 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -34,9 +34,6 @@ public:
   std::string const& GetConfigName() const;
 
 protected:
-  // Add language feature flags.
-  void AddFeatureFlags(std::string& flags, const std::string& lang);
-
   // Feature query methods.
   const char* GetFeature(const std::string& feature);
   bool GetFeatureAsBool(const std::string& feature);
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 2706dd5..2bfaea1 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -36,6 +36,19 @@ void cmLocalCommonGenerator::SetConfigName()
   }
 }
 
+void cmLocalCommonGenerator::AddFeatureFlags(std::string& flags,
+                                             std::string const& lang,
+                                             cmGeneratorTarget const* target)
+{
+  // Add language-specific flags.
+  this->AddLanguageFlags(flags, lang, this->ConfigName);
+
+  if (target->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION",
+                               this->ConfigName)) {
+    this->AppendFeatureOptions(flags, lang, "IPO");
+  }
+}
+
 std::string cmLocalCommonGenerator::GetFortranFlags(
   cmGeneratorTarget const* target)
 {
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index d4370f4..c89db17 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -33,6 +33,9 @@ public:
     return this->WorkingDirectory;
   }
 
+  void AddFeatureFlags(std::string& flags, std::string const& lang,
+                       cmGeneratorTarget const* target);
+
   std::string GetFortranFlags(cmGeneratorTarget const* target);
 
 protected:
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 9d42257..f2c7bc8 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -189,7 +189,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   }
 
   // Add language feature flags.
-  this->AddFeatureFlags(flags, linkLanguage);
+  this->LocalGenerator->AddFeatureFlags(flags, linkLanguage,
+                                        this->GeneratorTarget);
 
   this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
                                              linkLanguage, this->ConfigName);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 438f90f..8a8fda2 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -628,7 +628,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
 
     // Add language feature flags.
     std::string langFlags;
-    this->AddFeatureFlags(langFlags, linkLanguage);
+    this->LocalGenerator->AddFeatureFlags(langFlags, linkLanguage,
+                                          this->GeneratorTarget);
 
     this->LocalGenerator->AddArchitectureFlags(
       langFlags, this->GeneratorTarget, linkLanguage, this->ConfigName);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fa9190d606b4f97d0929562f1f5854d7a3d8693
commit 7fa9190d606b4f97d0929562f1f5854d7a3d8693
Author:     Tobias Hunger <tobias.hunger at qt.io>
AuthorDate: Fri Jun 10 17:51:26 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 16 11:42:17 2016 -0400

    cmLocalCommonGenerator: Adopt Fortran flag generation
    
    Move cmCommonTargetGenerator::AddFortranFlags to
    cmLocalCommonGenerator::GetFortranFlags so it can be used without having
    a target generator available.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index eb1216e..0f87d89 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -88,51 +88,6 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
   this->LocalGenerator->AppendFlags(flags, flag);
 }
 
-void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
-{
-  // Enable module output if necessary.
-  if (const char* modout_flag =
-        this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
-    this->LocalGenerator->AppendFlags(flags, modout_flag);
-  }
-
-  // Add a module output directory flag if necessary.
-  std::string mod_dir = this->GeneratorTarget->GetFortranModuleDirectory();
-  if (!mod_dir.empty()) {
-    mod_dir =
-      this->Convert(mod_dir, this->LocalGenerator->GetWorkingDirectory(),
-                    cmOutputConverter::SHELL);
-  } else {
-    mod_dir =
-      this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
-  }
-  if (!mod_dir.empty()) {
-    const char* moddir_flag =
-      this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
-    std::string modflag = moddir_flag;
-    modflag += mod_dir;
-    this->LocalGenerator->AppendFlags(flags, modflag);
-  }
-
-  // If there is a separate module path flag then duplicate the
-  // include path with it.  This compiler does not search the include
-  // path for modules.
-  if (const char* modpath_flag =
-        this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
-    std::vector<std::string> includes;
-    const std::string& config = this->ConfigName;
-    this->LocalGenerator->GetIncludeDirectories(
-      includes, this->GeneratorTarget, "C", config);
-    for (std::vector<std::string>::const_iterator idi = includes.begin();
-         idi != includes.end(); ++idi) {
-      std::string flg = modpath_flag;
-      flg +=
-        this->Convert(*idi, cmOutputConverter::NONE, cmOutputConverter::SHELL);
-      this->LocalGenerator->AppendFlags(flags, flg);
-    }
-  }
-}
-
 void cmCommonTargetGenerator::AppendFortranFormatFlags(
   std::string& flags, cmSourceFile const& source)
 {
@@ -175,7 +130,8 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
 
     // Fortran-specific flags computed for this target.
     if (l == "Fortran") {
-      this->AddFortranFlags(flags);
+      this->LocalGenerator->AppendFlags(
+        flags, this->LocalGenerator->GetFortranFlags(this->GeneratorTarget));
     }
 
     this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index dc4974c..0bafde9 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -53,9 +53,6 @@ protected:
   // The windows module definition source file (.def), if any.
   cmSourceFile const* ModuleDefinitionFile;
 
-  // Compute target-specific Fortran language flags.
-  void AddFortranFlags(std::string& flags);
-
   std::string Convert(
     std::string const& source, cmOutputConverter::RelativeRoot relative,
     cmOutputConverter::OutputFormat output = cmOutputConverter::UNCHANGED);
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 6cfeb10..2706dd5 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -35,3 +35,50 @@ void cmLocalCommonGenerator::SetConfigName()
     this->ConfigName = "";
   }
 }
+
+std::string cmLocalCommonGenerator::GetFortranFlags(
+  cmGeneratorTarget const* target)
+{
+  std::string flags;
+
+  // Enable module output if necessary.
+  if (const char* modout_flag =
+        this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
+    this->AppendFlags(flags, modout_flag);
+  }
+
+  // Add a module output directory flag if necessary.
+  std::string mod_dir = target->GetFortranModuleDirectory();
+  if (!mod_dir.empty()) {
+    mod_dir =
+      this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL);
+  } else {
+    mod_dir =
+      this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
+  }
+  if (!mod_dir.empty()) {
+    const char* moddir_flag =
+      this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
+    std::string modflag = moddir_flag;
+    modflag += mod_dir;
+    this->AppendFlags(flags, modflag);
+  }
+
+  // If there is a separate module path flag then duplicate the
+  // include path with it.  This compiler does not search the include
+  // path for modules.
+  if (const char* modpath_flag =
+        this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
+    std::vector<std::string> includes;
+    this->GetIncludeDirectories(includes, target, "C", this->ConfigName);
+    for (std::vector<std::string>::const_iterator idi = includes.begin();
+         idi != includes.end(); ++idi) {
+      std::string flg = modpath_flag;
+      flg +=
+        this->Convert(*idi, cmOutputConverter::NONE, cmOutputConverter::SHELL);
+      this->AppendFlags(flags, flg);
+    }
+  }
+
+  return flags;
+}
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index 10380db..d4370f4 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -33,6 +33,8 @@ public:
     return this->WorkingDirectory;
   }
 
+  std::string GetFortranFlags(cmGeneratorTarget const* target);
+
 protected:
   cmOutputConverter::RelativeRoot WorkingDirectory;
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27fcb61ba413811df0649cbf4244081564ebc614
commit 27fcb61ba413811df0649cbf4244081564ebc614
Author:     Tobias Hunger <tobias.hunger at qt.io>
AuthorDate: Fri Jun 10 16:58:36 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 16 11:22:19 2016 -0400

    cmGeneratorTarget: Adopt Fortran module directory generation
    
    Move code to create/get the fortran module directory from the
    cmCommonTargetGenerator to cmGeneratorTarget.
    
    Rename the ComputeFortranModuleDirectory method to
    CreateFortranModuleDirectory as this method *creates* the directory if
    it is missing.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 1cc04ea..eb1216e 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -27,7 +27,6 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
       gt->LocalGenerator->GetGlobalGenerator()))
   , ConfigName(LocalGenerator->GetConfigName())
   , ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName))
-  , FortranModuleDirectoryComputed(false)
 {
 }
 
@@ -89,43 +88,6 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
   this->LocalGenerator->AppendFlags(flags, flag);
 }
 
-std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
-{
-  std::string mod_dir;
-  const char* target_mod_dir =
-    this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY");
-  const char* moddir_flag =
-    this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
-  if (target_mod_dir && moddir_flag) {
-    // Compute the full path to the module directory.
-    if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
-      // Already a full path.
-      mod_dir = target_mod_dir;
-    } else {
-      // Interpret relative to the current output directory.
-      mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
-      mod_dir += "/";
-      mod_dir += target_mod_dir;
-    }
-
-    // Make sure the module output directory exists.
-    cmSystemTools::MakeDirectory(mod_dir);
-  }
-  return mod_dir;
-}
-
-std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
-{
-  // Compute the module directory.
-  if (!this->FortranModuleDirectoryComputed) {
-    this->FortranModuleDirectoryComputed = true;
-    this->FortranModuleDirectory = this->ComputeFortranModuleDirectory();
-  }
-
-  // Return the computed directory.
-  return this->FortranModuleDirectory;
-}
-
 void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
 {
   // Enable module output if necessary.
@@ -135,7 +97,7 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
   }
 
   // Add a module output directory flag if necessary.
-  std::string mod_dir = this->GetFortranModuleDirectory();
+  std::string mod_dir = this->GeneratorTarget->GetFortranModuleDirectory();
   if (!mod_dir.empty()) {
     mod_dir =
       this->Convert(mod_dir, this->LocalGenerator->GetWorkingDirectory(),
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index c35d22a..dc4974c 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -53,12 +53,6 @@ protected:
   // The windows module definition source file (.def), if any.
   cmSourceFile const* ModuleDefinitionFile;
 
-  // Target-wide Fortran module output directory.
-  bool FortranModuleDirectoryComputed;
-  std::string FortranModuleDirectory;
-  std::string GetFortranModuleDirectory();
-  virtual std::string ComputeFortranModuleDirectory() const;
-
   // Compute target-specific Fortran language flags.
   void AddFortranFlags(std::string& flags);
 
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 5f4b074..15b44a6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -258,6 +258,7 @@ void CreatePropertyGeneratorExpressions(
 
 cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
   : Target(t)
+  , FortranModuleDirectoryCreated(false)
   , SourceFileFlagsConstructed(false)
   , PolicyWarnedCMP0022(false)
   , DebugIncludesDone(false)
@@ -3842,6 +3843,40 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major,
   }
 }
 
+std::string cmGeneratorTarget::GetFortranModuleDirectory() const
+{
+  if (!this->FortranModuleDirectoryCreated) {
+    this->FortranModuleDirectory = true;
+    this->FortranModuleDirectory = this->CreateFortranModuleDirectory();
+  }
+
+  return this->FortranModuleDirectory;
+}
+
+std::string cmGeneratorTarget::CreateFortranModuleDirectory() const
+{
+  static std::string mod_dir;
+  const char* target_mod_dir = this->GetProperty("Fortran_MODULE_DIRECTORY");
+  const char* moddir_flag =
+    this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
+  if (target_mod_dir && moddir_flag) {
+    // Compute the full path to the module directory.
+    if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
+      // Already a full path.
+      mod_dir = target_mod_dir;
+    } else {
+      // Interpret relative to the current output directory.
+      mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
+      mod_dir += "/";
+      mod_dir += target_mod_dir;
+    }
+
+    // Make sure the module output directory exists.
+    cmSystemTools::MakeDirectory(mod_dir);
+  }
+  return mod_dir;
+}
+
 std::string cmGeneratorTarget::GetFrameworkVersion() const
 {
   assert(this->GetType() != cmState::INTERFACE_LIBRARY);
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 63208bc..2ee9bef 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -526,7 +526,13 @@ public:
   void GetTargetVersion(bool soversion, int& major, int& minor,
                         int& patch) const;
 
+  std::string GetFortranModuleDirectory() const;
+
 private:
+  std::string CreateFortranModuleDirectory() const;
+  mutable bool FortranModuleDirectoryCreated;
+  mutable std::string FortranModuleDirectory;
+
   friend class cmTargetTraceDependencies;
   struct SourceEntry
   {
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index daf05d3..8b341a1 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -962,7 +962,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
     << "\n"
     << "# Fortran module output directory.\n"
     << "set(CMAKE_Fortran_TARGET_MODULE_DIR \""
-    << this->GetFortranModuleDirectory() << "\")\n";
+    << this->GeneratorTarget->GetFortranModuleDirectory() << "\")\n";
   /* clang-format on */
 
   // and now write the rule to use it

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52572a26dfdfb7eaa0d28870e215bd00dcc1ec55
commit 52572a26dfdfb7eaa0d28870e215bd00dcc1ec55
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 16 10:54:20 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Jun 16 10:54:20 2016 -0400

    Refactor Makefile/Ninja tool working directory storage
    
    Move cmCommonTargetGenerator::WorkingDirectory to cmLocalCommonGenerator
    and add an access method.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index b893dd3..1cc04ea 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -19,10 +19,8 @@
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
 
-cmCommonTargetGenerator::cmCommonTargetGenerator(
-  cmOutputConverter::RelativeRoot wd, cmGeneratorTarget* gt)
-  : WorkingDirectory(wd)
-  , GeneratorTarget(gt)
+cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
+  : GeneratorTarget(gt)
   , Makefile(gt->Makefile)
   , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
   , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
@@ -140,7 +138,8 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
   std::string mod_dir = this->GetFortranModuleDirectory();
   if (!mod_dir.empty()) {
     mod_dir =
-      this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL);
+      this->Convert(mod_dir, this->LocalGenerator->GetWorkingDirectory(),
+                    cmOutputConverter::SHELL);
   } else {
     mod_dir =
       this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
@@ -308,7 +307,8 @@ std::string cmCommonTargetGenerator::GetManifests()
   for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
        mi != manifest_srcs.end(); ++mi) {
     manifests.push_back(this->Convert(
-      (*mi)->GetFullPath(), this->WorkingDirectory, cmOutputConverter::SHELL));
+      (*mi)->GetFullPath(), this->LocalGenerator->GetWorkingDirectory(),
+      cmOutputConverter::SHELL));
   }
 
   return cmJoin(manifests, " ");
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index ace5351..c35d22a 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -28,8 +28,7 @@ class cmSourceFile;
 class cmCommonTargetGenerator
 {
 public:
-  cmCommonTargetGenerator(cmOutputConverter::RelativeRoot wd,
-                          cmGeneratorTarget* gt);
+  cmCommonTargetGenerator(cmGeneratorTarget* gt);
   virtual ~cmCommonTargetGenerator();
 
   std::string const& GetConfigName() const;
@@ -45,7 +44,6 @@ protected:
   // Helper to add flag for windows .def file.
   void AddModuleDefinitionFlag(std::string& flags);
 
-  cmOutputConverter::RelativeRoot WorkingDirectory;
   cmGeneratorTarget* GeneratorTarget;
   cmMakefile* Makefile;
   cmLocalCommonGenerator* LocalGenerator;
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 3ebd128..6cfeb10 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -13,9 +13,10 @@
 
 #include "cmMakefile.h"
 
-cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
-                                               cmMakefile* mf)
+cmLocalCommonGenerator::cmLocalCommonGenerator(
+  cmGlobalGenerator* gg, cmMakefile* mf, cmOutputConverter::RelativeRoot wd)
   : cmLocalGenerator(gg, mf)
+  , WorkingDirectory(wd)
 {
 }
 
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index d282054..10380db 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -22,12 +22,20 @@ class cmCommonTargetGenerator;
 class cmLocalCommonGenerator : public cmLocalGenerator
 {
 public:
-  cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
+  cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf,
+                         cmOutputConverter::RelativeRoot wd);
   ~cmLocalCommonGenerator();
 
   std::string const& GetConfigName() { return this->ConfigName; }
 
+  cmOutputConverter::RelativeRoot GetWorkingDirectory() const
+  {
+    return this->WorkingDirectory;
+  }
+
 protected:
+  cmOutputConverter::RelativeRoot WorkingDirectory;
+
   void SetConfigName();
   std::string ConfigName;
 
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 6e676f1..0f488a6 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -25,7 +25,7 @@
 
 cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
                                              cmMakefile* mf)
-  : cmLocalCommonGenerator(gg, mf)
+  : cmLocalCommonGenerator(gg, mf, cmOutputConverter::HOME_OUTPUT)
   , HomeRelativeOutputPath("")
 {
   this->TargetImplib = "$TARGET_IMPLIB";
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 4b5af8b..460f0e2 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -84,7 +84,7 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
 
 cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
   cmGlobalGenerator* gg, cmMakefile* mf)
-  : cmLocalCommonGenerator(gg, mf)
+  : cmLocalCommonGenerator(gg, mf, cmOutputConverter::START_OUTPUT)
 {
   this->MakefileVariableSize = 0;
   this->ColorMakefile = false;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3086bb1..daf05d3 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -32,7 +32,7 @@
 #include <ctype.h>
 
 cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
-  : cmCommonTargetGenerator(cmOutputConverter::START_OUTPUT, target)
+  : cmCommonTargetGenerator(target)
   , OSXBundleGenerator(0)
   , MacOSXContentGenerator(0)
 {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 05a0a63..b413c33 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -58,7 +58,7 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
 }
 
 cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
-  : cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target)
+  : cmCommonTargetGenerator(target)
   , MacOSXContentGenerator(0)
   , OSXBundleGenerator(0)
   , MacContentFolders()

-----------------------------------------------------------------------

Summary of changes:
 Source/cmCommonTargetGenerator.cxx             |  133 ++----------------------
 Source/cmCommonTargetGenerator.h               |   16 +--
 Source/cmGeneratorTarget.cxx                   |   35 +++++++
 Source/cmGeneratorTarget.h                     |    6 ++
 Source/cmLocalCommonGenerator.cxx              |   85 ++++++++++++++-
 Source/cmLocalCommonGenerator.h                |   18 +++-
 Source/cmLocalNinjaGenerator.cxx               |    2 +-
 Source/cmLocalUnixMakefileGenerator3.cxx       |    2 +-
 Source/cmMakefileExecutableTargetGenerator.cxx |    3 +-
 Source/cmMakefileLibraryTargetGenerator.cxx    |    3 +-
 Source/cmMakefileTargetGenerator.cxx           |    4 +-
 Source/cmNinjaTargetGenerator.cxx              |    2 +-
 12 files changed, 157 insertions(+), 152 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list