Android: Always set CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION

When this variable is not set by the user or toolchain file, set it to
the default selected.  This will be useful for client code that needs to
pass the value to an external tool that needs to find the same toolchain
in the NDK.  Leave it empty for a standalone toolchain.

Suggested-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
This commit is contained in:
Brad King
2016-11-11 14:50:50 -05:00
parent 4a4be0301b
commit 3d42a72bd5
7 changed files with 32 additions and 4 deletions
+8 -1
View File
@@ -22,8 +22,15 @@ string(APPEND CMAKE_CXX_FLAGS " -Werror -Wno-attributes")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined")
if(CMAKE_ANDROID_NDK)
if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "clang")
if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is not set!")
elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "^clang")
add_definitions(-DCOMPILER_IS_CLANG)
elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "toolchains/[^/]+-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}/prebuilt")
message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is\n"
" ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\n"
"which does not appear in CMAKE_C_COMPILER:\n"
" ${CMAKE_C_COMPILER}")
endif()
elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
execute_process(