From ffe5ece0582dcb2a363528c4ea044da0bb16fb4e Mon Sep 17 00:00:00 2001 From: WLs50 Date: Mon, 17 Mar 2025 07:19:07 +0100 Subject: [PATCH] wrap discord rpc as optional feature --- CMakeLists.txt | 13 ++++++++++--- Globals.h | 1 - application.cpp | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b6c507..7ceff26f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ option(WITH_LUA "Compile with lua scripting support" ON) option(WITH_OPENVR "Compile with OpenVR" ON) option(WITH_ZMQ "Compile with cppzmq" OFF) option(WITH_CRASHPAD "Compile with crashpad" OFF) +option(WITH_DISCORD_RPC "Compile with DISCORD RICH PRESENCE" OFF) option(USE_LTO "Use link-time optimization" OFF) option(WITH_LIBMANUL "Experimental multi-backend renderer" OFF) @@ -444,9 +445,15 @@ target_link_libraries(${PROJECT_NAME} Threads::Threads) find_package(GLM REQUIRED) target_include_directories(${PROJECT_NAME} PRIVATE ${GLM_INCLUDE_DIR}) -# add ref/discord-rpc to the project in the same way other dependencies are added -add_subdirectory(ref/discord-rpc) -target_link_libraries(${PROJECT_NAME} discord-rpc) + +if (WITH_DISCORD_RPC) + # add ref/discord-rpc to the project in the same way other dependencies are added + add_subdirectory(ref/discord-rpc) + target_link_libraries(${PROJECT_NAME} discord-rpc) + target_compile_definitions(${PROJECT_NAME} "WITH_DISCORD_RPC=1") +elseif () + target_compile_definitions(${PROJECT_NAME} "WITH_DISCORD_RPC=0") +endif () diff --git a/Globals.h b/Globals.h index 5142c602..36275d67 100644 --- a/Globals.h +++ b/Globals.h @@ -16,7 +16,6 @@ http://mozilla.org/MPL/2.0/. #include "light.h" #include "utilities.h" #include "motiontelemetry.h" -#include "ref/discord-rpc/include/discord_rpc.h" #include #ifdef WITH_UART diff --git a/application.cpp b/application.cpp index 9e63ce3d..c6efdc6b 100644 --- a/application.cpp +++ b/application.cpp @@ -29,7 +29,11 @@ http://mozilla.org/MPL/2.0/. #include "Timer.h" #include "dictionary.h" #include "version_info.h" -#include "ref/discord-rpc/include/discord_rpc.h" + +#if WITH_DISCORD_RPC +#include +#endif + #include #include "translation.h" @@ -179,6 +183,7 @@ int eu07_application::run_crashgui() } void eu07_application::DiscordRPCService() { +#if WITH_DISCORD_RPC // initialize discord-rpc WriteLog("Initializing Discord Rich Presence..."); static const char *discord_app_id = "1343662664504840222"; @@ -253,6 +258,7 @@ void eu07_application::DiscordRPCService() } std::this_thread::sleep_for(std::chrono::milliseconds(5000)); // update RPC every 5 secs } +#endif } int