... | ... | @@ -86,7 +86,7 @@ |
|
|
* [How can I build my MSVC application with a static runtime?](#how-can-i-build-my-msvc-application-with-a-static-runtime)
|
|
|
+ [Manual Replace](#manual-replace)
|
|
|
+ [Make Override Files](#make-override-files)
|
|
|
+ [Dynamic Replace](#dynamic-replace)
|
|
|
+ [Override CMAKE_MSVC_RUNTIME_LIBRARY](#override-cmake_msvc_runtime_library)
|
|
|
* [Why do generated Xcode projects have a CMake PostBuild Rules phase?](#why-do-generated-xcode-projects-have-a-cmake-postbuild-rules-phase)
|
|
|
* [Why does CMake not find my Xcode compiler on OS X with the Unix Makefiles generator?](#why-does-cmake-not-find-my-xcode-compiler-on-os-x-with-the-unix-makefiles-generator)
|
|
|
- [Other Questions](#other-questions)
|
... | ... | @@ -1953,24 +1953,18 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX |
|
|
project(Bar)
|
|
|
```
|
|
|
|
|
|
#### Dynamic Replace
|
|
|
#### Override CMAKE_MSVC_RUNTIME_LIBRARY
|
|
|
|
|
|
Alternatively, if you need dynamic control of `/MT` via some configure
|
|
|
option you could use the following technique. Note:
|
|
|
`CMAKE_CXX_FLAGS_<FOO>` is a directory level option, however. Also,
|
|
|
this option has the downside of leaving `/MD` visible in the cache editor
|
|
|
although it has no effect.
|
|
|
option you could use set the `CMAKE_MSVC_RUNTIME_LIBRARY` variable.
|
|
|
Note: `CMAKE_MSVC_RUNTIME_LIBRARY` is a directory level option, however.
|
|
|
|
|
|
```cmake
|
|
|
foreach(flag_var
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
endif()
|
|
|
endforeach()
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
|
```
|
|
|
|
|
|
You could also change the `MSVC_RUNTIME_LIBRARY` property of your target.
|
|
|
|
|
|
### Why do generated Xcode projects have a CMake PostBuild Rules phase?
|
|
|
|
|
|
CMake needs precise control over target link command lines that Xcode
|
... | ... | |