mirror of
https://github.com/reactos/CMake.git
synced 2024-12-16 08:07:29 +00:00
Merge topic 'android-standalone-unified-api-level'
5f93bf78
Android: Detect API version of standalone toolchain with unified headers
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !950
This commit is contained in:
commit
637ff39d45
@ -100,6 +100,20 @@ endif()
|
||||
|
||||
set(_ANDROID_STANDALONE_TOOLCHAIN_API "")
|
||||
if(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
|
||||
# Try to read the API level from the toolchain launcher.
|
||||
if(EXISTS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang")
|
||||
set(_ANDROID_API_LEVEL_CLANG_REGEX "__ANDROID_API__=([0-9]+)")
|
||||
file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang" _ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG
|
||||
REGEX "${_ANDROID_API_LEVEL_CLANG_REGEX}" LIMIT_COUNT 1 LIMIT_INPUT 65536)
|
||||
if(_ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG MATCHES "${_ANDROID_API_LEVEL_CLANG_REGEX}")
|
||||
set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
unset(_ANDROID_STANDALONE_TOOLCHAIN_BIN_CLANG)
|
||||
unset(_ANDROID_API_LEVEL_CLANG_REGEX)
|
||||
endif()
|
||||
if(NOT _ANDROID_STANDALONE_TOOLCHAIN_API)
|
||||
# The compiler launcher does not know __ANDROID_API__. Assume this
|
||||
# is not unified headers and look for it in the api-level.h header.
|
||||
set(_ANDROID_API_LEVEL_H_REGEX "^[\t ]*#[\t ]*define[\t ]+__ANDROID_API__[\t ]+([0-9]+)")
|
||||
file(STRINGS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h"
|
||||
_ANDROID_API_LEVEL_H_CONTENT REGEX "${_ANDROID_API_LEVEL_H_REGEX}")
|
||||
@ -107,6 +121,15 @@ if(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
|
||||
set(_ANDROID_STANDALONE_TOOLCHAIN_API "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _ANDROID_STANDALONE_TOOLCHAIN_API)
|
||||
message(WARNING
|
||||
"Android: Did not detect API level from\n"
|
||||
" ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/clang\n"
|
||||
"or\n"
|
||||
" ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h\n"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
|
||||
message(FATAL_ERROR "Android: Neither the NDK or a standalone toolchain was found.")
|
||||
|
Loading…
Reference in New Issue
Block a user