diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-07-12 21:49:15 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-07-12 21:49:15 +0800 |
commit | 74b0178b7b4d672c7f6b317102b0ecd26f1ea033 (patch) | |
tree | 64f0f01a6b47b534c42d7f4b085b8724e639937a /indra/cmake/Discord.cmake | |
parent | b1d2961edb593393da5ae88e275be7bb2568969b (diff) |
Rich Presence support using Discord Social SDK
Download DiscordSocialSdk-1.4.9649.zip
https://discord.com/developers/applications/1393451183741599796/social-sdk/downloads
to your ~/Downloads folder.
Add -DUSE_DISCORD:BOOL=ON to your cmake line.
The authorisation is triggered by selecting Help > Discord Social.
It seems that the user will need to do this every time they want Rich
Presence support on the viewer while using Discord.
The Discord app is still set to be a public client in the OAuth2 tab,
I'm going to try to make it work with the app set to be a confidential
client, next.
All Discord-related code are contained within one file, llstartup.cpp,
and other classes access it through some opaque layer, static functions,
otherwise we'd get these "duplicate symbol" linking errors.
Diffstat (limited to 'indra/cmake/Discord.cmake')
-rw-r--r-- | indra/cmake/Discord.cmake | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/cmake/Discord.cmake b/indra/cmake/Discord.cmake new file mode 100644 index 0000000000..52c0765ae7 --- /dev/null +++ b/indra/cmake/Discord.cmake @@ -0,0 +1,45 @@ +include(Prebuilt) + +add_library(ll::discord INTERFACE IMPORTED) +target_compile_definitions(ll::discord INTERFACE LL_DISCORD=1) + +if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/discord_installed OR NOT ${discord_installed} EQUAL 0) + file(ARCHIVE_EXTRACT + INPUT $ENV{HOME}/Downloads/DiscordSocialSdk-1.4.9649.zip + DESTINATION ${CMAKE_BINARY_DIR} + ) + file( + COPY + ${CMAKE_BINARY_DIR}/discord_social_sdk/include/cdiscord.h + ${CMAKE_BINARY_DIR}/discord_social_sdk/include/discordpp.h + DESTINATION ${LIBS_PREBUILT_DIR}/include + ) + if (WINDOWS) + file( + COPY ${CMAKE_BINARY_DIR}/discord_social_sdk/bin/release/discord_partner_sdk.dll + DESTINATION ${LIBS_PREBUILT_DIR}/bin/release + ) + set(LIBRARY_EXTENSION lib) + else () + set(LIBRARY_PREFIX lib) + set(LIBRARY_EXTENSION so) + endif () + if (DARWIN) + execute_process( + COMMAND lipo + libdiscord_partner_sdk.dylib + -thin ${CMAKE_OSX_ARCHITECTURES} + -output ${ARCH_PREBUILT_DIRS_RELEASE}/libdiscord_partner_sdk.dylib + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/discord_social_sdk/lib/release + ) + else () + file( + COPY ${CMAKE_BINARY_DIR}/discord_social_sdk/lib/release/${LIBRARY_PREFIX}discord_partner_sdk.${LIBRARY_EXTENSION} + DESTINATION ${ARCH_PREBUILT_DIRS_RELEASE} + ) + endif () + file(WRITE ${PREBUILD_TRACKING_DIR}/discord_installed "0") +endif () + +target_include_directories(ll::discord SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) +target_link_libraries(ll::discord INTERFACE discord_partner_sdk) |