src/third-party/discord-rpc/src/CMakeLists.txt (view raw)
1include_directories(${PROJECT_SOURCE_DIR}/include)
2
3option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON)
4option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF)
5option(WARNINGS_AS_ERRORS "When enabled, compiles with `-Werror` (on *nix platforms)." OFF)
6
7set(CMAKE_CXX_STANDARD 14)
8
9set(BASE_RPC_SRC
10 ${PROJECT_SOURCE_DIR}/include/discord_rpc.h
11 discord_rpc.cpp
12 ${PROJECT_SOURCE_DIR}/include/discord_register.h
13 rpc_connection.h
14 rpc_connection.cpp
15 serialization.h
16 serialization.cpp
17 connection.h
18 backoff.h
19 msg_queue.h
20)
21
22if(WIN32)
23 add_definitions(-DDISCORD_WINDOWS)
24 set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
25 if (NOT MSVC)
26 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include/mingw-std-threads)
27 endif()
28 add_library(discord-rpc STATIC ${BASE_RPC_SRC})
29 if (MSVC)
30 if(USE_STATIC_CRT)
31 foreach(CompilerFlag
32 CMAKE_CXX_FLAGS
33 CMAKE_CXX_FLAGS_DEBUG
34 CMAKE_CXX_FLAGS_RELEASE
35 CMAKE_C_FLAGS
36 CMAKE_C_FLAGS_DEBUG
37 CMAKE_C_FLAGS_RELEASE)
38 string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
39 endforeach()
40 endif(USE_STATIC_CRT)
41 target_compile_options(discord-rpc PRIVATE /EHsc
42 /Wall
43 /wd4100 # unreferenced formal parameter
44 /wd4514 # unreferenced inline
45 /wd4625 # copy constructor deleted
46 /wd5026 # move constructor deleted
47 /wd4626 # move assignment operator deleted
48 /wd4668 # not defined preprocessor macro
49 /wd4710 # function not inlined
50 /wd4711 # function was inlined
51 /wd4820 # structure padding
52 /wd4946 # reinterpret_cast used between related classes
53 /wd5027 # move assignment operator was implicitly defined as deleted
54 )
55 endif(MSVC)
56 target_link_libraries(discord-rpc PRIVATE psapi advapi32)
57endif(WIN32)
58
59if(UNIX)
60 set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_unix.cpp)
61
62 if (APPLE)
63 add_definitions(-DDISCORD_OSX)
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
65 set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_osx.m)
66 else (APPLE)
67 add_definitions(-DDISCORD_LINUX)
68 set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_linux.cpp)
69 endif(APPLE)
70
71 add_library(discord-rpc STATIC ${BASE_RPC_SRC})
72 target_link_libraries(discord-rpc PUBLIC pthread)
73
74 if (${WARNINGS_AS_ERRORS})
75 target_compile_options(discord-rpc PRIVATE -Werror)
76 endif (${WARNINGS_AS_ERRORS})
77
78 if (${BUILD_SHARED_LIBS})
79 target_compile_options(discord-rpc PRIVATE -fPIC)
80 endif (${BUILD_SHARED_LIBS})
81
82 if (APPLE)
83 target_link_libraries(discord-rpc PRIVATE "-framework AppKit")
84 endif (APPLE)
85endif(UNIX)
86
87if (NOT ${ENABLE_IO_THREAD})
88 target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DISABLE_IO_THREAD)
89endif (NOT ${ENABLE_IO_THREAD})