include(Prebuilt) include_guard() option(USE_DISCORD "Enable Discord SDK" OFF) if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/discord_sdk_installed OR NOT ${discord_sdk_installed} EQUAL 0) if (${LINUX_DISTRO} MATCHES gentoo) set(PREFIX_PATH /var/cache/distfiles) else () set(PREFIX_PATH $ENV{HOME}/Downloads) endif () file(ARCHIVE_EXTRACT INPUT ${PREFIX_PATH}/DiscordSocialSdk-1.10.19337.zip DESTINATION ${CMAKE_BINARY_DIR} ) file(MAKE_DIRECTORY ${LIBS_PREBUILT_DIR}/include/discord_sdk) 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/discord_sdk ) if ($ENV{MSYSTEM_CARCH} MATCHES aarch64) set(DISCORD_PLATFORM /arm64) endif () if (WINDOWS) file( COPY ${CMAKE_BINARY_DIR}/discord_social_sdk/bin/release${DISCORD_PLATFORM}/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${DISCORD_PLATFORM}/${LIBRARY_PREFIX}discord_partner_sdk.${LIBRARY_EXTENSION} DESTINATION ${ARCH_PREBUILT_DIRS_RELEASE} ) if (CMAKE_BUILD_TYPE MATCHES Release AND LINUX) execute_process( COMMAND ${CMAKE_STRIP} libdiscord_partner_sdk.so WORKING_DIRECTORY ${ARCH_PREBUILT_DIRS_RELEASE} ) endif () endif () file(WRITE ${PREBUILD_TRACKING_DIR}/discord_sdk_installed "0") endif () if(USE_DISCORD) add_library(ll::discord_sdk INTERFACE IMPORTED) target_compile_definitions(ll::discord_sdk INTERFACE LL_DISCORD=1) #use_prebuilt_binary(discord_sdk) find_library(DISCORD_SDK_LIBRARY NAMES discord_partner_sdk discord_partner_sdk.lib libdiscord_partner_sdk.so libdiscord_partner_sdk.dylib PATHS "${ARCH_PREBUILT_DIRS_ARCH_RELEASE}" "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) target_include_directories(ll::discord_sdk SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/discord_sdk) target_link_libraries(ll::discord_sdk INTERFACE ${DISCORD_SDK_LIBRARY}) endif()