From b2996e1fd48842446a64443d057c576f819bda00 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 17 Dec 2018 16:45:09 -0800 Subject: [PATCH] Support custom Android NDK, better ABI specification (#4986) --- scripts/toolchains/android.cmake | 13 ++++++++++++- toolsrc/src/vcpkg/base/system.cpp | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/toolchains/android.cmake b/scripts/toolchains/android.cmake index 893463056f..69192aeca9 100644 --- a/scripts/toolchains/android.cmake +++ b/scripts/toolchains/android.cmake @@ -1,11 +1,22 @@ set(ANDROID_CPP_FEATURES "rtti exceptions" CACHE STRING "") set(CMAKE_SYSTEM_NAME Android CACHE STRING "") -set(ANDROID_ABI x86_64 CACHE STRING "") set(ANDROID_TOOLCHAIN clang CACHE STRING "") set(ANDROID_NATIVE_API_LEVEL 21 CACHE STRING "") set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang CACHE STRING "") +if (VCPKG_TARGET_TRIPLET STREQUAL "arm64-android") + set(ANDROID_ABI arm64-v8a CACHE STRING "") +elseif(VCPKG_TARGET_TRIPLET STREQUAL "arm-android") + set(ANDROID_ABI armeabi-v7a CACHE STRING "") +elseif(VCPKG_TARGET_TRIPLET STREQUAL "x64-android") + set(ANDROID_ABI x86_64 CACHE STRING "") +elseif(VCPKG_TARGET_TRIPLET STREQUAL "x86-android") + set(ANDROID_ABI x86 CACHE STRING "") +else() + message(FATAL_ERROR "Unknown ABI for target triplet ${VCPKG_TARGET_TRIPLET}") +endif() + if(DEFINED ENV{ANDROID_NDK_HOME}) set(ANDROID_NDK_HOME $ENV{ANDROID_NDK_HOME}) else() diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 9c72f8401d..8aa1db53ca 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -170,6 +170,8 @@ namespace vcpkg::System L"NVCUDASAMPLES_ROOT", // Enables find_package(Vulkan) in CMake. Environmental variable generated by Vulkan SDK installer L"VULKAN_SDK", + // Enable targeted Android NDK + L"ANDROID_NDK_HOME", }; std::wstring env_cstr;