1 # ------------------------------------------------------------------------------
2 # Android CMake toolchain file, for use with the Android NDK r5-r8
3 # Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended).
4 # See home page: http://code.google.com/p/android-cmake/
6 # The file is mantained by the OpenCV project. And also can be found at
7 # http://code.opencv.org/svn/opencv/trunk/opencv/android/android.toolchain.cmake
10 # $ export ANDROID_NDK=/absolute/path/to/the/android-ndk
11 # $ mkdir build && cd build
12 # $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..
15 # Usage Linux (using standalone toolchain):
16 # $ export ANDROID_STANDALONE_TOOLCHAIN=/absolute/path/to/android-toolchain
17 # $ mkdir build && cd build
18 # $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..
22 # You need native port of make to build your project.
23 # Android NDK r7 (or newer) already has make.exe on board.
24 # For older NDK you have to install it separately.
25 # For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm
27 # $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk
28 # $ mkdir build && cd build
29 # $ cmake.exe -G"MinGW Makefiles"
30 # -DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake
31 # -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" ..
32 # $ "%ANDROID_NDK%\prebuilt\windows\bin\make.exe"
35 # Options (can be set as cmake parameters: -D<option_name>=<value>):
36 # ANDROID_NDK=/opt/android-ndk - path to the NDK root.
37 # Can be set as environment variable. Can be set only at first cmake run.
39 # ANDROID_STANDALONE_TOOLCHAIN=/opt/android-toolchain - path to the
40 # standalone toolchain. This option is not used if full NDK is found
41 # (ignored if ANDROID_NDK is set).
42 # Can be set as environment variable. Can be set only at first cmake run.
44 # ANDROID_ABI=armeabi-v7a - specifies the target Application Binary
45 # Interface (ABI). This option nearly matches to the APP_ABI variable
46 # used by ndk-build tool from Android NDK.
47 # Possible values are:
48 # "armeabi" - matches to the NDK ABI with the same name.
49 # See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
50 # "armeabi-v7a" - matches to the NDK ABI with the same name.
51 # See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
52 # "armeabi-v7a with NEON" - same as armeabi-v7a, but
53 # sets NEON as floating-point unit
54 # "armeabi-v7a with VFPV3" - same as armeabi-v7a, but
55 # sets VFPV3 as floating-point unit (has 32 registers instead of 16).
56 # "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
57 # "x86" - matches to the NDK ABI with the same name.
58 # See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
60 # ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
61 # Option is read-only when standalone toolchain used.
63 # ANDROID_FORCE_ARM_BUILD=OFF - set true to generate 32-bit ARM instructions
64 # instead of Thumb-1. Is not available for "x86" (inapplicable) and
65 # "armeabi-v6 with VFP" (forced) ABIs.
67 # ANDROID_NO_UNDEFINED=ON - set true to show all undefined symbols as linker
68 # errors even if they are not used.
70 # ANDROID_SO_UNDEFINED=OFF - set true to allow undefined symbols in shared
71 # libraries. Automatically turned on for NDK r5x and r6x due to GLESv2
74 # LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_SOURCE_DIR} - where to output binary
75 # files. See additional details below.
77 # ANDROID_SET_OBSOLETE_VARIABLES=ON - it set, then toolchain defines some
78 # obsolete variables which were set by previous versions of this file for
79 # backward compatibility.
83 # android-cmake toolchain searches for NDK/toolchain in the following order:
84 # ANDROID_NDK - cmake parameter
85 # ANDROID_NDK - environment variable
86 # ANDROID_STANDALONE_TOOLCHAIN - cmake parameter
87 # ANDROID_STANDALONE_TOOLCHAIN - environment variable
88 # ANDROID_NDK - default locations
89 # ANDROID_STANDALONE_TOOLCHAIN - default locations
91 # Make sure to do the following in your scripts:
92 # SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" )
93 # SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" )
94 # The flags will be prepopulated with critical flags, so don't loose them.
95 # Also be aware that toolchain also sets configuration-specific compiler
96 # flags and linker flags.
98 # ANDROID and BUILD_ANDROID will be set to true, you may test any of these
99 # variables to make necessary Android-specific configuration changes.
101 # Also ARMEABI or ARMEABI_V7A or X86 will be set true, mutually exclusive.
102 # NEON option will be set true if VFP is set to NEON.
104 # LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android
105 # libraries will be installed.
106 # Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be
107 # under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
108 # (depending on the target ABI). This is convenient for Android packaging.
111 # Ethan Rublee ethan.ruble@gmail.com
112 # Andrey Kamaev andrey.kamaev@itseez.com
115 # - initial version December 2010
116 # - modified April 2011
117 # [+] added possibility to build with NDK (without standalone toolchain)
118 # [+] support cross-compilation on Windows (native, no cygwin support)
119 # [+] added compiler option to force "char" type to be signed
120 # [+] added toolchain option to compile to 32-bit ARM instructions
121 # [+] added toolchain option to disable SWIG search
122 # [+] added platform "armeabi-v7a with VFPV3"
123 # [~] ARM_TARGETS renamed to ARM_TARGET
124 # [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows)
125 # [~] Fixed bug with ANDROID_API_LEVEL variable
126 # [~] turn off SWIG search if it is not found first time
127 # - modified May 2011
128 # [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL
129 # [+] ANDROID_API_LEVEL is detected by toolchain if not specified
130 # [~] added guard to prevent changing of output directories on the first
132 # [~] toolchain exits with error if ARM_TARGET is not recognized
133 # - modified June 2011
134 # [~] default NDK path is updated for version r5c
135 # [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
136 # [~] toolchain install directory is added to linker paths
137 # [-] removed SWIG-related stuff from toolchain
138 # [+] added macro find_host_package, find_host_program to search
139 # packages/programs on the host system
140 # [~] fixed path to STL library
141 # - modified July 2011
142 # [~] fixed options caching
143 # [~] search for all supported NDK versions
144 # [~] allowed spaces in NDK path
145 # - modified September 2011
146 # [~] updated for NDK r6b
147 # - modified November 2011
148 # [*] rewritten for NDK r7
149 # [+] x86 toolchain support (experimental)
150 # [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
151 # [~] improved compiler and linker flags management
152 # [+] support different build flags for Release and Debug configurations
153 # [~] by default compiler flags the same as used by ndk-build (but only
155 # [~] ANDROID_NDK_TOOLCHAIN_ROOT is splitted to ANDROID_STANDALONE_TOOLCHAIN
156 # and ANDROID_TOOLCHAIN_ROOT
157 # [~] ARM_TARGET is renamed to ANDROID_ABI
158 # [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME
159 # [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL
160 # - modified January 2012
161 # [+] added stlport_static support (experimental)
162 # [+] added special check for cygwin
163 # [+] filtered out hidden files (starting with .) while globbing inside NDK
164 # [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
165 # [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
166 # - modified February 2012
167 # [+] updated for NDK r7b
168 # [~] fixed cmake try_compile() command
169 # [~] Fix for missing install_name_tool on OS X
170 # - modified March 2012
171 # [~] fixed incorrect C compiler flags
172 # [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change
173 # [+] improved toolchain loading speed
174 # [+] added assembler language support (.S)
175 # [+] allowed preset search paths and extra search suffixes
176 # - modified April 2012
177 # [+] updated for NDK r7c
178 # [~] fixed most of problems with compiler/linker flags and caching
179 # [+] added option ANDROID_FUNCTION_LEVEL_LINKING
180 # - modified May 2012
181 # [+] updated for NDK r8
182 # [+] added mips architecture support
183 # ------------------------------------------------------------------------------
185 cmake_minimum_required( VERSION 2.6.3 )
187 if( DEFINED CMAKE_CROSSCOMPILING )
188 #subsequent toolchain loading is not really needed
192 get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
193 if( _CMAKE_IN_TRY_COMPILE )
194 include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL )
197 # this one is important
198 set( CMAKE_SYSTEM_NAME Linux )
199 #this one not so much
200 set( CMAKE_SYSTEM_VERSION 1 )
202 set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
203 if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
204 if( CMAKE_HOST_WIN32 )
205 file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
206 set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" )
208 file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS )
209 set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk" )
212 if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH)
213 set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
216 set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
217 set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
218 set( ANDROID_SUPPORTED_ABIS_mipsel "mips" )
220 set( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
221 set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
222 set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )
225 macro( __LIST_FILTER listvar regex )
227 foreach( __val ${${listvar}} )
228 if( __val MATCHES "${regex}" )
229 list( REMOVE_ITEM ${listvar} "${__val}" )
235 macro( __INIT_VARIABLE var_name )
237 foreach( __var ${ARGN} )
238 if( __var STREQUAL "PATH" )
243 if( __test_path AND NOT EXISTS "${${var_name}}" )
244 unset( ${var_name} CACHE )
246 if( "${${var_name}}" STREQUAL "" )
248 foreach( __var ${ARGN} )
249 if( __var STREQUAL "VALUES" )
251 elseif( NOT __var STREQUAL "PATH" )
253 if( __var MATCHES "^OBSOLETE_.*$" )
254 string( REPLACE "OBSOLETE_" "" __var "${__var}" )
257 if( __var MATCHES "^ENV_.*$" )
258 string( REPLACE "ENV_" "" __var "${__var}" )
259 set( __value "$ENV{${__var}}" )
260 elseif( DEFINED ${__var} )
261 set( __value "${${__var}}" )
264 set( __value "${__var}" )
269 if( NOT "${__value}" STREQUAL "" )
271 if( EXISTS "${__value}" )
272 set( ${var_name} "${__value}" )
274 message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." )
279 set( ${var_name} "${__value}" )
281 message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." )
295 macro( __DETECT_NATIVE_API_LEVEL _var _path )
296 SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*$" )
297 FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" )
298 if( NOT __apiFileContent )
299 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." )
301 string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" )
302 unset( __apiFileContent )
303 unset( __ndkApiLevelRegex )
306 macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
307 file( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
308 __LIST_FILTER( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
309 list( LENGTH __gccExePath __gccExePathsCount )
310 if( NOT __gccExePathsCount EQUAL 1 )
311 message( WARNING "Could not uniquely determine machine name for compiler from ${_root}." )
314 get_filename_component( __gccExeName "${__gccExePath}" NAME_WE )
315 string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" )
317 unset( __gccExePath )
318 unset( __gccExePathsCount )
319 unset( __gccExeName )
322 macro( __COPY_IF_DIFFERENT _source _destination )
323 execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_source}" "${_destination}" RESULT_VARIABLE __fileCopyProcess )
324 if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${_destination}")
325 message( SEND_ERROR "Failed copying of ${_source} to the ${_destination}" )
327 unset( __fileCopyProcess )
331 #stl version: by default gnustl_static will be used
332 set( ANDROID_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
333 mark_as_advanced( ANDROID_USE_STLPORT )
335 #fight against cygwin
336 set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools")
337 mark_as_advanced( ANDROID_FORBID_SYGWIN )
338 if( ANDROID_FORBID_SYGWIN )
340 message( FATAL_ERROR "Android NDK and android-cmake toolchain are not welcome Cygwin. It is unlikely that this cmake toolchain will work under cygwin. But if you want to try then you can set cmake variable ANDROID_FORBID_SYGWIN to FALSE and rerun cmake." )
343 if( CMAKE_HOST_WIN32 )
344 #remove cygwin from PATH
345 set( __new_path "$ENV{PATH}")
346 __LIST_FILTER( __new_path "cygwin" )
347 set(ENV{PATH} "${__new_path}")
352 #detect current host platform
353 set( TOOL_OS_SUFFIX "" )
354 if( CMAKE_HOST_APPLE )
355 set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" )
356 elseif( CMAKE_HOST_WIN32 )
357 set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" )
358 set( TOOL_OS_SUFFIX ".exe" )
359 elseif( CMAKE_HOST_UNIX )
360 set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" )
362 message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
365 #see if we have path to Android NDK
366 __INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK )
367 if( NOT ANDROID_NDK )
368 #see if we have path to Android standalone toolchain
369 __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT )
371 if( NOT ANDROID_STANDALONE_TOOLCHAIN )
372 #try to find Android NDK in one of the the default locations
373 set( __ndkSearchPaths )
374 foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} )
375 foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} )
376 list( APPEND __ndkSearchPaths "${__ndkSearchPath}${suffix}" )
379 __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} )
380 unset( __ndkSearchPaths )
383 message( STATUS "Using default path for Android NDK: ${ANDROID_NDK}" )
384 message( STATUS " If you prefer to use a different location, please define a cmake or environment variable: ANDROID_NDK" )
386 #try to find Android standalone toolchain in one of the the default locations
387 __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH )
389 if( ANDROID_STANDALONE_TOOLCHAIN )
390 message( STATUS "Using default path for standalone toolchain ${ANDROID_STANDALONE_TOOLCHAIN}" )
391 message( STATUS " If you prefer to use a different location, please define the variable: ANDROID_STANDALONE_TOOLCHAIN" )
392 endif( ANDROID_STANDALONE_TOOLCHAIN )
394 endif( NOT ANDROID_STANDALONE_TOOLCHAIN )
395 endif( NOT ANDROID_NDK )
397 #remember found paths
399 get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
400 #try to detect change
402 string( LENGTH "${ANDROID_NDK}" __length )
403 string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
404 if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK )
405 message( FATAL_ERROR "It is not possible to change path to the NDK on subsequent run." )
407 unset( __androidNdkPreviousPath )
410 set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" )
411 set( BUILD_WITH_ANDROID_NDK True )
412 elseif( ANDROID_STANDALONE_TOOLCHAIN )
413 get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
414 #try to detect change
416 string( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length )
417 string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidStandaloneToolchainPreviousPath )
418 if( NOT __androidStandaloneToolchainPreviousPath STREQUAL ANDROID_STANDALONE_TOOLCHAIN )
419 message( FATAL_ERROR "It is not possible to change path to the Android standalone toolchain on subsequent run." )
421 unset( __androidStandaloneToolchainPreviousPath )
424 set( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" )
425 set( BUILD_WITH_STANDALONE_TOOLCHAIN True )
427 list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH)
428 message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolcahin.
429 You should either set an environment variable:
430 export ANDROID_NDK=~/my-android-ndk
432 export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain
433 or put the toolchain or NDK in the default path:
434 sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH}
435 sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" )
438 #get all the details about standalone toolchain
439 if( BUILD_WITH_STANDALONE_TOOLCHAIN )
440 __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" )
441 set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
442 set( __availableToolchains "standalone" )
443 __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" )
444 if( NOT __availableToolchainMachines )
445 message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." )
447 if( __availableToolchainMachines MATCHES i686 )
448 set( __availableToolchainArchs "x86" )
449 elseif( __availableToolchainMachines MATCHES arm )
450 set( __availableToolchainArchs "arm" )
451 elseif( __availableToolchainMachines MATCHES mipsel )
452 set( __availableToolchainArchs "mipsel" )
454 if( ANDROID_COMPILER_VERSION )
455 #do not run gcc every time because it is relatevely expencive
456 set( __availableToolchainCompilerVersions "${ANDROID_COMPILER_VERSION}" )
458 execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" --version
459 OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
460 string( REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
464 #get all the details about NDK
465 if( BUILD_WITH_ANDROID_NDK )
466 file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
467 string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
468 file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
469 __LIST_FILTER( __availableToolchains "^[.]" )
470 set( __availableToolchainMachines "" )
471 set( __availableToolchainArchs "" )
472 set( __availableToolchainCompilerVersions "" )
473 foreach( __toolchain ${__availableToolchains} )
474 __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
476 string( REGEX MATCH "[0-9]+.[0-9]+.[0-9]+$" __version "${__toolchain}" )
477 string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
478 list( APPEND __availableToolchainMachines ${__machine} )
479 list( APPEND __availableToolchainArchs ${__arch} )
480 list( APPEND __availableToolchainCompilerVersions ${__version} )
482 list( REMOVE_ITEM __availableToolchains "${__toolchain}" )
485 if( NOT __availableToolchains )
486 message( FATAL_ERROR "Could not any working toolchain in the NDK. Probably your Android NDK is broken." )
490 #build list of available ABIs
491 if( NOT ANDROID_SUPPORTED_ABIS )
492 set( ANDROID_SUPPORTED_ABIS "" )
493 set( __uniqToolchainArchNames ${__availableToolchainArchs} )
494 list( REMOVE_DUPLICATES __uniqToolchainArchNames )
495 list( SORT __uniqToolchainArchNames )
496 foreach( __arch ${__uniqToolchainArchNames} )
497 list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
499 unset( __uniqToolchainArchNames )
500 if( NOT ANDROID_SUPPORTED_ABIS )
501 message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
506 __INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${ANDROID_SUPPORTED_ABIS} )
507 #verify that target ABI is supported
508 list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx )
509 if( __androidAbiIdx EQUAL -1 )
510 string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" )
511 message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain.
512 Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\"
515 unset( __androidAbiIdx )
518 set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
520 #set target ABI options
521 if( ANDROID_ABI STREQUAL "x86" )
523 set( ANDROID_NDK_ABI_NAME "x86" )
524 set( ANDROID_ARCH_NAME "x86" )
525 set( ANDROID_ARCH_FULLNAME "x86" )
526 set( CMAKE_SYSTEM_PROCESSOR "i686" )
527 elseif( ANDROID_ABI STREQUAL "mips" )
529 set( ANDROID_NDK_ABI_NAME "mips" )
530 set( ANDROID_ARCH_NAME "mips" )
531 set( ANDROID_ARCH_FULLNAME "mipsel" )
532 set( CMAKE_SYSTEM_PROCESSOR "mips" )
533 elseif( ANDROID_ABI STREQUAL "armeabi" )
535 set( ANDROID_NDK_ABI_NAME "armeabi" )
536 set( ANDROID_ARCH_NAME "arm" )
537 set( ANDROID_ARCH_FULLNAME "arm" )
538 set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
539 elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
540 set( ARMEABI_V6 true )
541 set( ANDROID_NDK_ABI_NAME "armeabi" )
542 set( ANDROID_ARCH_NAME "arm" )
543 set( ANDROID_ARCH_FULLNAME "arm" )
544 set( CMAKE_SYSTEM_PROCESSOR "armv6" )
545 #need always fallback to older platform
547 elseif( ANDROID_ABI STREQUAL "armeabi-v7a")
548 set( ARMEABI_V7A true )
549 set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
550 set( ANDROID_ARCH_NAME "arm" )
551 set( ANDROID_ARCH_FULLNAME "arm" )
552 set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
553 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
554 set( ARMEABI_V7A true )
555 set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
556 set( ANDROID_ARCH_NAME "arm" )
557 set( ANDROID_ARCH_FULLNAME "arm" )
558 set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
560 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
561 set( ARMEABI_V7A true )
562 set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
563 set( ANDROID_ARCH_NAME "arm" )
564 set( ANDROID_ARCH_FULLNAME "arm" )
565 set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
569 message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." )
572 if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" )
574 #it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run...
575 file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" )
578 set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." )
579 if( CMAKE_VERSION VERSION_GREATER "2.8" )
580 list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
581 set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
584 if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
585 __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF )
586 set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE )
587 mark_as_advanced( ANDROID_FORCE_ARM_BUILD )
589 unset( ANDROID_FORCE_ARM_BUILD CACHE )
593 if( ANDROID_TOOLCHAIN_NAME )
594 list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx )
595 if( __toolchainIdx EQUAL -1 )
596 message( FATAL_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing. You need to remove CMakeCache.txt and rerun cmake manually to change the toolchain" )
598 list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
599 if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
600 message( SEND_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
603 set( __toolchainIdx -1 )
604 set( __applicableToolchains "" )
605 set( __toolchainMaxVersion "0.0.0" )
606 list( LENGTH __availableToolchains __availableToolchainsCount )
607 math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" )
608 foreach( __idx RANGE ${__availableToolchainsCount} )
609 list( GET __availableToolchainArchs ${__idx} __toolchainArch )
610 if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
611 list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
612 if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
613 set( __toolchainMaxVersion "${__toolchainVersion}" )
614 set( __toolchainIdx ${__idx} )
618 unset( __availableToolchainsCount )
619 unset( __toolchainMaxVersion )
620 unset( __toolchainVersion )
622 unset( __toolchainArch )
623 if( __toolchainIdx EQUAL -1 )
624 message( FATAL_ERROR "No one of available compiler toolchains is able to compile for ${ANDROID_ARCH_NAME} platform." )
626 list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME )
627 list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME )
628 list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION )
629 set( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" )
630 set( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" )
631 unset( __toolchainIdx )
632 unset( __availableToolchains )
633 unset( __availableToolchainMachines )
634 unset( __availableToolchainArchs )
635 unset( __availableToolchainCompilerVersions )
637 #choose native API level
638 __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
639 string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
641 list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
642 if( __levelIdx EQUAL -1 )
643 message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
646 if( BUILD_WITH_ANDROID_NDK )
647 __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
648 if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
649 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." )
651 unset( __realApiLevel )
653 set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
654 if( CMAKE_VERSION VERSION_GREATER "2.8" )
655 list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
656 set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
660 if( BUILD_WITH_STANDALONE_TOOLCHAIN )
661 set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
662 set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
663 set( __stlLibPath "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
665 if( BUILD_WITH_ANDROID_NDK )
666 set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
667 set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
668 if( ANDROID_USE_STLPORT )
669 set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
670 set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}" )
672 set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include" )
673 set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}" )
677 # specify the cross compiler
678 set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "gcc" )
679 set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "g++" )
680 set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "Assembler" )
681 if( CMAKE_VERSION VERSION_LESS 2.8.5 )
682 set( CMAKE_ASM_COMPILER_ARG1 "-c" )
684 #there may be a way to make cmake deduce these TODO deduce the rest of the tools
685 set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
686 set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
687 set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
688 set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" )
689 set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
690 set( CMAKE_OBJDUMP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" )
691 set( CMAKE_RANLIB "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" )
692 set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" )
694 find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool )
695 if( NOT CMAKE_INSTALL_NAME_TOOL )
696 message( FATAL_ERROR "Could not find install_name_tool, please check your installation." )
698 mark_as_advanced( CMAKE_INSTALL_NAME_TOOL )
701 set( ANDROID_SYSTEM_INCLUDE_DIRS "" )
702 set( ANDROID_SYSTEM_LIB_DIRS "" )
704 #setup output directories
705 set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
706 set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
708 if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
709 set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
711 set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
713 set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
716 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
717 if( __stlIncludePath AND EXISTS "${__stlIncludePath}" )
718 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" )
722 if( __stlLibPath AND EXISTS "${__stlLibPath}/include" )
723 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" )
725 if( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb/bits" )
726 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
727 elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
728 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
729 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
730 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
731 elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/bits" )
732 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
735 #flags and definitions
736 if(ANDROID_SYSROOT MATCHES "[ ;\"]")
737 set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
738 # quotes will break try_compile and compiler identification
739 message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
741 set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
744 remove_definitions( -DANDROID )
745 add_definitions( -DANDROID )
747 # Force set compilers because standard identification works badly for us
748 include( CMakeForceCompiler )
749 CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
750 set( CMAKE_C_PLATFORM_ID Linux )
751 set( CMAKE_C_SIZEOF_DATA_PTR 4 )
752 set( CMAKE_C_HAS_ISYSROOT 1 )
753 set( CMAKE_C_COMPILER_ABI ELF )
754 CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
755 set( CMAKE_CXX_PLATFORM_ID Linux )
756 set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
757 set( CMAKE_CXX_HAS_ISYSROOT 1 )
758 set( CMAKE_CXX_COMPILER_ABI ELF )
759 #force ASM compiler (required for CMake < 2.8.5)
760 set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
761 set( CMAKE_ASM_COMPILER_ID GNU )
762 set( CMAKE_ASM_COMPILER_WORKS TRUE )
763 set( CMAKE_ASM_COMPILER_FORCED TRUE )
764 set( CMAKE_COMPILER_IS_GNUASM 1)
767 if( ARMEABI OR ARMEABI_V7A )
768 # NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance
769 set( CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" )
770 set( CMAKE_C_FLAGS "-fPIC -Wno-psabi" )
771 remove_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
772 add_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
773 # extra arm-specific flags
774 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
776 set( CMAKE_CXX_FLAGS "-funwind-tables" )
777 set( CMAKE_C_FLAGS "-funwind-tables" )
779 set( CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
780 set( CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
781 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
783 set( CMAKE_CXX_FLAGS "" )
784 set( CMAKE_C_FLAGS "" )
787 if( ANDROID_USE_STLPORT )
788 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
789 set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" )
791 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions" )
792 set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
795 #release and debug flags
796 if( ARMEABI OR ARMEABI_V7A )
797 if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
798 #It is recommended to use the -mthumb compiler flag to force the generation
799 #of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones).
800 # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
801 set( CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" )
802 set( CMAKE_C_FLAGS_RELEASE "-mthumb -O3" )
803 set( CMAKE_CXX_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
804 set( CMAKE_C_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
806 # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI
807 # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
808 set( CMAKE_CXX_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
809 set( CMAKE_C_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
810 set( CMAKE_CXX_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
811 set( CMAKE_C_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
814 set( CMAKE_CXX_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
815 set( CMAKE_C_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
816 set( CMAKE_CXX_FLAGS_DEBUG "-O0 -finline-limit=300" )
817 set( CMAKE_C_FLAGS_DEBUG "-O0 -finline-limit=300" )
819 set( CMAKE_CXX_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
820 set( CMAKE_C_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
821 set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
822 set( CMAKE_C_FLAGS_DEBUG "-O0 -g" )
824 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
825 set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
826 set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
827 set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
831 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" )
833 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" )
835 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" )
837 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfp" )
840 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
842 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
844 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" )#sse?
848 list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}" "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
849 set( ANDROID_LINKER_FLAGS "" )
851 if( ANDROID_USE_STLPORT )
852 if( EXISTS "${__stlLibPath}/libstlport_static.a" )
853 __COPY_IF_DIFFERENT( "${__stlLibPath}/libstlport_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
855 if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
856 set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--start-group -lstlport_static" )
858 else( ANDROID_USE_STLPORT )
859 if( EXISTS "${__stlLibPath}/libgnustl_static.a" )
860 __COPY_IF_DIFFERENT( "${__stlLibPath}/libgnustl_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
861 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
862 __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
863 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
864 __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
865 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/thumb/libstdc++.a" )
866 __COPY_IF_DIFFERENT( "${__stlLibPath}/thumb/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
867 elseif( EXISTS "${__stlLibPath}/libstdc++.a" )
868 __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
870 if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
871 set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lstdc++" )
874 #gcc exception & rtti support
875 if( EXISTS "${__stlLibPath}/libsupc++.a" )
876 __COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
877 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" )
878 __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
879 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
880 __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
881 elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" )
882 __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
883 elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" )
884 __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
886 if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
887 set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lsupc++" )
889 endif( ANDROID_USE_STLPORT )
891 #cleanup for STL search
892 unset( __stlIncludePath )
893 unset( __stlLibPath )
896 __INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
897 set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
898 mark_as_advanced( ANDROID_NO_UNDEFINED )
899 if( ANDROID_NO_UNDEFINED )
900 set( ANDROID_LINKER_FLAGS "-Wl,--no-undefined ${ANDROID_LINKER_FLAGS}" )
903 if (ANDROID_NDK MATCHES "-r[56].?$")
904 #libGLESv2.so in NDK's prior to r7 refers to exteranal symbols. So this flag option is required for all projects using OpenGL from native.
905 __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON )
907 __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF )
910 set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
911 mark_as_advanced( ANDROID_SO_UNDEFINED )
912 if( ANDROID_SO_UNDEFINED )
913 set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
916 __INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
917 set( ANDROID_FUNCTION_LEVEL_LINKING ON CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
918 mark_as_advanced( ANDROID_FUNCTION_LEVEL_LINKING )
919 if( ANDROID_FUNCTION_LEVEL_LINKING )
920 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
921 set( ANDROID_LINKER_FLAGS "-Wl,--gc-sections ${ANDROID_LINKER_FLAGS}" )
925 # this is *required* to use the following linker flags that routes around
926 # a CPU bug in some Cortex-A8 implementations:
927 set( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
931 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
932 set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags" )
933 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
934 set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
935 set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
936 set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
937 set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
938 set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
939 set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )
941 include_directories( SYSTEM ${ANDROID_SYSTEM_INCLUDE_DIRS} )
942 link_directories( ${ANDROID_SYSTEM_LIB_DIRS} )
945 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Extra Android compiler flags")
946 set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Extra Android linker flags")
947 set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
948 set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
949 if( MIPS AND BUILD_WITH_ANDROID_NDK )
950 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
951 set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
952 set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
954 set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
955 set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
956 set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
959 #set these global flags for cmake client scripts to change behavior
961 set( BUILD_ANDROID True )
963 # where is the target environment
964 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" )
966 # only search for libraries and includes in the ndk toolchain
967 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
968 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
969 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
972 #macro to find packages on the host OS
973 macro( find_host_package )
974 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
975 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
976 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
977 if( CMAKE_HOST_WIN32 )
980 elseif( CMAKE_HOST_APPLE )
984 find_package( ${ARGN} )
988 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
989 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
990 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
994 #macro to find programs on the host OS
995 macro( find_host_program )
996 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
997 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
998 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
999 if( CMAKE_HOST_WIN32 )
1002 elseif( CMAKE_HOST_APPLE )
1006 find_program( ${ARGN} )
1010 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
1011 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
1012 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
1016 macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
1017 if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" )
1018 set( ${VAR} "armeabi" )
1019 elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
1020 set( ${VAR} "armeabi-v7a" )
1021 elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
1024 set( ${VAR} "unknown" )
1029 # export toolchain settings for the try_compile() command
1030 if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
1031 set( __toolchain_config "")
1032 foreach( __var ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING )
1033 if( DEFINED ${__var} )
1034 set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" )\n" )
1037 file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/android.toolchain.config.cmake" "${__toolchain_config}" )
1038 unset( __toolchain_config )
1042 # set some obsolete variables for backward compatibility
1043 set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
1044 mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES )
1045 if( ANDROID_SET_OBSOLETE_VARIABLES )
1046 set( ANDROID_API_LEVEL ${ANDROID_NATIVE_API_LEVEL} )
1047 set( ARM_TARGET "${ANDROID_ABI}" )
1048 set( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" )
1052 # Variables controlling behavior or set by cmake toolchain:
1053 # ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
1054 # ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
1055 # ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
1056 # ANDROID_USE_STLPORT : OFF/ON - EXPERIMENTAL!!!
1057 # ANDROID_FORBID_SYGWIN : ON/OFF
1058 # ANDROID_NO_UNDEFINED : ON/OFF
1059 # ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version)
1060 # ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF
1061 # Variables that takes effect only at first run:
1062 # ANDROID_FORCE_ARM_BUILD : ON/OFF
1063 # LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
1064 # Can be set only at the first run:
1066 # ANDROID_STANDALONE_TOOLCHAIN
1068 # ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL
1069 # ARM_TARGET : superseded by ANDROID_ABI
1070 # ARM_TARGETS : superseded by ANDROID_ABI (can be set only)
1071 # ANDROID_NDK_TOOLCHAIN_ROOT : superseded by ANDROID_STANDALONE_TOOLCHAIN (can be set only)
1072 # ANDROID_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL (completely removed)
1074 # Primary read-only variables:
1075 # ANDROID : always TRUE
1076 # ARMEABI : TRUE for arm v6 and older devices
1077 # ARMEABI_V6 : TRUE for arm v6
1078 # ARMEABI_V7A : TRUE for arm v7a
1079 # NEON : TRUE if NEON unit is enabled
1080 # VFPV3 : TRUE if VFP version 3 is enabled
1081 # X86 : TRUE if configured for x86
1082 # BUILD_ANDROID : always TRUE
1083 # BUILD_WITH_ANDROID_NDK : TRUE if NDK is used
1084 # BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
1085 # ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
1086 # ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a" or "x86" depending on ANDROID_ABI
1087 # ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
1088 # TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
1089 # ANDROID_SYSROOT : path to the compiler sysroot
1090 # ANDROID_SYSTEM_INCLUDE_DIRS
1091 # ANDROID_SYSTEM_LIB_DIRS
1093 # ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
1095 # Secondary (less stable) read-only variables:
1096 # ANDROID_COMPILER_VERSION : GCC version used
1097 # ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform
1098 # ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
1099 # ANDROID_TOOLCHAIN_NAME : "standalone", "arm-linux-androideabi-4.4.3" or "x86-4.4.3" or something similar.
1100 # ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
1101 # ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK)
1102 # ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK
1105 # ANDROID_DEFAULT_NDK_API_LEVEL
1106 # ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH}
1107 # ANDROID_NDK_SEARCH_PATHS
1108 # ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH
1109 # ANDROID_SUPPORTED_ABIS_${ARCH}
1110 # ANDROID_SUPPORTED_NDK_VERSIONS