I am trying to have my exe use /MTd instead of the default /MTd, but when I generate my project, it will still have /MDd in the Code Generation and Command Line
when looking at the TestFlags
property page. I have tried both a string replace and a set for CMAKE_CXX_FLAGS_DEBUG
. Is there something that I am missing?
I am attempting this with CMake 3.28.1 and Visual Studio 2022
cmake_minimum_required(VERSION 3.28)
#
project(CompileFlags CXX)
#
add_executable(TestFlags main.cpp)
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g /MTd")
# Replace /MDd with /MTd for Debug configuration
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
# Print out the debug flags
message("Debug flags: ${CMAKE_CXX_FLAGS_DEBUG}")
My output cmake output will be
Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
Debug flags: /MTd /Zi /Ob0 /Od /RTC1
Configuring done (0.0s)
Generating done (0.0s)