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 e827f616b9cf26d7ca98e06fbb6d439203ec9b39 (commit) via 8c5f1c8b636270a4d75d6a1dff2f29671a096880 (commit) via 8da72b129f119e5e03e58164e0ca3c279fedde84 (commit) from 2b5471bd742db73bc45b97cfdcba9109f5aeda33 (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=e827f616b9cf26d7ca98e06fbb6d439203ec9b39 commit e827f616b9cf26d7ca98e06fbb6d439203ec9b39 Merge: 2b5471b 8c5f1c8 Author: Brad King <brad.k...@kitware.com> AuthorDate: Mon Sep 19 15:43:10 2016 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Mon Sep 19 15:43:10 2016 -0400 Merge topic 'refactor-fortran-module-dir-lookup' into next 8c5f1c8b Fortran: Use module dir flag if needed for default module directory 8da72b12 cmGeneratorTarget: Refactor Fortran module directory lookup https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c5f1c8b636270a4d75d6a1dff2f29671a096880 commit 8c5f1c8b636270a4d75d6a1dff2f29671a096880 Author: Brad King <brad.k...@kitware.com> AuthorDate: Mon Sep 19 15:36:00 2016 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Sep 19 15:41:32 2016 -0400 Fortran: Use module dir flag if needed for default module directory Our buildsystem model says that the default Fortran module output directory is the build tree directory corresponding to the source tree `CMakeLists.txt` file adding the current target. Extend `cmGeneratorTarget::GetFortranModuleDirectory` to allow generators to pass in the compiler working directory. If the working directory does not match the default Fortran module output directory then we need an explicit module directory flag (e.g. `-J`) to tell the compiler to put/use modules in the latter. This does not affect the Makefile generator but will be useful for future introduction of Fortran support to the Ninja generator. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bed0b11..f181cf6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3883,22 +3883,31 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major, } } -std::string cmGeneratorTarget::GetFortranModuleDirectory() const +std::string cmGeneratorTarget::GetFortranModuleDirectory( + std::string const& working_dir) const { if (!this->FortranModuleDirectoryCreated) { this->FortranModuleDirectory = true; - this->FortranModuleDirectory = this->CreateFortranModuleDirectory(); + this->FortranModuleDirectory = + this->CreateFortranModuleDirectory(working_dir); } return this->FortranModuleDirectory; } -std::string cmGeneratorTarget::CreateFortranModuleDirectory() const +std::string cmGeneratorTarget::CreateFortranModuleDirectory( + std::string const& working_dir) const { std::string mod_dir; std::string target_mod_dir; if (const char* prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) { target_mod_dir = prop; + } else { + std::string const& default_mod_dir = + this->LocalGenerator->GetCurrentBinaryDirectory(); + if (default_mod_dir != working_dir) { + target_mod_dir = default_mod_dir; + } } const char* moddir_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 715220e..8e17b8f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -537,12 +537,13 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - std::string GetFortranModuleDirectory() const; + std::string GetFortranModuleDirectory(std::string const& working_dir) const; private: void AddSourceCommon(const std::string& src); - std::string CreateFortranModuleDirectory() const; + std::string CreateFortranModuleDirectory( + std::string const& working_dir) const; mutable bool FortranModuleDirectoryCreated; mutable std::string FortranModuleDirectory; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 0e79293..2de28b8 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -53,7 +53,10 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( } // Add a module output directory flag if necessary. - std::string mod_dir = target->GetFortranModuleDirectory(); + std::string mod_dir = target->GetFortranModuleDirectory( + this->WorkingDirectory == cmOutputConverter::HOME_OUTPUT + ? this->GetBinaryDirectory() + : this->GetCurrentBinaryDirectory()); if (!mod_dir.empty()) { mod_dir = this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 165f96c..862ea50 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -973,12 +973,16 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << " )\n"; } + std::string const& working_dir = + this->LocalGenerator->GetCurrentBinaryDirectory(); + /* clang-format off */ *this->InfoFileStream << "\n" << "# Fortran module output directory.\n" << "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" - << this->GeneratorTarget->GetFortranModuleDirectory() << "\")\n"; + << this->GeneratorTarget->GetFortranModuleDirectory(working_dir) + << "\")\n"; /* clang-format on */ // and now write the rule to use it https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8da72b129f119e5e03e58164e0ca3c279fedde84 commit 8da72b129f119e5e03e58164e0ca3c279fedde84 Author: Brad King <brad.k...@kitware.com> AuthorDate: Mon Sep 19 15:30:34 2016 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Sep 19 15:41:10 2016 -0400 cmGeneratorTarget: Refactor Fortran module directory lookup Make `target_module_dir` and owned value so we can modify it. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1e21ac4..bed0b11 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3896,10 +3896,13 @@ std::string cmGeneratorTarget::GetFortranModuleDirectory() const std::string cmGeneratorTarget::CreateFortranModuleDirectory() const { std::string mod_dir; - const char* target_mod_dir = this->GetProperty("Fortran_MODULE_DIRECTORY"); + std::string target_mod_dir; + if (const char* prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) { + target_mod_dir = prop; + } const char* moddir_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); - if (target_mod_dir && moddir_flag) { + if (!target_mod_dir.empty() && moddir_flag) { // Compute the full path to the module directory. if (cmSystemTools::FileIsFullPath(target_mod_dir)) { // Already a full path. ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 22 +++++++++++++++++----- Source/cmGeneratorTarget.h | 5 +++-- Source/cmLocalCommonGenerator.cxx | 5 ++++- Source/cmMakefileTargetGenerator.cxx | 6 +++++- 4 files changed, 29 insertions(+), 9 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits