From 210b0b99a96a37cb19de7e703c12f99a4a925926 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Feb 2020 10:22:23 -0500 Subject: 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 --- Modules/Compiler/XL-Fortran.cmake | 1 + Source/cmLocalCommonGenerator.cxx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index 1683dff..e01ec8e 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -8,6 +8,7 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=] 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") 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 -- cgit v0.12 From 92785ed74645e2331fca15ca1f657377c936a795 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2020 11:28:20 -0500 Subject: Tests: Enable Fortran submodule tests on XL compilers Since commit b66bc6606e (Tests: Add Fortran submodule tests, 2016-09-22, v3.7.0-rc1~55^2) we try a small test program to see if the Fortran compiler supports submodules. However, a typo in the test program caused it to fail on XL with the error: 1513-083 (E) Internal or module function id was not set within the function. Fix the typo so that the check passes and enables the submodule tests with XL compilers. --- Tests/FortranModules/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index d056b43..b7a6f68 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -21,7 +21,7 @@ end module parent submodule ( parent ) child contains module procedure id - f = x + id = x end procedure id end submodule child program main -- cgit v0.12