summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-28 15:22:23 (GMT)
committerBrad King <brad.king@kitware.com>2020-02-28 15:37:11 (GMT)
commit210b0b99a96a37cb19de7e703c12f99a4a925926 (patch)
tree42535cdd045049f9ac04b86d791fa309c08260cc /Source
parent2a9cf889178dfc202ec84f1fece8a68594cc3566 (diff)
downloadCMake-210b0b99a96a37cb19de7e703c12f99a4a925926.zip
CMake-210b0b99a96a37cb19de7e703c12f99a4a925926.tar.gz
CMake-210b0b99a96a37cb19de7e703c12f99a4a925926.tar.bz2
XL: Fix using Fortran modules from their output directory
The XL Fortran compiler's `-qmoddir=` flag sets the module output directory but does not add the directory to the search path for using modules. This is inconsistent with other compilers like the GNU Fortran compiler's `-J` flag that does both. In order to make these consistent, add the module output directory with a `-I` flag on the XL Fortran compiler so that it will be searched when using modules too. This fixes our `FortranModules` test's coverage of submodules on Ninja + XL. That test places module files in a subdirectory that with Ninja is not the current working directory when the compiler runs. Fixes: #20400
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalCommonGenerator.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 025ef7e..278ec8b 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -50,6 +50,15 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG"),
mod_dir);
this->AppendFlags(flags, modflag);
+ // Some compilers do not search their own module output directory
+ // for using other modules. Add an include directory explicitly
+ // for consistency with compilers that do search it.
+ std::string incflag =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_INCLUDE_FLAG");
+ if (!incflag.empty()) {
+ incflag = cmStrCat(incflag, mod_dir);
+ this->AppendFlags(flags, incflag);
+ }
}
// If there is a separate module path flag then duplicate the