فهرست منبع

Android: Provide CMAKE_ANDROID_NDK_VERSION with NDK legacy toolchain file

This variable has been provided since commit 746906242d (Android: Detect
NDK version number, 2021-02-26, v3.20.0-rc3~1^2~3) when using CMake's
NDK support or the modern NDK toolchain file.  Since commit 005e2cdfb0
(Android: Do not use gold for ndk >= r22, 2021-02-26, v3.20.0-rc3~1^2)
we need the value in our compiler/platform information files, so provide
it when using the NDK legacy toolchain file too.

Revert commit 1c86e397fe (Android/Clang: Tolerate undefined
CMAKE_ANDROID_NDK_VERSION, 2022-09-16, v3.25.0-rc1~118^2) since the
variable should now always be defined.

Issue: #21772
Fixes: #24386
Brad King 2 سال پیش
والد
کامیت
cb0b9452e8
2فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 1 1
      Modules/Compiler/Clang.cmake
  2. 2 0
      Modules/Platform/Android.cmake

+ 1 - 1
Modules/Compiler/Clang.cmake

@@ -80,7 +80,7 @@ else()
       set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto")
     endif()
 
-    if(ANDROID AND CMAKE_ANDROID_NDK_VERSION VERSION_LESS "22")
+    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()

+ 2 - 0
Modules/Platform/Android.cmake

@@ -39,6 +39,8 @@ endif()
 # Commonly used Android toolchain files that pre-date CMake upstream support
 # set CMAKE_SYSTEM_VERSION to 1.  Avoid interfering with them.
 if(CMAKE_SYSTEM_VERSION EQUAL 1)
+  # The NDK legacy toolchain file provides its version number.
+  set(CMAKE_ANDROID_NDK_VERSION ${ANDROID_NDK_MAJOR}.${ANDROID_NDK_MINOR})
   return()
 endif()