[CMake] [Fortran] Default flags for ifort on windows (and mxing C and Fortran)

Maik Beckmann beckmann.maik at googlemail.com
Thu Jun 25 08:47:56 EDT 2009


Hello,

Right now mixing Fortran and C compiled with respectively ifort and cl on 
windows doesn't work out of the box.  The reason for this is conflicting 
runtime libraries.

The default for cl and ifort is, without any flags given, to use LIBC.lib.  
This the static single threaded version. 

CMake by default adds flags to the CMAKE_*_FLAGS to let cl use the MSVCRT.lib 
or MSVCRTD.lib (namely /MD or /MDd) 

These adjustments are not done for the ifort compiler (except for the 
"Release" build type where /MD is used :P ) so mixing sources causes LINK2005 
errors (already defined symbols).

What about altering
  SET (CMAKE_Fortran_FLAGS_INIT "/W1 /nologo /fpp")
  SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "/debug:full")
  SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O2 /D NDEBUG")
  SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "/MD /O1 /D NDEBUG")
  SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O1 /debug:full /D NDEBUG")
to
  SET (CMAKE_Fortran_FLAGS_INIT "/W1 /nologo /fpp /libs:dll /threads")
  SET (CMAKE_Fortran_FLAGS_DEBUG_INIT "/debug:full /dbglibs")
  SET (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O2 /D NDEBUG")
  SET (CMAKE_Fortran_FLAGS_RELEASE_INIT "/MD /O1 /D NDEBUG")
  SET (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O1 /debug:full /D NDEBUG")
in Windows-ifort.cmake, The would let ifort behave the same as cl on windows, 
since
   /threads /libs:dll <=> /MD
and 
  /threads /libs:dll /dbglibs <=> /MDd


Regards,
 -- Maik


More information about the CMake mailing list