I am trying CMake in VS2019 for the first time and am confused about how it works. This is in Windows 10 using the msvc_x64_x64 toolset.
I have a CMake project that creates a static library, which I would like to use dynamic linking. The default CMakeSettings.json includes variables
CMAKE_CXX_FLAGS_DEBUG = /MDd /Zi /Ob0 /Od /RTC1
The CMakeLists.txt's do not override this, so it looks good to me.
However, the lib file produced seems to use static linking and another project can link to it with runtime library /MTd not /MDd.
So it seems that it is getting the compiler flags from somewhere else and ignoring those in CMakeSettings.json, or there is some variable other than CMAKE_CXX_FLAGS_DEBUG.
How can I get it to use the CMakeSettings.json variables?
Here is the current CMakeSettings.json file
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_CXX_FLAGS_DEBUG",
"value": "/MDd /Zi /Ob0 /Od /RTC1",
"type": "STRING"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}