mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
cmake: build discord-rpc internally
This commit is contained in:
parent
21774564da
commit
19c5711092
3 changed files with 77 additions and 47 deletions
|
|
@ -134,7 +134,6 @@ if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
find_package(OPENMPT REQUIRED)
|
find_package(OPENMPT REQUIRED)
|
||||||
find_package(GME REQUIRED)
|
find_package(GME REQUIRED)
|
||||||
find_package(DiscordRPC REQUIRED)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
include(LibFindMacros)
|
|
||||||
|
|
||||||
libfind_pkg_check_modules(DISCORDRPC_PKGCONF DISCORDRPC)
|
|
||||||
|
|
||||||
find_path(DISCORDRPC_INCLUDE_DIR
|
|
||||||
NAMES discord_rpc.h
|
|
||||||
PATHS
|
|
||||||
${DISCORDRPC_PKGCONF_INCLUDE_DIRS}
|
|
||||||
"/usr/include"
|
|
||||||
"/usr/local/include"
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(DISCORDRPC_LIBRARY
|
|
||||||
NAMES discord-rpc
|
|
||||||
PATHS
|
|
||||||
${DISCORDRPC_PKGCONF_LIBRARY_DIRS}
|
|
||||||
"/usr/lib"
|
|
||||||
"/usr/local/lib"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
|
|
||||||
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
|
|
||||||
libfind_process(DISCORDRPC)
|
|
||||||
|
|
||||||
if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC)
|
|
||||||
add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(
|
|
||||||
DiscordRPC::DiscordRPC
|
|
||||||
PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
74
thirdparty/CMakeLists.txt
vendored
74
thirdparty/CMakeLists.txt
vendored
|
|
@ -528,17 +528,81 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
||||||
target_link_libraries(gme PRIVATE ZLIB::ZLIB)
|
target_link_libraries(gme PRIVATE ZLIB::ZLIB)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
CPMAddPackage(
|
||||||
CPMAddPackage(
|
NAME RapidJSON
|
||||||
|
VERSION 1.1.0
|
||||||
|
URL "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz"
|
||||||
|
EXCLUDE_FROM_ALL ON
|
||||||
|
DOWNLOAD_ONLY ON
|
||||||
|
)
|
||||||
|
if(RapidJSON_ADDED)
|
||||||
|
add_library(RapidJSON INTERFACE)
|
||||||
|
add_library(RapidJSON::RapidJSON ALIAS RapidJSON)
|
||||||
|
target_include_directories(RapidJSON INTERFACE "${RapidJSON_SOURCE_DIR}/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
CPMAddPackage(
|
||||||
NAME DiscordRPC
|
NAME DiscordRPC
|
||||||
VERSION 3.4.0
|
VERSION 3.4.0
|
||||||
URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip"
|
URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip"
|
||||||
EXCLUDE_FROM_ALL ON
|
EXCLUDE_FROM_ALL ON
|
||||||
OPTIONS
|
DOWNLOAD_ONLY ON
|
||||||
"BUILD_EXAMPLES OFF"
|
)
|
||||||
|
|
||||||
|
if(DiscordRPC_ADDED)
|
||||||
|
set(DiscordRPC_SOURCES
|
||||||
|
include/discord_rpc.h
|
||||||
|
include/discord_register.h
|
||||||
|
|
||||||
|
src/discord_rpc.cpp
|
||||||
|
src/rpc_connection.h
|
||||||
|
src/rpc_connection.cpp
|
||||||
|
src/serialization.h
|
||||||
|
src/serialization.cpp
|
||||||
|
src/connection.h
|
||||||
|
src/backoff.h
|
||||||
|
src/msg_queue.h
|
||||||
)
|
)
|
||||||
target_include_directories(discord-rpc INTERFACE "${DiscordRPC_SOURCE_DIR}/include")
|
list(TRANSFORM DiscordRPC_SOURCES PREPEND "${DiscordRPC_SOURCE_DIR}/")
|
||||||
|
|
||||||
|
# Discord RPC is always statically linked because it's tiny.
|
||||||
|
add_library(discord-rpc STATIC ${DiscordRPC_SOURCES})
|
||||||
add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc)
|
add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc)
|
||||||
|
|
||||||
|
target_include_directories(discord-rpc PUBLIC "${DiscordRPC_SOURCE_DIR}/include")
|
||||||
|
target_compile_features(discord-rpc PUBLIC cxx_std_11)
|
||||||
|
target_link_libraries(discord-rpc PRIVATE RapidJSON::RapidJSON)
|
||||||
|
|
||||||
|
# Platform-specific connection and register impls
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_WINDOWS)
|
||||||
|
target_sources(discord-rpc PRIVATE
|
||||||
|
"${DiscordRPC_SOURCE_DIR}/src/connection_win.cpp"
|
||||||
|
"${DiscordRPC_SOURCE_DIR}/src/discord_register_win.cpp"
|
||||||
|
)
|
||||||
|
target_link_libraries(discord-rpc PRIVATE psapi advapi32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
target_sources(discord-rpc PRIVATE
|
||||||
|
"${DiscordRPC_SOURCE_DIR}/src/connection_unix.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_OSX)
|
||||||
|
target_sources(discord-rpc PRIVATE
|
||||||
|
"${DiscordRPC_SOURCE_DIR}/src/discord_register_osx.m"
|
||||||
|
)
|
||||||
|
target_link_libraries(discord-rpc PUBLIC "-framework AppKit")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_LINUX)
|
||||||
|
target_sources(discord-rpc PRIVATE
|
||||||
|
"${DiscordRPC_SOURCE_DIR}/src/discord_register_linux.cpp"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(tcbrindle_span)
|
add_subdirectory(tcbrindle_span)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue