diff options
author | Brad King <brad.king@kitware.com> | 2019-07-26 16:48:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-26 18:17:07 (GMT) |
commit | 97bca2f9fab58fcf5bbcb29e1e7e86e37b5cc1e0 (patch) | |
tree | 048fee25cd8797b3527994c504c5b8ce50e2ede2 /Modules/Platform/Android-Determine.cmake | |
parent | 19f36c5fb2497703e4f071b3a9424a8d121ccef9 (diff) | |
download | CMake-97bca2f9fab58fcf5bbcb29e1e7e86e37b5cc1e0.zip CMake-97bca2f9fab58fcf5bbcb29e1e7e86e37b5cc1e0.tar.gz CMake-97bca2f9fab58fcf5bbcb29e1e7e86e37b5cc1e0.tar.bz2 |
Android: Use unified toolchain in NDK r19+
The NDK build system now uses only a single toolchain in
<ndk>/toolchains/llvm/prebuilt/<host>
Its compilers are always `bin/{clang,clang++}` and its binutils are
always `bin/<triple>-*`. It is a standalone toolchain:
* The Anrdoid API level is specified at the end of `--target=`.
* The standard library may be specified via `-stdlib=`.
* No need to pass system includes or libraries explicitly.
* No need to pass `--sysroot` or `-gcc-toolchain`.
Teach CMake to recognize NDK versions that have a unified
toolchain with its own sysroot and use the above approach.
Fixes: #18739
Diffstat (limited to 'Modules/Platform/Android-Determine.cmake')
-rw-r--r-- | Modules/Platform/Android-Determine.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 56ed328..e7c1b48 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -221,8 +221,15 @@ if(CMAKE_ANDROID_NDK) else() message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.") endif() + + # Look for a unified toolchain/sysroot provided with the NDK. + set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}") + if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot") + set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "") + endif() else() set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "") + set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "") endif() # https://developer.android.com/ndk/guides/abis.html @@ -370,6 +377,7 @@ if(CMAKE_ANDROID_NDK) "set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n" "set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n" "set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n" + "set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n" ) endif() |