From 4e6870a92fcbffa8f15b82f0a1b7b7edc4b30649 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 18 Jun 2021 01:49:06 +0200 Subject: [PATCH] Fix building Android release versions With out -03 -flto=full android builds will fail with a message that it's not possible wiht out O1 - O3 --- CMakeLists.txt | 11 +---------- android-project/CMake/android_defs.cmake | 17 +++++++++++++++++ android-project/app/build.gradle | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 android-project/CMake/android_defs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db421fc455..496a29a5a36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,16 +189,7 @@ endif() if(ANDROID) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/android-project/CMake") - - set(ASAN OFF) - set(UBSAN OFF) - set(DEVILUTIONX_SYSTEM_LIBSODIUM OFF) - set(DISABLE_ZERO_TIER ON) - set(TTF_FONT_DIR \"\") - - file( - COPY "${DevilutionX_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf" - DESTINATION "${DevilutionX_SOURCE_DIR}/android-project/app/src/main/assets") + include(android_defs) endif() if(PIE) diff --git a/android-project/CMake/android_defs.cmake b/android-project/CMake/android_defs.cmake new file mode 100644 index 00000000000..ee7c52c903c --- /dev/null +++ b/android-project/CMake/android_defs.cmake @@ -0,0 +1,17 @@ +#General compilation options +set(ASAN OFF) +set(UBSAN OFF) +set(DEVILUTIONX_SYSTEM_LIBSODIUM OFF) +set(DISABLE_ZERO_TIER ON) + +if(BINARY_RELEASE OR CMAKE_BUILD_TYPE STREQUAL "Release") + # Workaroudn linker bug in CLang: https://github.com/android/ndk/issues/721 + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto=full") +endif() + +#additional compilation definitions +set(TTF_FONT_DIR \"\") + +file( + COPY "${DevilutionX_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf" + DESTINATION "${DevilutionX_SOURCE_DIR}/android-project/app/src/main/assets") diff --git a/android-project/app/build.gradle b/android-project/app/build.gradle index 408f7bbc533..033e93d643b 100644 --- a/android-project/app/build.gradle +++ b/android-project/app/build.gradle @@ -22,7 +22,7 @@ android { versionName "1.2.1" externalNativeBuild { cmake { - arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static" + arguments "-DANDROID_STL=c++_static" abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } }