Use cmake-standard flag BUILD_SHARED_LIBS
This removes custom `BUILD_DYNAMIC_LIB` option and replaces it with a standard BUILD_SHARED_LIBS: https://cmake.org/cmake/help/v3.7/variable/BUILD_SHARED_LIBS.html Although not mentioned in the documentation there, this flag is implicitly available.
This commit is contained in:
committed by
Chris Marsh
parent
cfd6470946
commit
d121bbe709
@ -1,7 +1,6 @@
|
||||
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(BUILD_DYNAMIC_LIB "Build library as a DLL" OFF)
|
||||
|
||||
set(BASE_RPC_SRC
|
||||
${PROJECT_SOURCE_DIR}/include/discord-rpc.h
|
||||
@ -16,19 +15,16 @@ set(BASE_RPC_SRC
|
||||
msg_queue.h
|
||||
)
|
||||
|
||||
if (${BUILD_DYNAMIC_LIB})
|
||||
set(RPC_LIBRARY_TYPE SHARED)
|
||||
if (${BUILD_SHARED_LIBS})
|
||||
if(WIN32)
|
||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} dllmain.cpp)
|
||||
endif(WIN32)
|
||||
else(${BUILD_DYNAMIC_LIB})
|
||||
set(RPC_LIBRARY_TYPE STATIC)
|
||||
endif(${BUILD_DYNAMIC_LIB})
|
||||
endif(${BUILD_SHARED_LIBS})
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DDISCORD_WINDOWS)
|
||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
||||
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC})
|
||||
add_library(discord-rpc ${BASE_RPC_SRC})
|
||||
if (MSVC)
|
||||
target_compile_options(discord-rpc PRIVATE /EHsc
|
||||
/MT
|
||||
@ -60,7 +56,7 @@ if(UNIX)
|
||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_linux.cpp)
|
||||
endif(APPLE)
|
||||
|
||||
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC})
|
||||
add_library(discord-rpc ${BASE_RPC_SRC})
|
||||
target_link_libraries(discord-rpc PUBLIC pthread)
|
||||
target_compile_options(discord-rpc PRIVATE
|
||||
-g
|
||||
@ -91,10 +87,10 @@ if (NOT ${ENABLE_IO_THREAD})
|
||||
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DISABLE_IO_THREAD)
|
||||
endif (NOT ${ENABLE_IO_THREAD})
|
||||
|
||||
if (${BUILD_DYNAMIC_LIB})
|
||||
if (${BUILD_SHARED_LIBS})
|
||||
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
|
||||
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
|
||||
endif(${BUILD_DYNAMIC_LIB})
|
||||
endif(${BUILD_SHARED_LIBS})
|
||||
|
||||
add_dependencies(discord-rpc clangformat)
|
||||
|
||||
|
Reference in New Issue
Block a user