force /MDd /MTd ...

down vote accepted

You can modify the CMAKE_CXX_FLAGS_<Build Type> and/orCMAKE_C_FLAGS_<Build Type>variables:

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

If your CMake flags already contain/MD, you can ensure that the above commands are executed after the point at which/MDis inserted (the later addition of/MToverrides the conflicting existing option), or you can set the flags from scratch:

set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")

Or alternatively, you could replace the existing/MDand/MDdvalues with/MTand/MTdrespectively by doing something like:

set(CompilerFlags
        CMAKE_CXX_FLAGS
        CMAKE_CXX_FLAGS_DEBUG
        CMAKE_CXX_FLAGS_RELEASE
        CMAKE_C_FLAGS
        CMAKE_C_FLAGS_DEBUG
        CMAKE_C_FLAGS_RELEASE
        )
foreach(CompilerFlag ${CompilerFlags})
  string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()

你可能感兴趣的:(force /MDd /MTd ...)