From 2311a26eb0fe81c46597f2f2826f1f45ebdd4c06 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Tue, 1 Aug 2017 13:32:56 -0700 Subject: [PATCH] Fix my dll making, also other cmake variable use --- src/CMakeLists.txt | 31 +++++++++++++++++++++---------- src/dllmain.cpp | 6 ++++++ 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/dllmain.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2145fab..6c6f482 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/dllmain.cpp b/src/dllmain.cpp new file mode 100644 index 0000000..39d7893 --- /dev/null +++ b/src/dllmain.cpp @@ -0,0 +1,6 @@ +#include + +BOOL WINAPI DllMain(HMODULE, DWORD, LPVOID) +{ + return TRUE; +}