Compile for android including armv6. (#16847)

* compile for android including armv6.

* Update arm-android.cmake

* Update from comment in the PR
support ANDROID_NATIVE_API_LEVEL from env variable. (to be able to compile also 16 and not just 21 as default)

* Add ANDROID_ARM_NEON from env var

* Short version of update ANDROID_ARM_NEON.

* remove ANDROID_NATIVE_API_LEVEL now using vcpkg_CMAKE_SYSTEM_VERSION in triplet
Add cache to ANDROID_ARM_NEON
fix indents

* Update neon triplet

* Add arm-neon-android.cmake file.
This commit is contained in:
talregev 2021-05-05 23:32:47 +03:00 committed by GitHub
parent 706ab2a279
commit 27fe7a50db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 21 deletions

View File

@ -6,8 +6,14 @@ set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang CACHE STRING "")
if (VCPKG_TARGET_TRIPLET MATCHES "^arm64-android")
set(ANDROID_ABI arm64-v8a CACHE STRING "")
elseif(VCPKG_TARGET_TRIPLET MATCHES "^armv6-android")
set(ANDROID_ABI armeabi CACHE STRING "")
elseif(VCPKG_TARGET_TRIPLET MATCHES "^arm-neon-android")
set(ANDROID_ABI armeabi-v7a CACHE STRING "")
set(ANDROID_ARM_NEON ON CACHE BOOL "")
elseif(VCPKG_TARGET_TRIPLET MATCHES "^arm-android")
set(ANDROID_ABI armeabi-v7a CACHE STRING "")
set(ANDROID_ARM_NEON OFF CACHE BOOL "")
elseif(VCPKG_TARGET_TRIPLET MATCHES "^x64-android")
set(ANDROID_ABI x86_64 CACHE STRING "")
elseif(VCPKG_TARGET_TRIPLET MATCHES "^x86-android")
@ -25,11 +31,11 @@ endif()
if(DEFINED ENV{ANDROID_NDK_HOME})
set(ANDROID_NDK_HOME $ENV{ANDROID_NDK_HOME})
else()
set(ANDROID_NDK_HOME "$ENV{ProgramData}/Microsoft/AndroidNDK64/android-ndk-r13b/")
if(NOT EXISTS "${ANDROID_NDK_HOME}")
# Use Xamarin default installation folder
set(ANDROID_NDK_HOME "$ENV{ProgramFiles\(x86\)}/Android/android-sdk/ndk-bundle")
endif()
set(ANDROID_NDK_HOME "$ENV{ProgramData}/Microsoft/AndroidNDK64/android-ndk-r13b/")
if(NOT EXISTS "${ANDROID_NDK_HOME}")
# Use Xamarin default installation folder
set(ANDROID_NDK_HOME "$ENV{ProgramFiles\(x86\)}/Android/android-sdk/ndk-bundle")
endif()
endif()
if(NOT EXISTS "${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake")
@ -39,21 +45,21 @@ endif()
include("${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake")
if(NOT _VCPKG_ANDROID_TOOLCHAIN)
set(_VCPKG_ANDROID_TOOLCHAIN 1)
get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " ${VCPKG_CXX_FLAGS_RELEASE} ")
set(_VCPKG_ANDROID_TOOLCHAIN 1)
get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " ${VCPKG_CXX_FLAGS_RELEASE} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " ${VCPKG_LINKER_FLAGS_RELEASE} ")
endif()
endif()

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

View File

@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)