-#Ignore MSVCRT.lib on WIN32 in case using f2c code generator
-IF(WIN32 AND ${F2C_FOUND})
- SET_TARGET_PROPERTIES(MEFISTO2D PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
-ENDIF(WIN32 AND ${F2C_FOUND})
+#Ignore MSVCRT.lib on WINDOWS in case using f2c code generator
+IF(WIN32)
+ IF(CMAKE_BUILD_TYPE STREQUAL Debug)
+ IF(${F2C_FOUND})
+ SET_TARGET_PROPERTIES(MEFISTO2D PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
+ ENDIF(${F2C_FOUND})
+ ENDIF()
+ENDIF(WIN32)