diff options
author | Brad King <brad.king@kitware.com> | 2021-03-03 16:11:52 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-03 16:11:58 (GMT) |
commit | 957a117c705766d5d4d2d6c807217fe9d154cdff (patch) | |
tree | 5bffa910e35b950f868202f8da2a96427f3c0b3e /Modules | |
parent | a88efbc9cfad2d69e1f1e8875383c4e9c1f39849 (diff) | |
parent | 005e2cdfb05d92e1b24df2d35ea10ac557b3d831 (diff) | |
download | CMake-957a117c705766d5d4d2d6c807217fe9d154cdff.zip CMake-957a117c705766d5d4d2d6c807217fe9d154cdff.tar.gz CMake-957a117c705766d5d4d2d6c807217fe9d154cdff.tar.bz2 |
Merge topic 'android-r22'
005e2cdfb0 Android: Do not use gold for ndk >= r22
ed7a87f270 Tests: Update RunCMake.Android for NDK r22
4950d35733 Help: Document CMAKE_ANDROID_NDK_VERSION variable
746906242d Android: Detect NDK version number
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5862
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Compiler/Clang.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Android-Determine.cmake | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 5862521..9f93d41 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -77,7 +77,7 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto") endif() - if(ANDROID) + if(ANDROID AND NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL "22") # https://github.com/android-ndk/ndk/issues/242 set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold") endif() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index c279086..2d2cd5c 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -226,6 +226,44 @@ if(CMAKE_ANDROID_NDK) include("${CMAKE_ANDROID_NDK}/build/cmake/abis.cmake" OPTIONAL RESULT_VARIABLE _INCLUDED_ABIS) endif() +if(CMAKE_ANDROID_NDK AND EXISTS "${CMAKE_ANDROID_NDK}/source.properties") + # Android NDK revision + # Possible formats: + # * r16, build 1234: 16.0.1234 + # * r16b, build 1234: 16.1.1234 + # * r16 beta 1, build 1234: 16.0.1234-beta1 + # + # Canary builds are not specially marked. + file(READ "${CMAKE_ANDROID_NDK}/source.properties" _ANDROID_NDK_SOURCE_PROPERTIES) + + set(_ANDROID_NDK_REVISION_REGEX + "^Pkg\\.Desc = Android NDK\nPkg\\.Revision = ([0-9]+)\\.([0-9]+)\\.([0-9]+)(-beta([0-9]+))?") + if(NOT _ANDROID_NDK_SOURCE_PROPERTIES MATCHES "${_ANDROID_NDK_REVISION_REGEX}") + string(REPLACE "\n" "\n " _ANDROID_NDK_SOURCE_PROPERTIES "${_ANDROID_NDK_SOURCE_PROPERTIES}") + message(FATAL_ERROR + "Android: Failed to parse NDK revision from:\n" + " ${CMAKE_ANDROID_NDK}/source.properties\n" + "with content:\n" + " ${_ANDROID_NDK_SOURCE_PROPERTIES}") + endif() + + set(_ANDROID_NDK_MAJOR "${CMAKE_MATCH_1}") + set(_ANDROID_NDK_MINOR "${CMAKE_MATCH_2}") + set(_ANDROID_NDK_BUILD "${CMAKE_MATCH_3}") + set(_ANDROID_NDK_BETA "${CMAKE_MATCH_5}") + if(_ANDROID_NDK_BETA STREQUAL "") + set(_ANDROID_NDK_BETA "0") + endif() + set(CMAKE_ANDROID_NDK_VERSION "${_ANDROID_NDK_MAJOR}.${_ANDROID_NDK_MINOR}") + + unset(_ANDROID_NDK_SOURCE_PROPERTIES) + unset(_ANDROID_NDK_REVISION_REGEX) + unset(_ANDROID_NDK_MAJOR) + unset(_ANDROID_NDK_MINOR) + unset(_ANDROID_NDK_BUILD) + unset(_ANDROID_NDK_BETA) +endif() + if(CMAKE_ANDROID_NDK) # Identify the host platform. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") @@ -523,6 +561,7 @@ if(CMAKE_ANDROID_NDK) string(APPEND CMAKE_SYSTEM_CUSTOM_CODE "set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n" "set(CMAKE_ANDROID_ARCH_LLVM_TRIPLE \"${CMAKE_ANDROID_ARCH_LLVM_TRIPLE}\")\n" + "set(CMAKE_ANDROID_NDK_VERSION \"${CMAKE_ANDROID_NDK_VERSION}\")\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" |