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-Compiler-NDK.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-Compiler-NDK.cmake')
-rw-r--r-- | Modules/Platform/Android/Determine-Compiler-NDK.cmake | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index e5a7390..e009c10 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -1,6 +1,31 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +# In Android NDK r19 and above there is a single clang toolchain. +if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) + if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "clang") + message(FATAL_ERROR + "Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}' " + "is not supported by this NDK. It must be 'clang' or not set at all." + ) + endif() + message(STATUS "Android: Selected unified Clang toolchain") + set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "clang") + set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang${_ANDROID_HOST_EXT}") + set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}") + set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "") + set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "") + set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-") + set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}") + set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang++${_ANDROID_HOST_EXT}") + set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}") + set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "") + set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "") + set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-") + set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}") + return() +endif() + # In Android NDK releases there is build system toolchain selection logic in # these files: # |