mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
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
This commit is contained in:
@@ -8,6 +8,7 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>]
|
||||
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm]
|
||||
|
||||
set(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=")
|
||||
set(CMAKE_Fortran_MODDIR_INCLUDE_FLAG "-I") # -qmoddir= does not affect search path
|
||||
|
||||
set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D")
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user