From 2d0661c906e850f31ba59b86f0f0bbf2f2817fc7 Mon Sep 17 00:00:00 2001 From: Ben Morse Date: Fri, 5 Jan 2018 10:40:25 -0800 Subject: [PATCH] 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 --- src/CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1969ad9..c3dab48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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