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:
parent
265ea814f5
commit
2d0661c906
1 changed files with 9 additions and 7 deletions
|
@ -29,16 +29,18 @@ if(WIN32)
|
||||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
||||||
add_library(discord-rpc ${BASE_RPC_SRC})
|
add_library(discord-rpc ${BASE_RPC_SRC})
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(CRT_FLAGS)
|
|
||||||
if(USE_STATIC_CRT)
|
if(USE_STATIC_CRT)
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
foreach(CompilerFlag
|
||||||
set(CRT_FLAGS /MTd)
|
CMAKE_CXX_FLAGS
|
||||||
else()
|
CMAKE_CXX_FLAGS_DEBUG
|
||||||
set(CRT_FLAGS /MT)
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
endif()
|
CMAKE_C_FLAGS
|
||||||
|
CMAKE_C_FLAGS_DEBUG
|
||||||
|
CMAKE_C_FLAGS_RELEASE)
|
||||||
|
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
||||||
|
endforeach()
|
||||||
endif(USE_STATIC_CRT)
|
endif(USE_STATIC_CRT)
|
||||||
target_compile_options(discord-rpc PRIVATE /EHsc
|
target_compile_options(discord-rpc PRIVATE /EHsc
|
||||||
${CRT_FLAGS}
|
|
||||||
/Wall
|
/Wall
|
||||||
/wd4100 # unreferenced formal parameter
|
/wd4100 # unreferenced formal parameter
|
||||||
/wd4514 # unreferenced inline
|
/wd4514 # unreferenced inline
|
||||||
|
|
Loading…
Reference in a new issue