Brad King wrote:
Will Dicharry wrote:It appears that add_definitions() places -DWHATEVER in the compile command line on all Unix variants. Unfortunately, IBM's Fortran compiler uses -D as a compile flag for something other than adding a preprocessor definition. In order to pass a preprocessor definition, you have to use -WF,-DWHATEVER.What version of CMake are you using? This should work in 2.6.4 (and perhaps earlier 2.6.x but I don't remember). There is a platform configuration variable called "CMAKE_Fortran_DEFINE_FLAG" which is set to "-WF,-D" for that compiler. Add this to your project to see how the platform is set: message("CMAKE_Fortran_DEFINE_FLAG=${CMAKE_Fortran_DEFINE_FLAG}") message("CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}")
It turns out this is a little stranger than I originally thought. We use a toolchain file to specify the compiler for the system we're on. The toolchain file looks like this (the project is actually mixedC/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 (cmakechooses 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. 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? Thanks, Will -- Will Dicharry Software Developer Stellar Science Ltd Co
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
