[CMake] IBM Fortran and the C Preprocessor
Brad King
brad.king at kitware.com
Wed Jun 24 11:30:08 EDT 2009
Will Dicharry wrote:
> The toolchain file looks like this (the project is actually mixed
> C/Fortran code so there's some C/C++ stuff in the actual toolchain file,
> but this simple toolchain with a simple Fortran exe reproduces the
> problem):
>
> set( CMAKE_SYSTEM_NAME AIX )
> set( CMAKE_Fortran_COMPILER mpxlf90 )
> set( CMAKE_Fortran_FLAGS "-qfixed=72" CACHE STRING "" )
>
> We do this because we need a quick way to choose our compiler (cmake
> chooses GNU on this system by default, and we have to use an MPI wrapper
> compiler) and because we want those particular Fortran flags when the
> MPI wrapper compiler is being used.
The usual way to do this is
$ export FC=mpxlf90
$ export FFLAGS="-qfixed=72"
$ cmake /path/to/source
> When I use this toolchain file, the Fortran compiler ID is unknown (I
> failed to see this before, the C and CXX compiler IDs were correct).
>
> However if I comment out the set CMAKE_Fortran_FLAGS line or if I skip
> the toolchain file altogether and just pass
> -DCMAKE_Fortran_COMPILER=mpxlf90 into the cmake command, the compiler ID
> is VisualAge and everything works fine.
>
> Am I misusing the toolchain file capability?
As Bill said, the toolchain file is meant for cross compiling. It can
probably be used for normal configuration, but that is not well-tested.
I just tried something similar to your example and the compiler id check
works.
$ cat mytool.cmake
set(CMAKE_SYSTEM_NAME AIX)
set(CMAKE_Fortran_COMPILER xlf90)
set(CMAKE_Fortran_FLAGS "-q64" CACHE STRING "")
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(FOO Fortran)
add_definitions(-DTADA)
add_executable(foo foo.f)
$ mkdir b; cd b
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../mytool.cmake
-Brad
More information about the CMake
mailing list