下面的foo改为你的实际工程名,当然也可以支持动态库项目, add_library(foo SHARED foo.c)
add_executable(foo foo.c)
set_property(TARGET foo PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET foo PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded:Release>")
其它参见 :
MSVC_RUNTIME_LIBRARY — CMake 3.19.0 Documentation