Fix my dll making, also other cmake variable use

This commit is contained in:
Chris Marsh 2017-08-01 13:32:56 -07:00
parent 67a81b82cd
commit 2311a26eb0
2 changed files with 27 additions and 10 deletions

View file

@ -3,17 +3,28 @@ 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)
if (${ENABLE_IO_THREAD} EQUAL OFF)
if (NOT ${ENABLE_IO_THREAD})
add_definitions(-DDISCORD_DISABLE_IO_THREAD)
endif (${ENABLE_IO_THREAD} EQUAL OFF)
endif (NOT ${ENABLE_IO_THREAD})
if (${BUILD_DYNAMIC_LIB} EQUAL ON)
set(RPC_LIBRARY_TYPE DYNAMIC)
else(${BUILD_DYNAMIC_LIB} EQUAL ON)
set(BASE_RPC_SRC
${PROJECT_SOURCE_DIR}/include/discord-rpc.h
discord-rpc.cpp
discord-register.cpp
rpc_connection.h
rpc_connection.cpp
serialization.h
serialization.cpp
connection.h
backoff.h
)
if (${BUILD_DYNAMIC_LIB})
set(RPC_LIBRARY_TYPE SHARED)
set(BASE_RPC_SRC ${BASE_RPC_SRC} dllmain.cpp)
else(${BUILD_DYNAMIC_LIB})
set(RPC_LIBRARY_TYPE STATIC)
endif(${BUILD_DYNAMIC_LIB} EQUAL ON)
set(BASE_RPC_SRC ${PROJECT_SOURCE_DIR}/include/discord-rpc.h discord-rpc.cpp discord-register.cpp rpc_connection.h rpc_connection.cpp serialization.h serialization.cpp connection.h backoff.h)
endif(${BUILD_DYNAMIC_LIB})
if(WIN32)
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC} connection_win.cpp)
@ -28,10 +39,10 @@ endif(UNIX)
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include)
if (${BUILD_DYNAMIC_LIB} EQUAL ON)
if (${BUILD_DYNAMIC_LIB})
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
endif(${BUILD_DYNAMIC_LIB} EQUAL ON)
endif(${BUILD_DYNAMIC_LIB})
add_dependencies(discord-rpc clangformat)

6
src/dllmain.cpp Normal file
View file

@ -0,0 +1,6 @@
#include <windows.h>
BOOL WINAPI DllMain(HMODULE, DWORD, LPVOID)
{
return TRUE;
}