AW: [CMake] Selecting runtime library on Visual Studio projects
Sagnes, Frederic
frederic.sagnes at siemens.com
Tue Jul 18 04:54:40 EDT 2006
Hello Jan,
I tried this code but it doesn't work either (thank you Brad, CMAKE_COMPILER_IS_MSVC doesn't exist):
# Threads compatibility
IF ( MSVC )
MESSAGE ( STATUS "Setting MSVC MT switches")
SET (
CMAKE_CXX_FLAGS_DEBUG
"/MTd ${CMAKE_CXX_FLAGS_DEBUG}"
CACHE STRING "MSVC MT flags " FORCE
)
SET (
CMAKE_CXX_FLAGS_RELEASE
"/MT ${CMAKE_CXX_FLAGS_RELEASE}"
CACHE STRING "MSVC MT flags " FORCE
)
ENDIF ( MSVC )
What does the cache command really do that the normal way doesn't?
Whatever, it works with the cache command and doesn't without, now I have the following CMAKE_CXX_FLAGS_RELEASE variable:
/MT /MD /O2 /Ob2 /D NDEBUG
I also tested with:
/MD /O2 /Ob2 /D NDEBUG /MT
I thought VS would choose the first switch, or the last one, but in fact it seems to choose the default setting when two different switches are provided for the same setting: the final command line in VS always has the /MD switch.
Is there a way to remove the /MD* switches from the CMAKE_CXX_FLAGS_* variables and replace it with /MT* switches? I can of course overwrite the whole command with /MT*, but I will then loose the other switches (/O2 /Ob2 /D NDEBUG) and I definitely don't want that.
By the way, why does CMake specify the /MD switch as a default?
_______________________________________________
Frédéric Sagnes, A&D AS RD DH K3 Siemens AG Karlsruhe
-----Ursprüngliche Nachricht-----
Von: Jan Woetzel [mailto:jw at mip.informatik.uni-kiel.de]
Gesendet: Donnerstag, 13. Juli 2006 14:41
An: Sagnes, Frederic
Cc: cmake at cmake.org
Betreff: Re: [CMake] Selecting runtime library on Visual Studio projects
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.
More information about the CMake
mailing list