diff options
author | Brad King <brad.king@kitware.com> | 2016-11-11 20:22:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-18 14:51:18 (GMT) |
commit | 5c2100e5c0be11a8dda8694be214a59e15766857 (patch) | |
tree | 49454bec6d6b40f7d8f8f4d3328f9d1afca6adb0 | |
parent | 790c0a89de5a06e52a5f71b372e70ed0b36194cd (diff) | |
download | CMake-5c2100e5c0be11a8dda8694be214a59e15766857.zip CMake-5c2100e5c0be11a8dda8694be214a59e15766857.tar.gz CMake-5c2100e5c0be11a8dda8694be214a59e15766857.tar.bz2 |
Android: Add CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG variable
The NDK provides prebuilt toolchain files in directories named for the
host architecture. The NDK build system calls this `HOST_TAG`.
Expose the value publicly for use by clients that need to pass it
to external tools.
Suggested-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/release/dev/android-info-variables.rst | 5 | ||||
-rw-r--r-- | Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst | 6 | ||||
-rw-r--r-- | Modules/Platform/Android/Determine-Compiler-NDK.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Android/Determine-Compiler-Standalone.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Android/Determine-Compiler.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/Android/common.cmake | 8 |
7 files changed, 24 insertions, 0 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index b74f867..0b28c73 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -241,6 +241,7 @@ Variables that Control the Build /variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES /variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES /variable/CMAKE_ANDROID_NDK + /variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG /variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION /variable/CMAKE_ANDROID_PROCESS_MAX /variable/CMAKE_ANDROID_PROGUARD diff --git a/Help/release/dev/android-info-variables.rst b/Help/release/dev/android-info-variables.rst index 089f9b0..9330c62 100644 --- a/Help/release/dev/android-info-variables.rst +++ b/Help/release/dev/android-info-variables.rst @@ -4,3 +4,8 @@ android-info-variables * When :ref:`Cross Compiling for Android with the NDK`, the :variable:`CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION` variable is now set by CMake if it is not set by the user or toolchain file. + +* When :ref:`Cross Compiling for Android with the NDK`, a new + :variable:`CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG` variable is + now set by CMake to expose the host directory component of the + path to the NDK prebuilt toolchains. diff --git a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst new file mode 100644 index 0000000..207019a --- /dev/null +++ b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst @@ -0,0 +1,6 @@ +CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG +------------------------------------ + +When :ref:`Cross Compiling for Android with the NDK`, this variable +provides the NDK's "host tag" used to construct the path to prebuilt +toolchains that run on the host. diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index a33935b..855ae86 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -210,6 +210,7 @@ endif() # Help CMakeFindBinUtils locate things. set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}") +set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "${_ANDROID_HOST_DIR}") set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS_NDK}") set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}") diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake index 9f07ab9..d81e691 100644 --- a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake +++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake @@ -58,4 +58,5 @@ else() set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "") endif() +set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "") set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "") diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake index 7ec703a..162bc9d 100644 --- a/Modules/Platform/Android/Determine-Compiler.cmake +++ b/Modules/Platform/Android/Determine-Compiler.cmake @@ -40,6 +40,7 @@ if(CMAKE_ANDROID_NDK) elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) include(Platform/Android/Determine-Compiler-Standalone) else() + set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "") set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "") set(_ANDROID_TOOL_C_COMPILER "") set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "") @@ -62,6 +63,7 @@ macro(__android_determine_compiler lang) # Save the Android-specific information in CMake${lang}Compiler.cmake. set(CMAKE_${lang}_COMPILER_CUSTOM_CODE " +set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG}\") set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION}\") set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\") set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN \"${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}\") diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index 18c9797..0afa78c 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -32,6 +32,14 @@ if(CMAKE_ANDROID_NDK) "which does not appear in CMAKE_C_COMPILER:\n" " ${CMAKE_C_COMPILER}") endif() + if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG) + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is not set!") + elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin") + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is\n" + " ${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\n" + "which does not appear in CMAKE_C_COMPILER:\n" + " ${CMAKE_C_COMPILER}") + endif() elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) execute_process( COMMAND ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang --version |