Add option for building with /MT

This commit is contained in:
Ted John 2017-11-13 17:22:45 +00:00 committed by Chris Marsh
parent 5085d23dd1
commit 704c56d13f
2 changed files with 13 additions and 2 deletions

View File

@ -73,9 +73,9 @@ def main(clean):
generator64 = 'Visual Studio 14 2015 Win64'
build_lib('win32-static', generator32, {})
build_lib('win32-dynamic', generator32, {'BUILD_SHARED_LIBS': True})
build_lib('win32-dynamic', generator32, {'BUILD_SHARED_LIBS': True, 'USE_STATIC_CRT': True})
build_lib('win64-static', generator64, {})
build_lib('win64-dynamic', generator64, {'BUILD_SHARED_LIBS': True})
build_lib('win64-dynamic', generator64, {'BUILD_SHARED_LIBS': True, 'USE_STATIC_CRT': True})
# todo: this in some better way
src_dll = os.path.join(SCRIPT_PATH, 'builds', 'win64-dynamic', 'src', 'Release', 'discord-rpc.dll')

View File

@ -1,6 +1,7 @@
include_directories(${PROJECT_SOURCE_DIR}/include)
option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON)
option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF)
set(BASE_RPC_SRC
${PROJECT_SOURCE_DIR}/include/discord-rpc.h
@ -22,11 +23,21 @@ if (${BUILD_SHARED_LIBS})
endif(${BUILD_SHARED_LIBS})
if(WIN32)
set(CRT_FLAGS)
if(USE_STATIC_CRT)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CRT_FLAGS /MTd)
else()
set(CRT_FLAGS /MT)
endif()
endif(USE_STATIC_CRT)
add_definitions(-DDISCORD_WINDOWS)
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
add_library(discord-rpc ${BASE_RPC_SRC})
if (MSVC)
target_compile_options(discord-rpc PRIVATE /EHsc
${CRT_FLAGS}
/Wall
/wd4100 # unreferenced formal parameter
/wd4514 # unreferenced inline