Support building universal binaries with discord

For now only x86-64 is supported by discord sdk, arm64 we ship without
discord sdk. So players can choose if they want more performance without
discord integration, or less performance with discord integration.
This commit is contained in:
def 2021-12-20 16:06:55 +01:00
parent 61432c9813
commit 440baa17be
5 changed files with 17 additions and 10 deletions

View file

@ -54,7 +54,6 @@ else()
set(TARGET_BITS "64")
endif()
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
if(TARGET_BITS STREQUAL "32")
set(TARGET_CPU_ARCHITECTURE "arm")
@ -69,7 +68,6 @@ else()
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_OS "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@ -460,11 +458,11 @@ if(TARGET_OS AND TARGET_OS STREQUAL "mac")
endif()
message(STATUS "******** DDNet ********")
if(NOT TARGET_OS STREQUAL "mac")
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit")
else()
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit (SDK: ${CMAKE_OSX_SYSROOT}, architectures: ${CMAKE_OSX_ARCHITECTURES})")
set(TARGET "Target OS: ${TARGET_OS} ${CMAKE_SYSTEM_PROCESSOR}")
if(TARGET_OS STREQUAL "mac")
set(TARGET "${TARGET} (SDK: ${CMAKE_OSX_SYSROOT}, architectures: ${CMAKE_OSX_ARCHITECTURES})")
endif()
message(STATUS ${TARGET})
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
@ -2595,7 +2593,7 @@ if(CLIENT AND (DMGTOOLS_FOUND OR HDIUTIL))
endforeach()
set(DMG_DISCORD_COPY_COMMAND)
if(NOT FAT AND NOT TARGET_CPU_ARCHITECTURE STREQUAL "arm" AND NOT TARGET_CPU_ARCHITECTURE STREQUAL "arm64")
if(FAT OR NOT TARGET_CPU_ARCHITECTURE STREQUAL "arm64")
set(DMG_DISCORD_COPY_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/discord/${LIB_DIR}/discord_game_sdk.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/)
endif()

View file

@ -28,7 +28,7 @@ if(DISCORDSDK_FOUND)
elseif(TARGET_OS STREQUAL "linux")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.so")
elseif(TARGET_OS STREQUAL "mac")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.bundle")
set(DISCORDSDK_COPY_FILES "${EXTRA_DISCORDSDK_LIBDIR}/discord_game_sdk.dylib")
endif()
else()
set(DISCORDSDK_COPY_FILES)

@ -1 +1 @@
Subproject commit edfdbb6c40b78de2aac1174dbb977617312abbfb
Subproject commit 522c206ce3d52c76174d19e1712881c6bdaf1bbf

View file

@ -167,6 +167,12 @@
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#if defined(__aarch64__) || defined(__arm64__)
#define CONF_ARCH_ARM64 1
#define CONF_ARCH_STRING "arm64"
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#ifndef CONF_FAMILY_STRING
#define CONF_FAMILY_STRING "unknown"
#endif

View file

@ -1,6 +1,9 @@
#include <engine/discord.h>
#if defined(CONF_DISCORD)
// Hack for universal binary builds on macOS: Ignore arm64 until Discord
// releases a native arm64 SDK for macOS.
#if defined(CONF_DISCORD) && !(defined(CONF_ARCH_ARM64) && defined(CONF_PLATFORM_MACOS))
#include <discord_game_sdk.h>
typedef enum EDiscordResult (*FDiscordCreate)(DiscordVersion, struct DiscordCreateParams *, struct IDiscordCore **);