<div dir="ltr">The cache does *not* reveal what&#39;s actually used to generate, it reveals what was last cached. What is actually used to generate is whatever the logic in your CMakeLists files dictates. In your case, you should end up with &quot;/MT&quot; everywhere that you want to and it should work. (Verify it by looking at the settings in Visual Studio, or by doing a make VERBOSE=1 and inspecting the actual flags used to compile.)<div>
<br></div><div>Is that not the case?</div><div><br></div><div>I do a simple loop through the variables of interest and use STRING REGEX REPLACE to change /MD into /MT. Something like this (writing without running it, forgive if there are any typos):</div>
<div><br></div><div>foreach(flag_var CMAKE_CXX_FLAGS_DEBUG ...... other variables here too ...... )</div><div>&nbsp;&nbsp;if(${flag_var} MATCHES &quot;/MD&quot;)</div><div>&nbsp;&nbsp; &nbsp;string(REGEX REPLACE &quot;/MD&quot; &quot;/MT&quot; ${flag_var} &quot;${${flag_var}}&quot;)</div>
<div>&nbsp;&nbsp;endif(${flag_var} MATCHES &quot;/MD&quot;)</div><div>endforeach(flag_var)<br><br></div><div><br></div><div>Let us know how you make out....</div><div><br></div><div>David</div><div><br></div><div><br></div><div><br>
<div class="gmail_quote">On Fri, Sep 5, 2008 at 8:45 PM, McKay Davis <span dir="ltr">&lt;<a href="mailto:mckay.cpp@gmail.com">mckay.cpp@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">My setup: Win XP, VS 9 2008 Express, CMake 2.6.1<br><br>I&#39;m having trouble getting cmake to generate nmakefiles (or VS solutions) w/ the static C/C++ runtime lib flags.&nbsp; I cannot figure out how to pass the &#39;/MT&#39; flag (and NOT the /MD flag) to cl.exe.<br>

<br>My CMakeLists.txt is simple, with one directory, one lib, and one executable.&nbsp; It contains copies of lines 201-210 of share/cmake-2.6/Modules/Platform/Windows-cl.cmake with the FORCE flag set: <br><br>SET (CMAKE_CXX_FLAGS_INIT &quot;/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR&quot; CACHE STRING &quot;flags&quot; FORCE)<br>

SET (CMAKE_CXX_FLAGS_DEBUG_INIT &quot;/D_DEBUG /MTd /Zi&nbsp; /Ob0 /Od /GZ&quot; CACHE STRING &quot;flags&quot; FORCE)<br>SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT &quot;/MT /O1 /Ob1 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>

SET (CMAKE_CXX_FLAGS_RELEASE_INIT &quot;/MT /O2 /Ob2 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT &quot;/MT /Zi /O2 /Ob1 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>

SET (CMAKE_C_FLAGS_INIT &quot;/DWIN32 /D_WINDOWS /W3 /Zm1000&quot; CACHE STRING &quot;flags&quot; FORCE)<br>SET (CMAKE_C_FLAGS_DEBUG_INIT &quot;/D_DEBUG /MTd /Zi&nbsp; /Ob0 /Od /GZ&quot; CACHE STRING &quot;flags&quot; FORCE)<br>

SET (CMAKE_C_FLAGS_MINSIZEREL_INIT &quot;/MT /O1 /Ob1 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>SET (CMAKE_C_FLAGS_RELEASE_INIT &quot;/MT /O2 /Ob2 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT &quot;/MT /Zi /O2 /Ob1 /D NDEBUG&quot; CACHE STRING &quot;flags&quot; FORCE)<br>

<br>These seem to only affect the *_INIT vars, because after running cmake inspecting the cache reveals:<br><br>&gt; grep ^CMAKE_CX*_FLAGS CMakeCache.txt&#39;<br><br>CMAKE_CXX_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR<br>

CMAKE_CXX_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1<br>CMAKE_CXX_FLAGS_DEBUG_INIT:STRING=/D_DEBUG /MTd /Zi&nbsp; /Ob0 /Od /GZ<br>CMAKE_CXX_FLAGS_INIT:STRING=/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR<br>CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /D NDEBUG<br>

CMAKE_CXX_FLAGS_MINSIZEREL_INIT:STRING=/MT /O1 /Ob1 /D NDEBUG<br>CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /D NDEBUG<br>CMAKE_CXX_FLAGS_RELEASE_INIT:STRING=/MT /O2 /Ob2 /D NDEBUG<br>CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /D NDEBUG<br>

CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT:STRING=/MT /Zi /O2 /Ob1 /D NDEBUG<br>CMAKE_C_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3 /Zm1000<br>CMAKE_C_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi&nbsp; /Ob0 /Od /RTC1<br>CMAKE_C_FLAGS_DEBUG_INIT:STRING=/D_DEBUG /MTd /Zi&nbsp; /Ob0 /Od /GZ<br>

CMAKE_C_FLAGS_INIT:STRING=/DWIN32 /D_WINDOWS /W3 /Zm1000<br>CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /D NDEBUG<br>CMAKE_C_FLAGS_MINSIZEREL_INIT:STRING=/MT /O1 /Ob1 /D NDEBUG<br>CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /D NDEBUG<br>

CMAKE_C_FLAGS_RELEASE_INIT:STRING=/MT /O2 /Ob2 /D NDEBUG<br>CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /D NDEBUG<br>CMAKE_C_FLAGS_RELWITHDEBINFO_INIT:STRING=/MT /Zi /O2 /Ob1 /D NDEBUG<br>...<br><br>What should I do to get cmake to build w/ the static C runtime libs?<br>

<br>Thanks,<br><br>-McKay Davis<br><br></div>
<br>_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div></div>