MantisBT - CMake
View Issue Details
0015536CMakeCMakepublic2015-04-26 06:412015-11-02 09:13
Paul Romano 
 
normalminorhave not tried
closedno change required 
CMake 3.2.2 
 
0015536: Include directories for .mod files produced with IBM XL Fortran
When the IBM XL Fortran compiler is detected, the following is set:

set(CMAKE_Fortran_MODDIR_Flag "-qmoddir=")

According to the xlf documentation, this flag specifies where .mod files produced should be placed. However, unlike the -J option for gfortran and the -module option for ifort, -qmoddir does not tell the compiler to search for module files in this directory; for that, one also needs to specify -I. Thus, in order to work properly, you really need something like:

-qmoddir=includedir -Iincludedir
I'm using the IBM XL Fortran 14.1 for BlueGene/Q compiler on the Mira supercomputer at Argonne National Laboratory.
No tags attached.
Issue History
2015-04-26 06:41Paul RomanoNew Issue
2015-04-26 07:36Paul RomanoNote Added: 0038600
2015-04-27 10:55Brad KingNote Added: 0038618
2015-04-27 10:55Brad KingStatusnew => resolved
2015-04-27 10:55Brad KingResolutionopen => no change required
2015-04-27 19:04Paul RomanoNote Added: 0038624
2015-04-28 13:58Brad KingNote Added: 0038628
2015-11-02 09:13Robert MaynardNote Added: 0039793
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038600)
Paul Romano   
2015-04-26 07:36   
I should have mentioned before -- this prevents compilation when one module uses another with xlf giving the following error:

1514-219 (S) Unable to access module symbol file for module _____. Check path and file permissions of file. Use association not done for this module.
(0038618)
Brad King   
2015-04-27 10:55   
It is expected that the project use include_directories or target_include_directories to specify this.
(0038624)
Paul Romano   
2015-04-27 19:04   
Perhaps I didn't explain the issue clearly enough. Take the following example: two source files, a main program main.f90 and a module foo.f90 which is used by main.f90. The following CMakeLists.txt will fail with the above error when the IBM XL Fortran compiler is used:

project(main Fortran)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
add_executable(main main.f90 foo.f90)

This fails because foo.mod is generated in the include directory, and then when it tries to compile main.f90, the -qmoddir argument says "put any mod files generated in include" but it doesn't include a -I argument that tells it "search for .mod files in this directory".

Note that this simple example works fine with other Fortran compilers. With gfortran CMAKE_Fortran MODDIR_FLAG is set to -J which tells gfortran both where to generate .mod files and where to search for them. Similarly with ifort, CMAKE_Fortran_MODDIR_FLAG is -module which tells it where to generate and find .mod files. So it's really an idiosyncrasy of the XL compiler that it doesn't have an option similar to other compilers.
(0038628)
Brad King   
2015-04-28 13:58   
Re 0015536:0038624: Your example is missing

 include_directories(${CMAKE_BINARY_DIR}/include)

The Fortran_MODULE_DIRECTORY API is documented to specify the *output* location. It has no influence on include directories.
(0039793)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.