summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Egorov <egorov@linux.com>2022-09-16 10:02:44 (GMT)
committerBrad King <brad.king@kitware.com>2022-09-16 14:36:58 (GMT)
commit1c86e397fe20b89521842617258db33079e34d1f (patch)
tree2b0a0ba933bba2e5baf2fcddb66f11ccbd8cbc7b
parentcabba23ab270eb5cc672c43265f9eb3cb7dda8cc (diff)
downloadCMake-1c86e397fe20b89521842617258db33079e34d1f.zip
CMake-1c86e397fe20b89521842617258db33079e34d1f.tar.gz
CMake-1c86e397fe20b89521842617258db33079e34d1f.tar.bz2
Android/Clang: Tolerate undefined CMAKE_ANDROID_NDK_VERSION
The previous fix for #21772, commit 005e2cdfb0 (Android: Do not use gold for ndk >= r22, 2021-02-26, v3.20.0-rc3~1^2), doesn't work with typical android toolchain file, like this one: https://android.googlesource.com/platform/ndk/+/master/build/cmake/android-legacy.toolchain.cmake The condition fails to work when CMAKE_ANDROID_NDK_VERSION is undefined: second part evaluates to true, although ndk version is not known. I've encountered following environment where CMAKE_ANDROID_NDK_VERSION is used without definition: * Build uses android toolchain file, which sets CMAKE_SYSTEM_VERSION=1 and doesn't set CMAKE_ANDROID_NDK_VERSION. * Code in Platform/Android-Determine.cmake exits early when it detects toolchain usage (via value CMAKE_SYSTEM_VERSION=1). This file is the only place in cmake modules where variable CMAKE_ANDROID_NDK_VERSION is set, and by early return we skip this definition.
-rw-r--r--Modules/Compiler/Clang.cmake2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 257402a..4f9af37 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -80,7 +80,7 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto")
endif()
- if(ANDROID AND NOT CMAKE_ANDROID_NDK_VERSION VERSION_GREATER_EQUAL "22")
+ if(ANDROID AND CMAKE_ANDROID_NDK_VERSION VERSION_LESS "22")
# https://github.com/android-ndk/ndk/issues/242
set(CMAKE_${lang}_LINK_OPTIONS_IPO "-fuse-ld=gold")
endif()