# [+] filtered out hidden files (starting with .) while globbing inside NDK
# [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
# [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
+# - modified February 2012
+# [+] mostly fixed try_compile (it was always failing for Android)
# ------------------------------------------------------------------------------
# this one is important
endif()
#flags and definitions
-set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
+if(ANDROID_SYSROOT MATCHES "[ ;\"]")
+ set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
+ # quotes will break try_compile and compiler identification
+ message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
+else()
+ set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
+endif()
+
remove_definitions( -DANDROID )
add_definitions( -DANDROID )
+# Force set compilers because standard identification works badly for us
+include( CMakeForceCompiler )
+CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
+set( CMAKE_SIZEOF_VOID_P 4 )
+set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
+
# NDK flags
if( ARMEABI OR ARMEABI_V7A )
# NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Extra Android falgs")
set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
-# workaround for ugly cmake bug - compiler identification replaces all spaces (and somethimes " (quote symbol)) in the compiler flags with ; symbol
-# as result identification fails if ANDROID_SYSROOT contain spaces
-include( CMakeForceCompiler )
-CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
-CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
-set( CMAKE_SIZEOF_VOID_P 4 )
-set( CMAKE_C_SIZEOF_DATA_PTR 4 )
-set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
#set these global flags for cmake client scripts to change behavior
set( ANDROID True )
# detect ANDROID_SDK_TARGET if no target is provided by user
if(NOT ANDROID_SDK_TARGET)
set(desired_android_target_level ${ANDROID_NATIVE_API_LEVEL})
- if(desired_android_target_level LESS 8)
- set(desired_android_target_level 8)
+ if(desired_android_target_level LESS 11)
+ set(desired_android_target_level 11)
endif()
if(ANDROID_PROCESS EQUAL 0)
math(EXPR desired_android_target_level_1 "${desired_android_target_level}-1")