Not possible to set "/MT" or "/MTd" for Visual Studio 15 2017 generator
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(Test)
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /DFoo=1")
ADD_EXECUTABLE(test test.cpp)
create a dummy test.cpp and then
cmake -G 'Visual Studio 15 2017' .
the CMAKE_CXX_FLAGS written to the cache/project specify "/MDd" rather than "/MTd", although "Foo" successfully got set.
If you move the "SET" above project and set both "CMAKE_CXX_FLAGS_DEBUG" and "CMAKE_CXX_FLAGS_DEBUG_INIT", the "/MTd" makes it through to the project files, but not the cache, and it's still followed by an overriding "/MDd".
The same is true for the non-debug versions.
Using a combination of MESSAGE(STATUS)
and VARIABLE_WATCH
it is possible to see that the variable appears to be set correctly during the CMake run, which resulting makes the dynamic replacement suggested on the wiki/faq impossible.
I also tried using override files, to the same result.
Why is this, of all settings, impossible to modify???