fix debug build with static crt

CMAKE_BUILD_TYPE is not set at configuration time, so we can't test
against it.  So, we string-replace /MD with /MT in the c[xx] flags for
the different targets.  CF:

https://stackoverflow.com/questions/14172856/cmake-compile-with-mt-instead-of-md
This commit is contained in:
Ben Morse 2018-01-05 10:40:25 -08:00
parent 265ea814f5
commit 2d0661c906

View file

@ -29,16 +29,18 @@ if(WIN32)
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
add_library(discord-rpc ${BASE_RPC_SRC})
if (MSVC)
set(CRT_FLAGS)
if(USE_STATIC_CRT)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CRT_FLAGS /MTd)
else()
set(CRT_FLAGS /MT)
endif()
foreach(CompilerFlag
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE)
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif(USE_STATIC_CRT)
target_compile_options(discord-rpc PRIVATE /EHsc
${CRT_FLAGS}
/Wall
/wd4100 # unreferenced formal parameter
/wd4514 # unreferenced inline