On 06/25/2009 06:47 AM, Maik Beckmann wrote:
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


If you add /libs:dll to all build types, then you can take /MD out of CMAKE_Fortran_FLAGS_RELEASE_INIT. I had the same problem as you, and an almost identical patch sumbitted here: http://public.kitware.com/Bug/view.php?id=8744

Clint


_______________________________________________
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

Reply via email to