summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-19 19:36:00 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-20 12:48:41 (GMT)
commit7b5f85677c8aa067a5fef1cc68f4d8c8600693fa (patch)
tree1f5d9a419980bb89df73afae0d44aba8c731b314 /Source/cmGeneratorTarget.cxx
parent1777570fe5eb194d930f6716865bc909269da57e (diff)
downloadCMake-7b5f85677c8aa067a5fef1cc68f4d8c8600693fa.zip
CMake-7b5f85677c8aa067a5fef1cc68f4d8c8600693fa.tar.gz
CMake-7b5f85677c8aa067a5fef1cc68f4d8c8600693fa.tar.bz2
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.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx15
1 files changed, 12 insertions, 3 deletions
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");