diff options
Diffstat (limited to 'Tests/RunCMake/Android/common.cmake')
-rw-r--r-- | Tests/RunCMake/Android/common.cmake | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index d803c98..bef2428 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -22,8 +22,23 @@ 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() + 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( @@ -37,6 +52,23 @@ elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) endif() endif() +execute_process( + COMMAND "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" -dumpmachine + OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _err + RESULT_VARIABLE _res + ) +if(NOT _res EQUAL 0) + message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") +endif() +if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}") + message(SEND_ERROR "'gcc -dumpmachine' produced:\n" + " ${_out}\n" + "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" + " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" + ) +endif() + if(CMAKE_ANDROID_STL_TYPE STREQUAL "none") add_definitions(-DSTL_NONE) elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "system") |