diff options
author | Brad King <brad.king@kitware.com> | 2021-03-31 13:25:47 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-31 13:26:35 (GMT) |
commit | f31d1dd175bd46d3f78e678fe66c2adb54fd585f (patch) | |
tree | a1a405a6a3f50306667f0c2a2000610d881efa75 /Modules | |
parent | d796948f44c09d7714163948e79f20e9b1f8dbe6 (diff) | |
parent | 61e6fc26bc46b219b36533accb70002d5e2fb05a (diff) | |
download | CMake-f31d1dd175bd46d3f78e678fe66c2adb54fd585f.zip CMake-f31d1dd175bd46d3f78e678fe66c2adb54fd585f.tar.gz CMake-f31d1dd175bd46d3f78e678fe66c2adb54fd585f.tar.bz2 |
Merge topic 'android-binutils'
61e6fc26bc Android: Fix search for binutils
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5958
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Android-Initialize.cmake | 50 | ||||
-rw-r--r-- | Modules/Platform/Android.cmake | 50 |
3 files changed, 52 insertions, 50 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index ff178f6..e87a16b 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -99,6 +99,8 @@ else() set(_CMAKE_LINKER_NAMES "ld.lld") endif() list(APPEND _CMAKE_AR_NAMES "llvm-ar") + list(APPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") + list(APPEND _CMAKE_STRIP_NAMES "llvm-strip") list(APPEND _CMAKE_NM_NAMES "llvm-nm") list(APPEND _CMAKE_OBJDUMP_NAMES "llvm-objdump") list(APPEND _CMAKE_OBJCOPY_NAMES "llvm-objcopy") diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake index 6116ae1..50f0620 100644 --- a/Modules/Platform/Android-Initialize.cmake +++ b/Modules/Platform/Android-Initialize.cmake @@ -25,6 +25,56 @@ endif() set(CMAKE_BUILD_TYPE_INIT "RelWithDebInfo") +if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) + # Tell CMake not to search host sysroots for headers/libraries. + + # All paths added to CMAKE_SYSTEM_*_PATH below will be rerooted under + # CMAKE_FIND_ROOT_PATH. This is set because: + # 1. Users may structure their libraries in a way similar to NDK. When they do that, + # they can simply append another path to CMAKE_FIND_ROOT_PATH. + # 2. CMAKE_FIND_ROOT_PATH must be non-empty for CMAKE_FIND_ROOT_PATH_MODE_* == ONLY + # to be meaningful. https://github.com/android-ndk/ndk/issues/890 + list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot") + + # Allow users to override these values in case they want more strict behaviors. + # For example, they may want to prevent the NDK's libz from being picked up so + # they can use their own. + # https://github.com/android-ndk/ndk/issues/517 + if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + endif() + + if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + endif() + + if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + endif() + + if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + endif() + + # Don't search paths in PATH environment variable. + if(NOT DEFINED CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH) + set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + endif() + + # Allows CMake to find headers in the architecture-specific include directories. + set(CMAKE_LIBRARY_ARCHITECTURE "${CMAKE_ANDROID_ARCH_TRIPLE}") + + # Instructs CMake to search the correct API level for libraries. + # Besides the paths like <root>/<prefix>/lib/<arch>, cmake also searches <root>/<prefix>. + # So we can add the API level specific directory directly. + # https://github.com/android/ndk/issues/929 + list(PREPEND CMAKE_SYSTEM_PREFIX_PATH + "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/${CMAKE_SYSTEM_VERSION}" + ) + + list(APPEND CMAKE_SYSTEM_PROGRAM_PATH "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin") +endif() + # Skip sysroot selection if the NDK has a unified toolchain. if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) return() diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index e4b9a09..6944e32 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -35,56 +35,6 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1) return() endif() -if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED) - # Tell CMake not to search host sysroots for headers/libraries. - - # All paths added to CMAKE_SYSTEM_*_PATH below will be rerooted under - # CMAKE_FIND_ROOT_PATH. This is set because: - # 1. Users may structure their libraries in a way similar to NDK. When they do that, - # they can simply append another path to CMAKE_FIND_ROOT_PATH. - # 2. CMAKE_FIND_ROOT_PATH must be non-empty for CMAKE_FIND_ROOT_PATH_MODE_* == ONLY - # to be meaningful. https://github.com/android-ndk/ndk/issues/890 - list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot") - - # Allow users to override these values in case they want more strict behaviors. - # For example, they may want to prevent the NDK's libz from being picked up so - # they can use their own. - # https://github.com/android-ndk/ndk/issues/517 - if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - endif() - - if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - endif() - - if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - endif() - - if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - endif() - - # Don't search paths in PATH environment variable. - if(NOT DEFINED CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH) - set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) - endif() - - # Allows CMake to find headers in the architecture-specific include directories. - set(CMAKE_LIBRARY_ARCHITECTURE "${CMAKE_ANDROID_ARCH_TRIPLE}") - - # Instructs CMake to search the correct API level for libraries. - # Besides the paths like <root>/<prefix>/lib/<arch>, cmake also searches <root>/<prefix>. - # So we can add the API level specific directory directly. - # https://github.com/android/ndk/issues/929 - list(PREPEND CMAKE_SYSTEM_PREFIX_PATH - "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/${CMAKE_SYSTEM_VERSION}" - ) - - list(APPEND CMAKE_SYSTEM_PROGRAM_PATH "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin") -endif() - # Include the NDK hook. # It can be used by NDK to inject necessary fixes for an earlier cmake. if(CMAKE_ANDROID_NDK) |