@ -1,6 +1,6 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# A n d r o i d C M a k e t o o l c h a i n f i l e , f o r u s e w i t h t h e A n d r o i d N D K r 5 - r 8
# R e q u i r e s c m a k e 2 . 6 . 3 o r newer ( 2.8.3 or newer is recommended ) .
# R e q u i r e s c m a k e 2 . 6 . 3 o r newer ( 2.8.5 or newer is recommended ) .
# S e e h o m e p a g e : h t t p : / / c o d e . g o o g l e . c o m / p / a n d r o i d - c m a k e /
#
# T h e f i l e i s m a n t a i n e d b y t h e O p e n C V p r o j e c t . A n d a l s o c a n b e f o u n d a t
@ -44,7 +44,8 @@
# A N D R O I D _ A B I = a r m e a b i - v 7 a - s p e c i f i e s t h e t a r g e t A p p l i c a t i o n B i n a r y
# Interface ( ABI ) . T h i s o p t i o n n e a r l y m a t c h e s t o t h e A P P _ A B I v a r i a b l e
# u s e d b y n d k - b u i l d t o o l f r o m A n d r o i d N D K .
# P o s s i b l e v a l u e s a r e :
#
# P o s s i b l e t a r g e t s a r e :
# " a r m e a b i " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# " a r m e a b i - v 7 a " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
@ -55,7 +56,9 @@
# s e t s V F P V 3 a s f l o a t i n g - p o i n t unit ( has 32 registers instead of 16 ) .
# " a r m e a b i - v 6 w i t h V F P " - t u n e d f o r A R M v 6 p r o c e s s o r s h a v i n g V F P .
# " x 8 6 " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# " m i p s " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e
# ( n o t t e s t e s o n r e a l d e v i c e s )
#
# A N D R O I D _ N A T I V E _ A P I _ L E V E L = a n d r o i d - 8 - l e v e l o f A n d r o i d A P I c o m p i l e f o r .
# O p t i o n i s r e a d - o n l y w h e n s t a n d a l o n e t o o l c h a i n u s e d .
@ -183,12 +186,13 @@
# - m o d i f i e d A u g u s t 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 8 b
# [ ~ ] a l l i n t e r m e d i a t e f i l e s g e n e r a t e d b y t o o l c h a i n a r e m o v e d i n t o C M a k e F i l e s
# [ ~ ] l i b s t d c + + a n d l i b s u p c a r e r e m o v e d f r o m e x p l i c i t l i n k l i b r a r i e s
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmake_minimum_required ( VERSION 2.6.3 )
if ( DEFINED CMAKE_CROSSCOMPILING )
# s u b s e q u e n t t o o l c h a i n l o a d i n g i s n o t r e a l l y n e e d e d
# s u b s e q u e n t t o o l c h a i n l o a d i n g i s n o t r e a l l y n e e d e d
return ( )
endif ( )
@ -199,7 +203,7 @@ endif()
# t h i s o n e i s i m p o r t a n t
set ( CMAKE_SYSTEM_NAME Linux )
# t h i s o n e n o t s o m u c h
# t h i s o n e n o t s o m u c h
set ( CMAKE_SYSTEM_VERSION 1 )
set ( ANDROID_SUPPORTED_NDK_VERSIONS ${ ANDROID_EXTRA_NDK_VERSIONS } -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
@ -331,11 +335,11 @@ macro( __COPY_IF_DIFFERENT _source _destination )
endmacro ( )
# s t l v e r s i o n : b y d e f a u l t g n u s t l _ s t a t i c w i l l b e u s e d
# s t l v e r s i o n : b y d e f a u l t g n u s t l _ s t a t i c w i l l b e u s e d
set ( ANDROID_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static" )
mark_as_advanced ( ANDROID_USE_STLPORT )
# f i g h t a g a i n s t c y g w i n
# f i g h t a g a i n s t c y g w i n
set ( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools" )
mark_as_advanced ( ANDROID_FORBID_SYGWIN )
if ( ANDROID_FORBID_SYGWIN )
@ -344,7 +348,7 @@ if( ANDROID_FORBID_SYGWIN )
endif ( )
if ( CMAKE_HOST_WIN32 )
# r e m o v e c y g w i n f r o m P A T H
# r e m o v e c y g w i n f r o m P A T H
set ( __new_path "$ENV{PATH}" )
__LIST_FILTER ( __new_path "cygwin" )
set ( ENV{PATH} "${__new_path}" )
@ -352,7 +356,7 @@ if( ANDROID_FORBID_SYGWIN )
endif ( )
endif ( )
# d e t e c t c u r r e n t h o s t p l a t f o r m
# d e t e c t c u r r e n t h o s t p l a t f o r m
set ( TOOL_OS_SUFFIX "" )
if ( CMAKE_HOST_APPLE )
set ( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" )
@ -365,10 +369,10 @@ else()
message ( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
endif ( )
# s e e i f w e h a v e p a t h t o A n d r o i d N D K
# s e e i f w e h a v e p a t h t o A n d r o i d N D K
__INIT_VARIABLE ( ANDROID_NDK PATH ENV_ANDROID_NDK )
if ( NOT ANDROID_NDK )
# s e e i f w e h a v e p a t h t o A n d r o i d s t a n d a l o n e t o o l c h a i n
# s e e i f w e h a v e p a t h t o A n d r o i d s t a n d a l o n e t o o l c h a i n
__INIT_VARIABLE ( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT )
if ( NOT ANDROID_STANDALONE_TOOLCHAIN )
@ -397,10 +401,10 @@ if( NOT ANDROID_NDK )
endif ( NOT ANDROID_STANDALONE_TOOLCHAIN )
endif ( NOT ANDROID_NDK )
# r e m e m b e r f o u n d p a t h s
# r e m e m b e r f o u n d p a t h s
if ( ANDROID_NDK )
get_filename_component ( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
# t r y t o d e t e c t c h a n g e
# t r y t o d e t e c t c h a n g e
if ( CMAKE_AR )
string ( LENGTH "${ANDROID_NDK}" __length )
string ( SUBSTRING "${CMAKE_AR}" 0 ${ __length } __androidNdkPreviousPath )
@ -414,7 +418,7 @@ if( ANDROID_NDK )
set ( BUILD_WITH_ANDROID_NDK True )
elseif ( ANDROID_STANDALONE_TOOLCHAIN )
get_filename_component ( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
# t r y t o d e t e c t c h a n g e
# t r y t o d e t e c t c h a n g e
if ( CMAKE_AR )
string ( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length )
string ( SUBSTRING "${CMAKE_AR}" 0 ${ __length } __androidStandaloneToolchainPreviousPath )
@ -438,7 +442,7 @@ else()
s u d o l n - s ~ / m y - a n d r o i d - t o o l c h a i n $ { A N D R O I D _ S T A N D A L O N E _ T O O L C H A I N _ S E A R C H _ P A T H } " )
endif ( )
# g e t a l l t h e d e t a i l s a b o u t s t a n d a l o n e t o o l c h a i n
# g e t a l l t h e d e t a i l s a b o u t s t a n d a l o n e t o o l c h a i n
if ( BUILD_WITH_STANDALONE_TOOLCHAIN )
__DETECT_NATIVE_API_LEVEL ( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" )
set ( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ ANDROID_SUPPORTED_NATIVE_API_LEVELS } )
@ -455,7 +459,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
set ( __availableToolchainArchs "mipsel" )
endif ( )
if ( ANDROID_COMPILER_VERSION )
# d o n o t r u n g c c e v e r y t i m e b e c a u s e i t i s r e l a t e v e l y e x p e n c i v e
# d o n o t r u n g c c e v e r y t i m e b e c a u s e i t i s r e l a t e v e l y e x p e n c i v e
set ( __availableToolchainCompilerVersions "${ANDROID_COMPILER_VERSION}" )
else ( )
execute_process ( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" --version
@ -464,7 +468,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
endif ( )
endif ( )
# g e t a l l t h e d e t a i l s a b o u t N D K
# g e t a l l t h e d e t a i l s a b o u t N D K
if ( BUILD_WITH_ANDROID_NDK )
file ( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
string ( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
@ -490,7 +494,7 @@ if( BUILD_WITH_ANDROID_NDK )
endif ( )
endif ( )
# b u i l d l i s t o f a v a i l a b l e A B I s
# b u i l d l i s t o f a v a i l a b l e A B I s
if ( NOT ANDROID_SUPPORTED_ABIS )
set ( ANDROID_SUPPORTED_ABIS "" )
set ( __uniqToolchainArchNames ${ __availableToolchainArchs } )
@ -505,9 +509,9 @@ if( NOT ANDROID_SUPPORTED_ABIS )
endif ( )
endif ( )
# c h o o s e t a r g e t A B I
# c h o o s e t a r g e t A B I
__INIT_VARIABLE ( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${ ANDROID_SUPPORTED_ABIS } )
# v e r i f y t h a t t a r g e t A B I i s s u p p o r t e d
# v e r i f y t h a t t a r g e t A B I i s s u p p o r t e d
list ( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx )
if ( __androidAbiIdx EQUAL -1 )
string ( REPLACE ";" "\" , \"", PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" )
@ -517,10 +521,10 @@ if( __androidAbiIdx EQUAL -1 )
endif ( )
unset ( __androidAbiIdx )
# r e m e m b e r t a r g e t A B I
# r e m e m b e r t a r g e t A B I
set ( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
# s e t t a r g e t A B I o p t i o n s
# s e t t a r g e t A B I o p t i o n s
if ( ANDROID_ABI STREQUAL "x86" )
set ( X86 true )
set ( ANDROID_NDK_ABI_NAME "x86" )
@ -545,7 +549,7 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( CMAKE_SYSTEM_PROCESSOR "armv6" )
# n e e d a l w a y s f a l l b a c k t o o l d e r p l a t f o r m
# n e e d a l w a y s f a l l b a c k t o o l d e r p l a t f o r m
set ( ARMEABI true )
elseif ( ANDROID_ABI STREQUAL "armeabi-v7a" )
set ( ARMEABI_V7A true )
@ -573,8 +577,8 @@ else()
endif ( )
if ( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" )
# r e a l l y d i r t y h a c k
# i t i s n o t p o s s i b l e t o c h a n g e C M A K E _ S Y S T E M _ P R O C E S S O R a f t e r t h e f i r s t r u n . . .
# r e a l l y d i r t y h a c k
# i t i s n o t p o s s i b l e t o c h a n g e C M A K E _ S Y S T E M _ P R O C E S S O R a f t e r t h e f i r s t r u n . . .
file ( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \" ${ CMAKE_SYSTEM_PROCESSOR } \")\n" )
endif ( )
@ -592,7 +596,7 @@ else()
unset ( ANDROID_FORCE_ARM_BUILD CACHE )
endif ( )
# c h o o s e t o o l c h a i n
# c h o o s e t o o l c h a i n
if ( ANDROID_TOOLCHAIN_NAME )
list ( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx )
if ( __toolchainIdx EQUAL -1 )
@ -637,10 +641,10 @@ unset( __availableToolchainMachines )
unset ( __availableToolchainArchs )
unset ( __availableToolchainCompilerVersions )
# c h o o s e n a t i v e A P I l e v e l
# c h o o s e n a t i v e A P I l e v e l
__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 )
string ( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
# v a l i d a t e
# v a l i d a t e
list ( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
if ( __levelIdx EQUAL -1 )
message ( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
@ -659,7 +663,7 @@ if( CMAKE_VERSION VERSION_GREATER "2.8" )
set_property ( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ ANDROID_SUPPORTED_NATIVE_API_LEVELS } )
endif ( )
# s e t u p p a t h s
# s e t u p p a t h s
if ( BUILD_WITH_STANDALONE_TOOLCHAIN )
set ( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set ( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
@ -689,7 +693,7 @@ set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHI
if ( CMAKE_VERSION VERSION_LESS 2.8.5 )
set ( CMAKE_ASM_COMPILER_ARG1 "-c" )
endif ( )
# t h e r e m a y b e a w a y t o m a k e c m a k e d e d u c e t h e s e T O D O d e d u c e t h e r e s t o f t h e t o o l s
# t h e r e m a y b e a w a y t o m a k e c m a k e d e d u c e t h e s e T O D O d e d u c e t h e r e s t o f t h e t o o l s
set ( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
set ( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
set ( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
@ -705,11 +709,12 @@ if( APPLE )
endif ( )
mark_as_advanced ( CMAKE_INSTALL_NAME_TOOL )
endif ( )
# e x p o r t d i r e c t o r i e s
# e x p o r t d i r e c t o r i e s
set ( ANDROID_SYSTEM_INCLUDE_DIRS "" )
set ( ANDROID_SYSTEM_LIB_DIRS "" )
# s e t u p o u t p u t d i r e c t o r i e s
# s e t u p o u t p u t d i r e c t o r i e s
set ( LIBRARY_OUTPUT_PATH_ROOT ${ CMAKE_SOURCE_DIR } CACHE PATH "root for library output, set this to change where android libs are installed to" )
set ( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
@ -722,13 +727,13 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
set ( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
endif ( )
# i n c l u d e s
# i n c l u d e s
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
if ( __stlIncludePath AND EXISTS "${__stlIncludePath}" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" )
endif ( )
# S T L b i t s i n c l u d e s
# c + + b i t s i n c l u d e s
if ( __stlLibPath AND EXISTS "${__stlLibPath}/include" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" )
endif ( )
@ -742,7 +747,7 @@ elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/incl
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
endif ( )
# f l a g s a n d d e f i n i t i o n s
# f l a g s a n d d e f i n i t i o n s
if ( ANDROID_SYSROOT MATCHES "[ ;\" ] " )
set ( ANDROID_CXX_FLAGS "--sysroot=\" ${ ANDROID_SYSROOT } \"" )
# q u o t e s w i l l b r e a k t r y _ c o m p i l e a n d c o m p i l e r i d e n t i f i c a t i o n
@ -766,7 +771,7 @@ set( CMAKE_CXX_PLATFORM_ID Linux )
set ( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
set ( CMAKE_CXX_HAS_ISYSROOT 1 )
set ( CMAKE_CXX_COMPILER_ABI ELF )
# f o r c e A S M compiler ( required for CMake < 2.8.5 )
# f o r c e A S M compiler ( required for CMake < 2.8.5 )
set ( CMAKE_ASM_COMPILER_ID_RUN TRUE )
set ( CMAKE_ASM_COMPILER_ID GNU )
set ( CMAKE_ASM_COMPILER_WORKS TRUE )
@ -796,17 +801,17 @@ endif()
if ( ANDROID_USE_STLPORT )
set ( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
set ( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-rtti -fno- exceptions" )
set ( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-exceptions" )
else ( )
set ( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fexceptions" )
set ( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fexceptions" )
endif ( )
# r e l e a s e a n d d e b u g f l a g s
# r e l e a s e a n d d e b u g f l a g s
if ( ARMEABI OR ARMEABI_V7A )
if ( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
# I t i s r e c o m m e n d e d t o u s e t h e - m t h u m b c o m p i l e r f l a g t o f o r c e t h e g e n e r a t i o n
# o f 1 6 - b i t T h u m b - 1 instructions ( the default being 32-bit ARM ones ) .
# I t i s r e c o m m e n d e d t o u s e t h e - m t h u m b c o m p i l e r f l a g t o f o r c e t h e g e n e r a t i o n
# o f 1 6 - b i t T h u m b - 1 instructions ( the default being 32-bit ARM ones ) .
# O 3 i n s t e a d o f O 2 / O s i n r e l e a s e m o d e - l i k e c m a k e s e t s f o r d e s k t o p g c c
set ( _CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" )
set ( _CMAKE_C_FLAGS_RELEASE "-mthumb -O3" )
@ -836,7 +841,7 @@ set( _CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer
set ( _CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
set ( _CMAKE_C_FLAGS_DEBUG "${_CMAKE_C_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
# A B I - s p e c i f i c f l a g s
# A B I - s p e c i f i c f l a g s
if ( ARMEABI_V7A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" )
if ( NEON )
@ -854,19 +859,18 @@ elseif( X86 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" ) # s s e ?
endif ( )
# l i n k e r f l a g s
# l i n k e r f l a g s
if ( NOT DEFINED __ndklibspath )
set ( __ndklibspath "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ndklibs/${ANDROID_NDK_ABI_NAME}" )
endif ( )
list ( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" "${ CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
list ( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
set ( ANDROID_LINKER_FLAGS "" )
# S T L
# S T L
if ( ANDROID_USE_STLPORT )
if ( EXISTS "${__stlLibPath}/libstlport_static.a" )
__COPY_IF_DIFFERENT ( "${__stlLibPath}/libstlport_static.a" "${__ndklibspath}/libstlport_static.a" )
endif ( )
if ( EXISTS "${__ndklibspath}/libstlport_static.a" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--start-group -lstlport_static" )
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \" ${ __stlLibPath } /libstlport_static.a\ "" )
set ( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \" ${ __stlLibPath } /libstlport_static.a\ "" )
endif ( )
else ( ANDROID_USE_STLPORT )
if ( EXISTS "${__stlLibPath}/libgnustl_static.a" )
@ -880,11 +884,6 @@ else( ANDROID_USE_STLPORT )
elseif ( EXISTS "${__stlLibPath}/libstdc++.a" )
__COPY_IF_DIFFERENT ( "${__stlLibPath}/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
endif ( )
if ( EXISTS "${__ndklibspath}/libstdc++.a" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lstdc++" )
endif ( )
# g c c e x c e p t i o n & r t t i s u p p o r t
if ( EXISTS "${__stlLibPath}/libsupc++.a" )
__COPY_IF_DIFFERENT ( "${__stlLibPath}/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
elseif ( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" )
@ -896,16 +895,14 @@ else( ANDROID_USE_STLPORT )
elseif ( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" )
__COPY_IF_DIFFERENT ( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
endif ( )
if ( EXISTS "${__ndklibspath}/libsupc++.a" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lsupc++" )
endif ( )
list ( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" )
endif ( ANDROID_USE_STLPORT )
# c l e a n u p f o r S T L s e a r c h
# c l e a n u p f o r S T L s e a r c h
unset ( __stlIncludePath )
unset ( __stlLibPath )
# o t h e r l i n k e r f l a g s
# o t h e r l i n k e r f l a g s
__INIT_VARIABLE ( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
set ( ANDROID_NO_UNDEFINED ${ ANDROID_NO_UNDEFINED } CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
mark_as_advanced ( ANDROID_NO_UNDEFINED )
@ -914,7 +911,7 @@ if( ANDROID_NO_UNDEFINED )
endif ( )
if ( ANDROID_NDK MATCHES "-r[56].?$" )
# l i b G L E S v 2 . s o i n N D K ' s p r i o r t o r 7 r e f e r s t o e x t e r a n a l s y m b o l s . S o t h i s f l a g o p t i o n i s r e q u i r e d f o r a l l p r o j e c t s u s i n g O p e n G L f r o m n a t i v e .
# l i b G L E S v 2 . s o i n N D K ' s p r i o r t o r 7 r e f e r s t o e x t e r a n a l s y m b o l s . S o t h i s f l a g o p t i o n i s r e q u i r e d f o r a l l p r o j e c t s u s i n g O p e n G L f r o m n a t i v e .
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES ON )
else ( )
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES OFF )
@ -940,7 +937,7 @@ if( ARMEABI_V7A )
set ( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
endif ( )
# c a c h e f l a g s
# c a c h e f l a g s
set ( CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
set ( CMAKE_C_FLAGS "${_CMAKE_C_FLAGS}" CACHE STRING "c flags" )
set ( CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
@ -954,7 +951,7 @@ set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )
include_directories ( SYSTEM ${ ANDROID_SYSTEM_INCLUDE_DIRS } )
link_directories ( ${ ANDROID_SYSTEM_LIB_DIRS } )
# f i n i s h f l a g s
# f i n i s h f l a g s
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Extra Android compiler flags" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Extra Android linker flags" )
set ( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
@ -969,7 +966,7 @@ else()
set ( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
endif ( )
# s e t t h e s e g l o b a l f l a g s f o r c m a k e c l i e n t s c r i p t s t o c h a n g e b e h a v i o r
# s e t t h e s e g l o b a l f l a g s f o r c m a k e c l i e n t s c r i p t s t o c h a n g e b e h a v i o r
set ( ANDROID True )
set ( BUILD_ANDROID True )
@ -982,7 +979,7 @@ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
# m a c r o t o f i n d p a c k a g e s o n t h e h o s t O S
# m a c r o t o f i n d p a c k a g e s o n t h e h o s t O S
macro ( find_host_package )
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
@ -1004,7 +1001,7 @@ macro( find_host_package )
endmacro ( )
# m a c r o t o f i n d p r o g r a m s o n t h e h o s t O S
# m a c r o t o f i n d p r o g r a m s o n t h e h o s t O S
macro ( find_host_program )
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
@ -1044,7 +1041,11 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
set ( __toolchain_config "" )
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 __ndklibspath )
if ( DEFINED ${ __var } )
set ( __toolchain_config "${__toolchain_config}set( ${__var} \" ${ ${__var } }\ " )\n" )
if ( "${__var}" MATCHES " " )
set ( __toolchain_config "${__toolchain_config}set( ${__var} \" ${ ${__var } }\ " CACHE INTERNAL \" \" ) \ n " )
else ( )
set ( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \" \" ) \ n " )
endif ( )
endif ( )
endforeach ( )
file ( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" )