[CMake] IBM Fortran and the C Preprocessor

Brad King brad.king at kitware.com
Tue Jun 23 18:11:45 EDT 2009


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}")

-Brad


More information about the CMake mailing list