MantisBT - CMake
View Issue Details
0013034CMake(No Category)public2012-03-09 23:272012-09-03 16:02
Ben Matthews 
Brad King 
normalminoralways
closedfixed 
IBM Bluegene/LLinux (SuSe PowerPC multilib)SLES 9
CMake 2.8.7 
CMake 2.8.8CMake 2.8.8 
0013034: CMAKE_Fortran_MODULE_DIRECTORY does not document that it is output only
XLF 10.1 looks for modules in the directories passed to the "-I" switch. CMake correctly sets -qmoddir= to set the module output directory, but fails to generate the matching -I switch, causing builds using a non-standard module directory to fail.

(The build also fails with the GFortran 3.3.3 as shipped with BG/L with
g77: unrecognized option `-Jmodules')
mkdir tmp
git clone https://matthb2@github.com/matthb2/CMake-XL-Fortran-Module-Bug.git [^]
mkdir build-broken
cd build-broken
cmake -DCMAKE_TOOLCHAIN_FILE=/gpfs/gpfs0/home/matthb2/bluegenexlc-mpixlf.cmake ../CMake-XL-Fortran-Module-Bug/
#snipped
make
Scanning dependencies of target test
[ 50%] Building Fortran object CMakeFiles/test.dir/modexample.f.o
** test === End of Compilation 1 ===
1501-510 Compilation successful for file modexample.f.
[100%] Building Fortran object CMakeFiles/test.dir/main.f.o
"/gpfs/gpfs0/home/matthb2/cmake_bug/CMake-XL-Fortran-Module-Bug/main.f", line 2.15: 1514-219 (S) Unable to access module symbol file for module test. Check path and file permissions of file. Use association not done for this module.
1501-511 Compilation failed for file main.f.
make[2]: *** [CMakeFiles/test.dir/main.f.o] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2

cd ../CMake-XL-Fortran-Module-Bug
git checkout -b workaround origin/workaround
mkdir ../build-works
cd ../build-works
cmake -DCMAKE_TOOLCHAIN_FILE=/gpfs/gpfs0/home/matthb2/bluegenexlc-mpixlf.cmake ../CMake-XL-Fortran-Module-Bug/
#snipped
make

-- Configuring done
-- Generating done
-- Build files have been written to: /gpfs/gpfs0/home/matthb2/cmake_bug/build
Scanning dependencies of target test
[ 50%] Building Fortran object CMakeFiles/test.dir/modexample.f.o
** test === End of Compilation 1 ===
1501-510 Compilation successful for file modexample.f.
[100%] Building Fortran object CMakeFiles/test.dir/main.f.o
** demo === End of Compilation 1 ===
1501-510 Compilation successful for file main.f.
Linking Fortran executable test
[100%] Built target test
No tags attached.
Issue History
2012-03-09 23:27Ben MatthewsNew Issue
2012-03-09 23:29Ben MatthewsNote Added: 0028887
2012-03-09 23:31Ben MatthewsNote Edited: 0028887bug_revision_view_page.php?bugnote_id=28887#r569
2012-03-12 09:07Brad KingNote Added: 0028889
2012-03-12 11:46Ben MatthewsNote Added: 0028892
2012-03-12 11:56Brad KingSummarySetting CMAKE_Fortran_MODULE_DIRECTORY breaks build on IBM XLF Compiler => CMAKE_Fortran_MODULE_DIRECTORY does not document that it is output only
2012-03-12 11:57Brad KingNote Added: 0028893
2012-03-12 11:57Brad KingStatusnew => resolved
2012-03-12 11:57Brad KingFixed in Version => CMake 2.8.8
2012-03-12 11:57Brad KingResolutionopen => fixed
2012-03-12 11:57Brad KingAssigned To => Brad King
2012-04-19 15:53David ColeTarget Version => CMake 2.8.8
2012-09-03 16:02David ColeNote Added: 0030885
2012-09-03 16:02David ColeStatusresolved => closed

Notes
(0028887)
Ben Matthews   
2012-03-09 23:29   
(edited on: 2012-03-09 23:31)
Test system is a front-end node for an IBM Bluegene/L

Likely also applicable to /P, but I haven't tested it.

Example (master branch) works fine with modern versions of gfortran on x86

(0028889)
Brad King   
2012-03-12 09:07   
The CMAKE_Fortran_MODULE_DIRECTORY variable is about where module *output* goes. This is orthogonal in principle to where module *input* is searched. It is perfectly reasonable for a target to generate modules it doesn't use and thus would not need the output directory to be an input directory automatically. You need to add the location with include_directories().
(0028892)
Ben Matthews   
2012-03-12 11:46   
Ok. To me, it would be nice if the documentation made this a little more clear, since this issue only seems to show up on a few (less common) compilers.
(0028893)
Brad King   
2012-03-12 11:57   
This came up on the mailing list recently too. I've updated the documentation:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54604ee7 [^]
(0030885)
David Cole   
2012-09-03 16:02   
Closing resolved issues that have not been updated in more than 4 months.