[CMake] Different flags for compiling and linking with Fortran
xavier lacoste
xl64100 at gmail.com
Thu Jun 15 03:11:49 EDT 2017
Dear Cmake Users,
I could reproduce this with a minimal CMakeLists.txt :
[lacoste at caimanp8 test]$ cat CMakeLists.txt
###############################################################################
#
#
# CMake proposal for SABL projects based on Python + libs in C/Fortran
#
#
#
###############################################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT(TOTO)
ENABLE_LANGUAGE (C Fortran)
[lacoste at caimanp8 test]$ FFLAGS="-cpp" cmake .
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /opt/ibm/xlC/13.1.5/bin/xlc_r
-- Check for working C compiler: /opt/ibm/xlC/13.1.5/bin/xlc_r -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/ibm/xlC/13.1.5/bin/xlC_r
-- Check for working CXX compiler: /opt/ibm/xlC/13.1.5/bin/xlC_r -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is XL
-- Check for working Fortran compiler: /opt/ibm/xlf/15.1.5/bin/xlf90_r
-- Check for working Fortran compiler: /opt/ibm/xlf/15.1.5/bin/xlf90_r --
broken
CMake Error at /usr/share/cmake/Modules/CMakeTestFortranCompiler.cmake:54
(message):
The Fortran compiler "/opt/ibm/xlf/15.1.5/bin/xlf90_r" is not able to
compile a simple test program.
It fails with the following output:
Change Dir: /home/lacoste/test/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec1053595571/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1053595571.dir/build.make
CMakeFiles/cmTryCompileExec1053595571.dir/build
gmake[1]: Entering directory `/home/lacoste/test/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/lacoste/test/CMakeFiles/CMakeTmp/CMakeFiles 1
Building Fortran object
CMakeFiles/cmTryCompileExec1053595571.dir/testFortranCompiler.f.o
/opt/ibm/xlf/15.1.5/bin/xlf90_r -cpp -qthreaded -qhalt=e -c
/home/lacoste/test/CMakeFiles/CMakeTmp/testFortranCompiler.f -o
CMakeFiles/cmTryCompileExec1053595571.dir/testFortranCompiler.f.o
** testfortran === End of Compilation 1 ===
1501-510 Compilation successful for file testFortranCompiler.f.
Linking Fortran executable cmTryCompileExec1053595571
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec1053595571.dir/link.txt --verbose=1
/opt/ibm/xlf/15.1.5/bin/xlf90_r -cpp -qthreaded -qhalt=e
CMakeFiles/cmTryCompileExec1053595571.dir/testFortranCompiler.f.o -o
cmTryCompileExec1053595571
/opt/ibm/xlf/15.1.5/bin/.orig/xlf90_r: 1501-294 (S) No input file
specified. Please use -qhelp for more information.
gmake[1]: *** [cmTryCompileExec1053595571] Error 249
gmake[1]: Leaving directory `/home/lacoste/test/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec1053595571/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:11 (ENABLE_LANGUAGE)
-- Configuring incomplete, errors occurred!
See also "/home/lacoste/test/CMakeFiles/CMakeOutput.log".
See also "/home/lacoste/test/CMakeFiles/CMakeError.log".
Regards,
XL
2017-06-15 9:04 GMT+02:00 xavier lacoste <xl64100 at gmail.com>:
> Dear cmake users,
>
> For some Fortran compiler we need to remove flags we added to
> CMAKE_Fortran_FLAGS_RELEASE to be able to link (options not recognized at
> link).
>
> Do you have any idea of how to do so ?
>
> A practical case is the xlf90 -cpp flag.
> I have several .f90 files that need preprocessing so I require -cpp
> -qsuffix=cpp=f90 at compile time but it is not supported at link time.
>
> If I use :
> FFLAGS="-g -cpp -qxlf2003=POLYmorphic -qsuffix=cpp=f90 -qextname
> -qdirective='IBM*' -qport=typlssarg"
> I get an error when CMake tries to build a fortran file with XLF :
> -- Check for working Fortran compiler: /opt/ibm/xlf/15.1.5/bin/xlf90_r
> -- Check for working Fortran compiler: /opt/ibm/xlf/15.1.5/bin/xlf90_r
> -- broken
> CMake Error at /usr/share/cmake/Modules/CMakeTestFortranCompiler.cmake:54
> (message):
> The Fortran compiler "/opt/ibm/xlf/15.1.5/bin/xlf90_r" is not able to
> compile a simple test program.
>
> It fails with the following output:
>
> Change Dir: /home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp
>
>
>
> Run Build Command:/usr/bin/gmake "cmTryCompileExec3078717336/fast"
>
> gmake[1]: Entering directory
> `/home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp'
>
>
> /usr/bin/gmake -f CMakeFiles/cmTryCompileExec3078717336.dir/build.make
> CMakeFiles/cmTryCompileExec3078717336.dir/build
>
> gmake[2]: Entering directory
> `/home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp'
>
>
> /usr/bin/cmake -E cmake_progress_report
> /home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp/CMakeFiles
> 1
>
> Building Fortran object
> CMakeFiles/cmTryCompileExec3078717336.dir/testFortranCompiler.f.o
>
> /opt/ibm/xlf/15.1.5/bin/xlf90_r -g -cpp -qxlf2003=POLYmorphic
> -qsuffix=cpp=f90 -qextname -qdirective='IBM*' -qport=typlssarg -c
> /home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp/testFortranCompiler.f
> -o CMakeFiles/cmTryCompileExec3078717336.dir/testFortranCompiler.f.o
>
> ** testfortran === End of Compilation 1 ===
>
> 1501-510 Compilation successful for file testFortranCompiler.f.
>
> Linking Fortran executable cmTryCompileExec3078717336
>
> /usr/bin/cmake -E cmake_link_script
> CMakeFiles/cmTryCompileExec3078717336.dir/link.txt --verbose=1
>
> /opt/ibm/xlf/15.1.5/bin/xlf90_r -g -cpp -qxlf2003=POLYmorphic
> -qsuffix=cpp=f90 -qextname -qdirective='IBM*' -qport=typlssarg
> CMakeFiles/cmTryCompileExec3078717336.dir/testFortranCompiler.f.o -o
> cmTryCompileExec3078717336
>
> /opt/ibm/xlf/15.1.5/bin/.orig/xlf90_r: 1501-294 (S) No input file
> specified. Please use -qhelp for more information.
>
> gmake[2]: *** [cmTryCompileExec3078717336] Error 249
>
> gmake[2]: Leaving directory
> `/home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp'
>
>
> gmake[1]: *** [cmTryCompileExec3078717336/fast] Error 2
>
> gmake[1]: Leaving directory
> `/home/lacoste/sabl/build/ppc64le_LinuxRH7.3_
> xlfCommunity_spectrummpi10.1.0/CMakeFiles/CMakeTmp'
>
> This is due to the preprocessing flags given at link time.
> I could solve it by renaming all my .f90 into .F90 files but, with cray
> compiler, I have an other issue that also need to separate link and compile
> flags.
>
> Regards,
>
> Xavier LACOSTE
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170615/c0cebb32/attachment-0001.html>
More information about the CMake
mailing list