Skip to content

Instantly share code, notes, and snippets.

@alexandre-janniaux
Last active November 21, 2019 12:52
Show Gist options
  • Save alexandre-janniaux/c71ff5cb341bd26f3909a28e11e67e9d to your computer and use it in GitHub Desktop.
Save alexandre-janniaux/c71ff5cb341bd26f3909a28e11e67e9d to your computer and use it in GitHub Desktop.
commit 6e5b7ca8ea70a9774004f2576e6f7435bd56d4ff (HEAD -> android-build)
Author: Alexandre Janniaux <ajanni@videolabs.io>
Date: Thu Nov 21 13:30:11 2019 +0100
contrib: toolchain.cmake: enforce system name and arch abi for android
CMAKE_SYSTEM_PROCESSOR must match specific rules for Android, defined in
the CMake files: Modules/Platform/Android-Determine.cmake. Instead, pass
down the ANDROID_ABI variable to the CMAKE_ANDROID_ARCH_ABI which will be
used to set the correct environment.
Also enforce CMAKE_SYSTEM_NAME to have CMAKE_CROSSCOMPILE = true.
diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index fcc5411743..e99321d508 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -552,7 +552,17 @@ ifndef WITH_OPTIMIZATION
else
echo "set(CMAKE_BUILD_TYPE Release)" >> $@
endif
+
+ifdef HAVE_ANDROID
+# Android has special rules for detecting the architecture
+# and CMAKE_SYSTEM_PROCESSOR should match them.
+ echo "set(CMAKE_SYSTEM_NAME Android)" >> $@
+ echo "set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ABI})" >> $@
+else
echo "set(CMAKE_SYSTEM_PROCESSOR $(ARCH))" >> $@
+endif
+
+
if test -n "$(CMAKE_SYSTEM_NAME)"; then \
echo "set(CMAKE_SYSTEM_NAME $(CMAKE_SYSTEM_NAME))" >> $@; \
fi;
commit c8dc41b9151196e53dedb2adfa13839401c405c4
Author: Alexandre Janniaux <ajanni@videolabs.io>
Date: Thu Nov 21 11:11:15 2019 +0100
contrib: soxr: don't enforce CMAKE_SYSTEM_NAME on android
CMake will infer the CMAKE_SYSTEM_NAME variable from the generated
toolchain on Android, and setting it prevents CMake from finding which
system it really is and believe it's Windows. Because PKG_CONFIG_PATH
entries are separated by a semi-colon on Windows, it prevents finding
libraries like libavcodec.
diff --git a/contrib/src/soxr/rules.mak b/contrib/src/soxr/rules.mak
index eaefb7c3ee..a26557b6fb 100644
--- a/contrib/src/soxr/rules.mak
+++ b/contrib/src/soxr/rules.mak
@@ -24,10 +24,13 @@ soxr: soxr-$(SOXR_VERSION)-Source.tar.xz .sum-soxr
$(call pkg_static,"src/soxr.pc.in")
$(MOVE)
+# CMAKE_SYSTEM_NAME is inferred from the toolchain in Android builds
+ifndef HAVE_ANDROID
# Force CMAKE_CROSSCOMPILING to True
ifdef HAVE_CROSS_COMPILE
SOXR_EXTRA_CONF=-DCMAKE_SYSTEM_NAME=Generic
endif
+endif
.soxr: soxr toolchain.cmake
rm -f $</CMakeCache.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment