2017-06-30 12:00:45 -07:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
2017-06-30 16:18:54 -07:00
|
|
|
|
2017-07-25 13:40:30 -07:00
|
|
|
option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON)
|
2017-11-13 17:22:45 +00:00
|
|
|
option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF)
|
2018-05-10 17:46:11 -07:00
|
|
|
option(WARNINGS_AS_ERRORS "When enabled, compiles with `-Werror` (on *nix platforms)." OFF)
|
2017-07-25 13:40:30 -07:00
|
|
|
|
2017-11-15 20:04:42 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
|
|
2017-08-01 13:32:56 -07:00
|
|
|
set(BASE_RPC_SRC
|
2018-02-27 13:33:00 -08:00
|
|
|
${PROJECT_SOURCE_DIR}/include/discord_rpc.h
|
|
|
|
|
discord_rpc.cpp
|
2018-02-02 01:42:17 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/include/discord_register.h
|
2017-08-01 13:32:56 -07:00
|
|
|
rpc_connection.h
|
|
|
|
|
rpc_connection.cpp
|
|
|
|
|
serialization.h
|
|
|
|
|
serialization.cpp
|
|
|
|
|
connection.h
|
|
|
|
|
backoff.h
|
2017-10-12 13:06:55 -07:00
|
|
|
msg_queue.h
|
2017-08-01 13:32:56 -07:00
|
|
|
)
|
2017-07-25 13:40:30 -07:00
|
|
|
|
2017-11-12 23:19:27 +01:00
|
|
|
if (${BUILD_SHARED_LIBS})
|
2017-09-14 08:59:32 -07:00
|
|
|
if(WIN32)
|
|
|
|
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} dllmain.cpp)
|
|
|
|
|
endif(WIN32)
|
2017-11-12 23:19:27 +01:00
|
|
|
endif(${BUILD_SHARED_LIBS})
|
2017-06-30 16:18:54 -07:00
|
|
|
|
|
|
|
|
if(WIN32)
|
2017-09-14 08:59:32 -07:00
|
|
|
add_definitions(-DDISCORD_WINDOWS)
|
|
|
|
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
2017-11-12 23:19:27 +01:00
|
|
|
add_library(discord-rpc ${BASE_RPC_SRC})
|
2017-11-14 16:03:07 +01:00
|
|
|
if (MSVC)
|
2017-11-15 23:19:30 +00:00
|
|
|
if(USE_STATIC_CRT)
|
2018-01-05 10:40:25 -08:00
|
|
|
foreach(CompilerFlag
|
|
|
|
|
CMAKE_CXX_FLAGS
|
|
|
|
|
CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
|
CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
|
CMAKE_C_FLAGS
|
|
|
|
|
CMAKE_C_FLAGS_DEBUG
|
|
|
|
|
CMAKE_C_FLAGS_RELEASE)
|
|
|
|
|
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
|
|
|
|
endforeach()
|
2017-11-15 23:19:30 +00:00
|
|
|
endif(USE_STATIC_CRT)
|
|
|
|
|
target_compile_options(discord-rpc PRIVATE /EHsc
|
|
|
|
|
/Wall
|
|
|
|
|
/wd4100 # unreferenced formal parameter
|
|
|
|
|
/wd4514 # unreferenced inline
|
|
|
|
|
/wd4625 # copy constructor deleted
|
|
|
|
|
/wd5026 # move constructor deleted
|
|
|
|
|
/wd4626 # move assignment operator deleted
|
|
|
|
|
/wd4668 # not defined preprocessor macro
|
|
|
|
|
/wd4710 # function not inlined
|
|
|
|
|
/wd4711 # function was inlined
|
|
|
|
|
/wd4820 # structure padding
|
|
|
|
|
/wd4946 # reinterpret_cast used between related classes
|
|
|
|
|
/wd5027 # move assignment operator was implicitly defined as deleted
|
|
|
|
|
)
|
2017-11-14 16:03:07 +01:00
|
|
|
endif(MSVC)
|
2018-03-13 21:00:47 +01:00
|
|
|
target_link_libraries(discord-rpc PRIVATE psapi advapi32)
|
2017-06-30 16:18:54 -07:00
|
|
|
endif(WIN32)
|
2017-07-13 08:32:08 -07:00
|
|
|
|
2017-07-13 10:08:14 -07:00
|
|
|
if(UNIX)
|
2017-09-14 08:59:32 -07:00
|
|
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_unix.cpp)
|
2017-10-12 16:08:08 -07:00
|
|
|
|
2017-09-14 08:59:32 -07:00
|
|
|
if (APPLE)
|
|
|
|
|
add_definitions(-DDISCORD_OSX)
|
|
|
|
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_osx.m)
|
|
|
|
|
else (APPLE)
|
|
|
|
|
add_definitions(-DDISCORD_LINUX)
|
|
|
|
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_linux.cpp)
|
|
|
|
|
endif(APPLE)
|
|
|
|
|
|
2017-11-12 23:19:27 +01:00
|
|
|
add_library(discord-rpc ${BASE_RPC_SRC})
|
2017-07-27 15:09:05 -07:00
|
|
|
target_link_libraries(discord-rpc PUBLIC pthread)
|
2017-10-12 16:08:08 -07:00
|
|
|
target_compile_options(discord-rpc PRIVATE
|
|
|
|
|
-g
|
2017-11-09 21:05:14 +01:00
|
|
|
-Wall
|
2017-11-09 22:00:33 +01:00
|
|
|
-Wextra
|
|
|
|
|
-Wpedantic
|
2018-05-10 17:46:11 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (${WARNINGS_AS_ERRORS})
|
|
|
|
|
target_compile_options(discord-rpc PRIVATE -Werror)
|
|
|
|
|
endif (${WARNINGS_AS_ERRORS})
|
|
|
|
|
|
|
|
|
|
target_compile_options(discord-rpc PRIVATE
|
2017-10-12 16:08:08 -07:00
|
|
|
-Wno-unknown-pragmas # pragma push thing doesn't work on clang
|
|
|
|
|
-Wno-old-style-cast # it's fine
|
|
|
|
|
-Wno-c++98-compat # that was almost 2 decades ago
|
|
|
|
|
-Wno-c++98-compat-pedantic
|
|
|
|
|
-Wno-missing-noreturn
|
|
|
|
|
-Wno-padded # structure padding
|
|
|
|
|
-Wno-covered-switch-default
|
|
|
|
|
-Wno-exit-time-destructors # not sure about these
|
|
|
|
|
-Wno-global-constructors
|
|
|
|
|
)
|
2017-09-14 08:59:32 -07:00
|
|
|
|
2017-11-12 23:25:53 +01:00
|
|
|
if (${BUILD_SHARED_LIBS})
|
|
|
|
|
target_compile_options(discord-rpc PRIVATE -fPIC)
|
|
|
|
|
endif (${BUILD_SHARED_LIBS})
|
|
|
|
|
|
2017-09-14 08:59:32 -07:00
|
|
|
if (APPLE)
|
|
|
|
|
target_link_libraries(discord-rpc PRIVATE "-framework AppKit")
|
|
|
|
|
endif (APPLE)
|
2017-07-13 10:08:14 -07:00
|
|
|
endif(UNIX)
|
2017-07-17 09:28:54 -07:00
|
|
|
|
2017-07-18 14:29:54 -07:00
|
|
|
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include)
|
2017-07-25 10:15:42 -07:00
|
|
|
|
2017-09-07 09:05:41 -07:00
|
|
|
if (NOT ${ENABLE_IO_THREAD})
|
2017-11-12 03:29:22 +01:00
|
|
|
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DISABLE_IO_THREAD)
|
2017-09-07 09:05:41 -07:00
|
|
|
endif (NOT ${ENABLE_IO_THREAD})
|
|
|
|
|
|
2017-11-12 23:19:27 +01:00
|
|
|
if (${BUILD_SHARED_LIBS})
|
2017-07-31 15:58:39 -07:00
|
|
|
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
|
|
|
|
|
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
|
2017-11-12 23:19:27 +01:00
|
|
|
endif(${BUILD_SHARED_LIBS})
|
2017-07-31 15:58:39 -07:00
|
|
|
|
2017-11-29 09:50:22 -08:00
|
|
|
if (CLANG_FORMAT_CMD)
|
|
|
|
|
add_dependencies(discord-rpc clangformat)
|
|
|
|
|
endif(CLANG_FORMAT_CMD)
|
2017-07-25 16:00:12 -07:00
|
|
|
|
|
|
|
|
# install
|
|
|
|
|
|
|
|
|
|
install(
|
|
|
|
|
TARGETS discord-rpc
|
|
|
|
|
EXPORT "discord-rpc"
|
2017-09-07 09:05:41 -07:00
|
|
|
RUNTIME
|
2017-11-16 11:48:50 +01:00
|
|
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
2017-09-07 09:05:41 -07:00
|
|
|
LIBRARY
|
2017-11-16 11:48:50 +01:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
2017-09-07 09:05:41 -07:00
|
|
|
ARCHIVE
|
2017-11-16 11:48:50 +01:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
2017-09-07 09:05:41 -07:00
|
|
|
INCLUDES
|
2017-11-16 11:48:50 +01:00
|
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
2017-07-25 16:00:12 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
install(
|
|
|
|
|
FILES
|
2018-02-27 13:33:00 -08:00
|
|
|
"../include/discord_rpc.h"
|
2018-02-02 01:42:17 +01:00
|
|
|
"../include/discord_register.h"
|
2017-07-25 16:00:12 -07:00
|
|
|
DESTINATION "include"
|
2017-10-12 15:38:15 -07:00
|
|
|
)
|