Jan Woetzel a écrit :
Sagnes, Frederic wrote:

How can I switch the default libraries (/MD and MDd switches) to the static ones (/MT and /MTd switches).
(1) The easy way is start CMakeSetup.exe or ccmake
and edit the flags by hand interactively.
(2) Inti the cache one time with different flags. See SET(... CACHE ..FORCE ...) command.
E.g.
   SET(CMAKE_CXX_FLAGS_DEBUG
     "${CMAKE_CXX_FLAGS_DEBUG} /wd4100 /wd4127 /wd4189 /wd4512 /wd4702"
     CACHE STRING "Debug builds CMAKE CXX flags " FORCE )

My suggestion is (1).

Jan.

We never use interactive building so CMakeSetup nor ccmake can be used
(builds are fully automated). So we had to find a way to do this without
user interaction and without knowledge of the compiler being used.

You can put this in your CMakeLists.txt. If the compiler you use don't have /MD flags there is no modification and so no error message about an erroneous flag (maybe a link error
depending on the build process but you can add some other lines like these).

IF (WIN32)
 FOREACH (MODE "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
   STRING(REPLACE "/MD" "/MT" TMP "${CMAKE_C_FLAGS${MODE}}")
   SET(CMAKE_C_FLAGS${MODE} "${TMP}" CACHE STRING "" FORCE)
   MESSAGE(STATUS "C_${MODE}=${CMAKE_C_FLAGS${MODE}}")
   STRING(REPLACE "/MD" "/MT" TMP "${CMAKE_CXX_FLAGS${MODE}}")
   SET(CMAKE_CXX_FLAGS${MODE} "${TMP}" CACHE STRING "" FORCE)
   MESSAGE(STATUS "CXX_${MODE}=${CMAKE_CXX_FLAGS${MODE}}")
 ENDFOREACH (MODE)
ENDIF (WIN32)


Philippe.

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to