Commit 98b6e1d5 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #10515 from alalek:android_ndk16

parents 57dc28fe d01a2038
...@@ -244,10 +244,14 @@ mark_as_advanced(HAVE_IEEEFP) ...@@ -244,10 +244,14 @@ mark_as_advanced(HAVE_IEEEFP)
# Large file support # Large file support
if(UNIX OR MINGW) if(UNIX OR MINGW)
# This might not catch every possibility catered for by if(ANDROID AND (ANDROID_NATIVE_API_LEVEL LESS 21) AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang))
# AC_SYS_LARGEFILE. # Android NDK build problem: 'mmap' issue with GCC and API<21
add_definitions(-D_FILE_OFFSET_BITS=64) else()
set(FILE_OFFSET_BITS 64) # This might not catch every possibility catered for by
# AC_SYS_LARGEFILE.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(FILE_OFFSET_BITS 64)
endif()
endif() endif()
# Documentation install directory (default to cmake project docdir) # Documentation install directory (default to cmake project docdir)
......
...@@ -245,9 +245,6 @@ ...@@ -245,9 +245,6 @@
# endif # endif
#endif #endif
/* Number of bits in a file offset, on hosts where this is settable. */
#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@
/* Define to `__inline__' or `__inline' if that's what the C compiler /* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */ calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus #ifndef __cplusplus
......
...@@ -216,14 +216,14 @@ class FieldMaskTree { ...@@ -216,14 +216,14 @@ class FieldMaskTree {
~Node() { ClearChildren(); } ~Node() { ClearChildren(); }
void ClearChildren() { void ClearChildren() {
for (map<string, Node*>::iterator it = children.begin(); for (std::map<string, Node*>::iterator it = children.begin();
it != children.end(); ++it) { it != children.end(); ++it) {
delete it->second; delete it->second;
} }
children.clear(); children.clear();
} }
map<string, Node*> children; std::map<string, Node*> children;
private: private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);
...@@ -274,7 +274,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, ...@@ -274,7 +274,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node,
out->add_paths(prefix); out->add_paths(prefix);
return; return;
} }
for (map<string, Node*>::const_iterator it = node->children.begin(); for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) { it != node->children.end(); ++it) {
string current_path = prefix.empty() ? it->first : prefix + "." + it->first; string current_path = prefix.empty() ? it->first : prefix + "." + it->first;
MergeToFieldMask(current_path, it->second, out); MergeToFieldMask(current_path, it->second, out);
...@@ -339,7 +339,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node, ...@@ -339,7 +339,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node,
if (node->children.empty()) { if (node->children.empty()) {
out->AddPath(prefix); out->AddPath(prefix);
} }
for (map<string, Node*>::const_iterator it = node->children.begin(); for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) { it != node->children.end(); ++it) {
string current_path = prefix.empty() ? it->first : prefix + "." + it->first; string current_path = prefix.empty() ? it->first : prefix + "." + it->first;
MergeLeafNodesToTree(current_path, it->second, out); MergeLeafNodesToTree(current_path, it->second, out);
...@@ -353,7 +353,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, ...@@ -353,7 +353,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source,
const Reflection* source_reflection = source.GetReflection(); const Reflection* source_reflection = source.GetReflection();
const Reflection* destination_reflection = destination->GetReflection(); const Reflection* destination_reflection = destination->GetReflection();
const Descriptor* descriptor = source.GetDescriptor(); const Descriptor* descriptor = source.GetDescriptor();
for (map<string, Node*>::const_iterator it = node->children.begin(); for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) { it != node->children.end(); ++it) {
const string& field_name = it->first; const string& field_name = it->first;
const Node* child = it->second; const Node* child = it->second;
...@@ -456,7 +456,7 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) { ...@@ -456,7 +456,7 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) {
const int32 field_count = descriptor->field_count(); const int32 field_count = descriptor->field_count();
for (int index = 0; index < field_count; ++index) { for (int index = 0; index < field_count; ++index) {
const FieldDescriptor* field = descriptor->field(index); const FieldDescriptor* field = descriptor->field(index);
map<string, Node*>::const_iterator it = node->children.find(field->name()); std::map<string, Node*>::const_iterator it = node->children.find(field->name());
if (it == node->children.end()) { if (it == node->children.end()) {
reflection->ClearField(message, field); reflection->ClearField(message, field);
} else { } else {
......
...@@ -60,7 +60,7 @@ class TypeInfoForTypeResolver : public TypeInfo { ...@@ -60,7 +60,7 @@ class TypeInfoForTypeResolver : public TypeInfo {
virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl( virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
StringPiece type_url) const { StringPiece type_url) const {
map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url); std::map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url);
if (it != cached_types_.end()) { if (it != cached_types_.end()) {
return it->second; return it->second;
} }
...@@ -85,7 +85,7 @@ class TypeInfoForTypeResolver : public TypeInfo { ...@@ -85,7 +85,7 @@ class TypeInfoForTypeResolver : public TypeInfo {
virtual const google::protobuf::Enum* GetEnumByTypeUrl( virtual const google::protobuf::Enum* GetEnumByTypeUrl(
StringPiece type_url) const { StringPiece type_url) const {
map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url); std::map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url);
if (it != cached_enums_.end()) { if (it != cached_enums_.end()) {
return it->second.ok() ? it->second.ValueOrDie() : NULL; return it->second.ok() ? it->second.ValueOrDie() : NULL;
} }
...@@ -123,8 +123,8 @@ class TypeInfoForTypeResolver : public TypeInfo { ...@@ -123,8 +123,8 @@ class TypeInfoForTypeResolver : public TypeInfo {
typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum; typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum;
template <typename T> template <typename T>
static void DeleteCachedTypes(map<StringPiece, T>* cached_types) { static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) {
for (typename map<StringPiece, T>::iterator it = cached_types->begin(); for (typename std::map<StringPiece, T>::iterator it = cached_types->begin();
it != cached_types->end(); ++it) { it != cached_types->end(); ++it) {
if (it->second.ok()) { if (it->second.ok()) {
delete it->second.ValueOrDie(); delete it->second.ValueOrDie();
...@@ -153,11 +153,11 @@ class TypeInfoForTypeResolver : public TypeInfo { ...@@ -153,11 +153,11 @@ class TypeInfoForTypeResolver : public TypeInfo {
// cached_types_, cached_enums_ and camel_case_name_table_. // cached_types_, cached_enums_ and camel_case_name_table_.
mutable set<string> string_storage_; mutable set<string> string_storage_;
mutable map<StringPiece, StatusOrType> cached_types_; mutable std::map<StringPiece, StatusOrType> cached_types_;
mutable map<StringPiece, StatusOrEnum> cached_enums_; mutable std::map<StringPiece, StatusOrEnum> cached_enums_;
mutable set<const google::protobuf::Type*> indexed_types_; mutable set<const google::protobuf::Type*> indexed_types_;
mutable map<StringPiece, StringPiece> camel_case_name_table_; mutable std::map<StringPiece, StringPiece> camel_case_name_table_;
}; };
} // namespace } // namespace
......
...@@ -1284,7 +1284,7 @@ class MaximumMatcher { ...@@ -1284,7 +1284,7 @@ class MaximumMatcher {
int count1_; int count1_;
int count2_; int count2_;
google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_; google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_;
map<pair<int, int>, bool> cached_match_results_; std::map<pair<int, int>, bool> cached_match_results_;
vector<int>* match_list1_; vector<int>* match_list1_;
vector<int>* match_list2_; vector<int>* match_list2_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher);
...@@ -1322,7 +1322,7 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) { ...@@ -1322,7 +1322,7 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) {
bool MaximumMatcher::Match(int left, int right) { bool MaximumMatcher::Match(int left, int right) {
pair<int, int> p(left, right); pair<int, int> p(left, right);
map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p); std::map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p);
if (it != cached_match_results_.end()) { if (it != cached_match_results_.end()) {
return it->second; return it->second;
} }
......
...@@ -13,7 +13,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") ...@@ -13,7 +13,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_COMPILER_IS_GNUCC 1) set(CMAKE_COMPILER_IS_GNUCC 1)
set(CMAKE_COMPILER_IS_CLANGCC 1) set(CMAKE_COMPILER_IS_CLANGCC 1)
endif() endif()
if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER}" MATCHES "ccache") if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER};${CMAKE_CXX_COMPILER_LAUNCHER}" MATCHES "ccache")
set(CMAKE_COMPILER_IS_CCACHE 1) set(CMAKE_COMPILER_IS_CCACHE 1)
endif() endif()
......
...@@ -8,8 +8,7 @@ if(BUILD_ZLIB) ...@@ -8,8 +8,7 @@ if(BUILD_ZLIB)
else() else()
find_package(ZLIB "${MIN_VER_ZLIB}") find_package(ZLIB "${MIN_VER_ZLIB}")
if(ZLIB_FOUND AND ANDROID) if(ZLIB_FOUND AND ANDROID)
if(ZLIB_LIBRARIES STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so" OR if(ZLIB_LIBRARIES MATCHES "/usr/(lib|lib32|lib64)/libz.so$")
ZLIB_LIBRARIES STREQUAL "${ANDROID_SYSROOT}/usr/lib64/libz.so")
set(ZLIB_LIBRARIES z) set(ZLIB_LIBRARIES z)
endif() endif()
endif() endif()
......
...@@ -18,6 +18,13 @@ if(WITH_IPP) ...@@ -18,6 +18,13 @@ if(WITH_IPP)
endif() endif()
ocv_include_directories(${IPP_INCLUDE_DIRS}) ocv_include_directories(${IPP_INCLUDE_DIRS})
list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES}) list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
# Details: #10229
if(ANDROID AND NOT OPENCV_SKIP_ANDROID_IPP_FIX_1)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a ${CMAKE_SHARED_LINKER_FLAGS}")
elseif(ANDROID AND NOT OPENCV_SKIP_ANDROID_IPP_FIX_2)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
endif() endif()
endif() endif()
......
...@@ -88,6 +88,16 @@ LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES) ...@@ -88,6 +88,16 @@ LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES) LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS) LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
# Details: #10229
ifeq ($(OPENCV_SKIP_ANDROID_IPP_FIX_1),)
LOCAL_LDFLAGS += -Wl,--exclude-libs,libippicv.a
LOCAL_LDFLAGS += -Wl,--exclude-libs,libippiw.a
else
ifeq ($(OPENCV_SKIP_ANDROID_IPP_FIX_2),)
LOCAL_LDFLAGS += -Wl,-Bsymbolic
endif
endif
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES) LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS) LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
......
...@@ -312,9 +312,16 @@ macro( __DETECT_NATIVE_API_LEVEL _var _path ) ...@@ -312,9 +312,16 @@ macro( __DETECT_NATIVE_API_LEVEL _var _path )
set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" ) set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" )
file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if( NOT __apiFileContent ) if( NOT __apiFileContent )
message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+__ANDROID_API_FUTURE__[\t ]*$" )
file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if( __apiFileContent )
set(${_var} 10000)
else()
message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
endif()
else()
string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" )
endif() endif()
string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" )
unset( __apiFileContent ) unset( __apiFileContent )
unset( __ndkApiLevelRegex ) unset( __ndkApiLevelRegex )
endmacro() endmacro()
...@@ -810,10 +817,15 @@ unset(__real_api_level) ...@@ -810,10 +817,15 @@ unset(__real_api_level)
# validate # validate
list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx ) list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
if( __levelIdx EQUAL -1 ) if( __levelIdx EQUAL -1 )
message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." ) message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain.\nSupported values of ANDROID_NATIVE_API_LEVEL: ${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
else() else()
if( BUILD_WITH_ANDROID_NDK ) if( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) if(EXISTS "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h")
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
else()
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/sysroot/usr/include/android/api-level.h")
endif()
if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 ) if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 )
message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." ) message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif() endif()
...@@ -914,6 +926,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) ...@@ -914,6 +926,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" ) set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
set( ANDROID_SYSROOT_INCLUDE "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include" )
if( NOT ANDROID_STL STREQUAL "none" ) if( NOT ANDROID_STL STREQUAL "none" )
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" ) set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" )
...@@ -991,6 +1004,11 @@ endif() ...@@ -991,6 +1004,11 @@ endif()
if( BUILD_WITH_ANDROID_NDK ) if( BUILD_WITH_ANDROID_NDK )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
if( EXISTS "${ANDROID_SYSROOT}/usr/include" )
set( ANDROID_SYSROOT_INCLUDE "${ANDROID_SYSROOT}/usr/include" )
else()
set( ANDROID_SYSROOT_INCLUDE "${ANDROID_NDK}/sysroot/usr/include" "${ANDROID_NDK}/sysroot/usr/include/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
endif()
if( ANDROID_STL STREQUAL "none" ) if( ANDROID_STL STREQUAL "none" )
# do nothing # do nothing
...@@ -1480,7 +1498,7 @@ if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES ) ...@@ -1480,7 +1498,7 @@ if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
endif() endif()
endif() endif()
# configure exceptios # configure exceptions
if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES ) if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES )
if( ANDROID_EXCEPTIONS ) if( ANDROID_EXCEPTIONS )
set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" ) set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" )
...@@ -1492,9 +1510,11 @@ if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES ) ...@@ -1492,9 +1510,11 @@ if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES )
endif() endif()
# global includes and link directories # global includes and link directories
include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) include_directories( SYSTEM "${ANDROID_SYSROOT_INCLUDE}" ${ANDROID_STL_INCLUDE_DIRS} )
get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning
link_directories( "${__android_install_path}" ) link_directories( "${__android_install_path}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID -D__ANDROID_API__=${ANDROID_NATIVE_API_LEVEL}" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DANDROID -D__ANDROID_API__=${ANDROID_NATIVE_API_LEVEL}" )
# detect if need link crtbegin_so.o explicitly # detect if need link crtbegin_so.o explicitly
if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK ) if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK )
...@@ -1567,19 +1587,58 @@ set( ANDROID True ) ...@@ -1567,19 +1587,58 @@ set( ANDROID True )
set( BUILD_ANDROID True ) set( BUILD_ANDROID True )
# where is the target environment # where is the target environment
set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) set( CMAKE_FIND_ROOT_PATH
"${ANDROID_TOOLCHAIN_ROOT}/bin"
"${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}"
"${ANDROID_SYSROOT}"
"${ANDROID_NDK}/sysroot" # NDK16+
"${CMAKE_INSTALL_PREFIX}"
"${CMAKE_INSTALL_PREFIX}/share" )
# only search for libraries and includes in the ndk toolchain # only search for libraries and includes in the ndk toolchain
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
endif()
macro(__cmake_find_root_save_and_reset)
foreach(v
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
)
set(__save_${v} ${${v}})
set(${v} NEVER)
endforeach()
endmacro()
macro(__cmake_find_root_restore)
foreach(v
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
)
set(${v} ${__save_${v}})
unset(__save_${v})
endforeach()
endmacro()
# macro to find packages on the host OS # macro to find packages on the host OS
macro( find_host_package ) macro( find_host_package )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) __cmake_find_root_save_and_reset()
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 ) if( CMAKE_HOST_WIN32 )
SET( WIN32 1 ) SET( WIN32 1 )
SET( UNIX ) SET( UNIX )
...@@ -1591,17 +1650,13 @@ macro( find_host_package ) ...@@ -1591,17 +1650,13 @@ macro( find_host_package )
SET( WIN32 ) SET( WIN32 )
SET( APPLE ) SET( APPLE )
SET( UNIX 1 ) SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) __cmake_find_root_restore()
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro() endmacro()
# macro to find programs on the host OS # macro to find programs on the host OS
macro( find_host_program ) macro( find_host_program )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) __cmake_find_root_save_and_reset()
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 ) if( CMAKE_HOST_WIN32 )
SET( WIN32 1 ) SET( WIN32 1 )
SET( UNIX ) SET( UNIX )
...@@ -1613,9 +1668,7 @@ macro( find_host_program ) ...@@ -1613,9 +1668,7 @@ macro( find_host_program )
SET( WIN32 ) SET( WIN32 )
SET( APPLE ) SET( APPLE )
SET( UNIX 1 ) SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) __cmake_find_root_restore()
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro() endmacro()
...@@ -1713,6 +1766,7 @@ endif() ...@@ -1713,6 +1766,7 @@ endif()
# ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor) # ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor)
# ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI # ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI
# ANDROID_SYSROOT : path to the compiler sysroot # ANDROID_SYSROOT : path to the compiler sysroot
# ANDROID_SYSROOT_INCLUDE : paths to system include paths
# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
# ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used # ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment