@ -3,7 +3,7 @@
# 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
# 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 . T h e l a t e s t v e r s i o n c a n b e g e t a t
# h t t p : / / c o d e . o p e n c v . o r g / p r o j e c t s / o p e n c v / r e p o s i t o r y / r e v i s i o n s / m a s t e r / c h a n g e s / a n d r o i d / a n d r o i d . t o o l c h a i n . c m a k e
#
# U s a g e L i n u x :
@ -29,7 +29,7 @@
# $ c m a k e . e x e - G " M i n G W M a k e f i l e s "
# - D C M A K E _ T O O L C H A I N _ F I L E = p a t h \ t o \ t h e \ a n d r o i d . t o o l c h a i n . c m a k e
# - D C M A K E _ M A K E _ P R O G R A M = " % A N D R O I D _ N D K % \ p r e b u i l t \ w i n d o w s \ b i n \ m a k e . e x e " . .
# $ " % A N D R O I D _ N D K % \ p r e b u i l t \ w i n d o w s \ b i n \ m a k e . e x e "
# $ c m a k e . e x e - - b u i l d .
#
#
# Options ( can be set as cmake parameters: -D<option_name>=<value> ) :
@ -41,7 +41,7 @@
# ( i g n o r e d i f A N D R O I D _ N D K i s s e t ) .
# C a n b e s e t a s e n v i r o n m e n t v a r i a b l e . C a n b e s e t o n l y a t f i r s t c m a k e r u n .
#
# 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
# 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 .
#
@ -58,27 +58,28 @@
# " 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 .
# " 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 )
# ( I t i s n o t t e s t e d o n r e a l d e v i c e s b y t h e a u t h o s o f t h i s t o o l c h a i 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 .
#
# 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 .
# 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 i s u s e d .
#
# A N D R O I D _ F O R C E _ A R M _ B U I L D = O F F - s e t t r u e t o g e n e r a t e 3 2 - b i t A R M i n s t r u c t i o n s
# i n s t e a d o f T h u m b - 1 . I s n o t a v a i l a b l e f o r " x 8 6 " ( i n a p p l i c a b l e ) a n d
# " a r m e a b i - v 6 w i t h V F P " ( f o r c e d ) A B I s .
# A N D R O I D _ F O R C E _ A R M _ B U I L D = O F F - s e t O N t o g e n e r a t e 3 2 - b i t A R M i n s t r u c t i o n s
# i n s t e a d o f T h u m b . I s n o t a v a i l a b l e f o r " x 8 6 " ( i n a p p l i c a b l e ) a n d
# " a r m e a b i - v 6 w i t h V F P " ( i s f o r c e d t o b e O N ) A B I s .
#
# A N D R O I D _ N O _ U N D E F I N E D = O N - s e t t r u e t o s h o w a l l u n d e f i n e d s y m b o l s a s l i n k e r
# A N D R O I D _ N O _ U N D E F I N E D = O N - s e t O N t o s h o w a l l u n d e f i n e d s y m b o l s a s l i n k e r
# e r r o r s e v e n i f t h e y a r e n o t u s e d .
#
# A N D R O I D _ S O _ U N D E F I N E D = O F F - s e t t r u e t o a l l o w u n d e f i n e d s y m b o l s i n s h a r e d
# l i b r a r i e s . A u t o m a t i c a l l y t u r n e d o n f o r N D K r 5 x a n d r 6 x d u e t o G L E S v 2
# A N D R O I D _ S O _ U N D E F I N E D = O F F - s e t O N t o a l l o w u n d e f i n e d s y m b o l s i n s h a r e d
# l i b r a r i e s . A u t o m a t i c a l l y t u r n e d f o r N D K r 5 x a n d r 6 x d u e t o G L E S v 2
# p r o b l e m s .
#
# L I B R A R Y _ O U T P U T _ P A T H _ R O O T = $ { C M A K E _ S O U R C E _ D I R } - w h e r e t o o u t p u t b i n a r y
# f i l e s . S e e a d d i t i o n a l d e t a i l s b e l o w .
#
# A N D R O I D _ S E T _ O B S O L E T E _ V A R I A B L E S = O N - i t s e t , t h e n t o o l c h a i n d e f i n e s s o m e
# o b s o l e t e v a r i a b l e s w h i c h w e r e s e t b y p r e v i o u s v e r s i o n s o f t h i s f i l e f o r
# A N D R O I D _ S E T _ O B S O L E T E _ V A R I A B L E S = O N - i f s e t , t h e n t o o l c h a i n d e f i n e s s o m e
# o b s o l e t e v a r i a b l e s w h i c h w e r e u s e d b y p r e v i o u s v e r s i o n s o f t h i s f i l e f o r
# b a c k w a r d c o m p a t i b i l i t y .
#
#
@ -94,15 +95,15 @@
# M a k e s u r e t o d o t h e f o l l o w i n g i n y o u r s c r i p t s :
# SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" )
# SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" )
# T h e f l a g s w i l l b e p r e p o p u l a t e d w i t h c r i t i c a l f l a g s , s o d o n ' t l o o s e t h e m .
# A l s o b e a w a r e t h a t t o o l c h a i n a l s o s e t s c o n f i g u r a t i o n - s p e c i f i c c o m p i l e r
# f l a g s a n d l i n k e r f l a g s .
# T h e f l a g s w i l l b e p r e p o p u l a t e d w i t h c r i t i c a l f l a g s , s o d o n ' t l o o s e t h e m .
# A l s o b e a w a r e t h a t t o o l c h a i n a l s o s e t s c o n f i g u r a t i o n - s p e c i f i c c o m p i l e r
# f l a g s a n d l i n k e r f l a g s .
#
# A N D R O I D a n d B U I L D _ A N D R O I D w i l l b e s e t t o t r u e , y o u m a y t e s t a n y o f t h e s e
# v a r i a b l e s t o m a k e n e c e s s a r y A n d r o i d - s p e c i f i c c o n f i g u r a t i o n c h a n g e s .
#
# A l s o A R M E A B I o r A R M E A B I _ V 7 A o r X 8 6 w i l l b e s e t t r u e , m u t u a l l y e x c l u s i v e .
# N E O N o p t i o n w i l l b e s e t t r u e i f V F P i s s e t t o N E O N .
# A l s o A R M E A B I o r A R M E A B I _ V 7 A o r X 8 6 o r M I P S w i l l b e s e t t r u e , m u t u a l l y
# e x c l u s i v e . N E O N o p t i o n w i l l b e s e t t r u e i f V F P i s s e t t o N E O N .
#
# L I B R A R Y _ O U T P U T _ P A T H _ R O O T s h o u l d b e s e t i n c a c h e t o d e t e r m i n e w h e r e A n d r o i d
# l i b r a r i e s w i l l b e i n s t a l l e d .
@ -185,7 +186,7 @@
# [ + ] a d d e d m i p s a r c h i t e c t u r e s u p p o r t
# - 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
# [ ~ ] 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 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
# [ + ] a d d e d C C a c h e support ( via NDK_CCACHE environment or cmake variable )
# [ + ] a d d e d g o l d l i n k e r s u p p o r t f o r N D K r 8 b
@ -199,7 +200,7 @@ if( DEFINED CMAKE_CROSSCOMPILING )
return ( )
endif ( )
get_property ( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
get_property ( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if ( _CMAKE_IN_TRY_COMPILE )
include ( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL )
endif ( )
@ -279,15 +280,15 @@ macro( __INIT_VARIABLE var_name )
if ( NOT "${__value}" STREQUAL "" )
if ( __test_path )
if ( EXISTS "${__value}" )
set ( ${ var_name } "${__value}" )
if ( __obsolete )
file ( TO_CMAKE_PATH "${__value}" ${ var_name } )
if ( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE )
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." )
endif ( )
break ( )
endif ( )
else ( )
set ( ${ var_name } "${__value}" )
if ( __obsolete )
if ( __obsolete AND NOT _CMAKE_IN_TRY_COMPILE )
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." )
endif ( )
break ( )
@ -298,6 +299,8 @@ macro( __INIT_VARIABLE var_name )
unset ( __value )
unset ( __values )
unset ( __obsolete )
elseif ( __test_path )
file ( TO_CMAKE_PATH "${${var_name}}" ${ var_name } )
endif ( )
unset ( __test_path )
endmacro ( )
@ -314,19 +317,23 @@ macro( __DETECT_NATIVE_API_LEVEL _var _path )
endmacro ( )
macro ( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
file ( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER ( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
list ( LENGTH __gccExePath __gccExePathsCount )
if ( NOT __gccExePathsCount EQUAL 1 )
message ( WARNING "Could not uniquely determine machine name for compiler from ${_root}." )
set ( ${ _var } "" )
if ( EXISTS "${_root}" )
file ( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER ( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
list ( LENGTH __gccExePath __gccExePathsCount )
if ( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE )
message ( WARNING "Could not determine machine name for compiler from ${_root}" )
set ( ${ _var } "" )
else ( )
get_filename_component ( __gccExeName "${__gccExePath}" NAME_WE )
string ( REPLACE "-gcc" "" ${ _var } "${__gccExeName}" )
endif ( )
unset ( __gccExePath )
unset ( __gccExePathsCount )
unset ( __gccExeName )
else ( )
get_filename_component ( __gccExeName "${__gccExePath}" NAME_WE )
string ( REPLACE "-gcc" "" ${ _var } "${__gccExeName}" )
set ( ${ _var } "" )
endif ( )
unset ( __gccExePath )
unset ( __gccExePathsCount )
unset ( __gccExeName )
endmacro ( )
macro ( __COPY_IF_DIFFERENT _source _destination )
@ -403,7 +410,6 @@ if( NOT ANDROID_NDK )
endif ( 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
if ( ANDROID_NDK )
get_filename_component ( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
@ -412,12 +418,13 @@ if( ANDROID_NDK )
string ( LENGTH "${ANDROID_NDK}" __length )
string ( SUBSTRING "${CMAKE_AR}" 0 ${ __length } __androidNdkPreviousPath )
if ( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK )
message ( FATAL_ERROR "It is not possible to change path to the NDK on subsequent run." )
message ( FATAL_ERROR " It is not possible to change the path to the NDK on subsequent CMake run. You must remove all files from your build folder first.
" )
endif ( )
unset ( __androidNdkPreviousPath )
unset ( __length )
endif ( )
set ( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" )
set ( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE )
set ( BUILD_WITH_ANDROID_NDK True )
elseif ( ANDROID_STANDALONE_TOOLCHAIN )
get_filename_component ( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
@ -431,7 +438,7 @@ elseif( ANDROID_STANDALONE_TOOLCHAIN )
unset ( __androidStandaloneToolchainPreviousPath )
unset ( __length )
endif ( )
set ( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" )
set ( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" FORCE )
set ( BUILD_WITH_STANDALONE_TOOLCHAIN True )
else ( )
list ( GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH )
@ -585,7 +592,7 @@ if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMa
file ( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \" ${ CMAKE_SYSTEM_PROCESSOR } \")\n" )
endif ( )
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." )
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." FORCE )
if ( CMAKE_VERSION VERSION_GREATER "2.8" )
list ( SORT ANDROID_SUPPORTED_ABIS_ ${ ANDROID_ARCH_FULLNAME } )
set_property ( CACHE ANDROID_ABI PROPERTY STRINGS ${ ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME } } )
@ -636,8 +643,8 @@ endif()
list ( GET __availableToolchains ${ __toolchainIdx } ANDROID_TOOLCHAIN_NAME )
list ( GET __availableToolchainMachines ${ __toolchainIdx } ANDROID_TOOLCHAIN_MACHINE_NAME )
list ( GET __availableToolchainCompilerVersions ${ __toolchainIdx } ANDROID_COMPILER_VERSION )
set ( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" )
set ( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" )
set ( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" FORCE )
set ( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" FORCE )
unset ( __toolchainIdx )
unset ( __availableToolchains )
unset ( __availableToolchainMachines )
@ -769,8 +776,10 @@ endif()
# 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
message ( WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build." )
if ( NOT _CMAKE_IN_TRY_COMPILE )
# 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
message ( WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build." )
endif ( )
else ( )
set ( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
endif ( )
@ -981,8 +990,8 @@ include_directories( SYSTEM ${ANDROID_SYSTEM_INCLUDE_DIRS} )
link_directories ( ${ ANDROID_SYSTEM_LIB_DIRS } )
# 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 ( 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}" )
set ( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
if ( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK MATCHES "-r8$" )
@ -1129,16 +1138,17 @@ endif()
# N E O N : T R U E i f N E O N u n i t i s e n a b l e d
# V F P V 3 : T R U E i f V F P v e r s i o n 3 i s e n a b l e d
# X 8 6 : T R U E i f c o n f i g u r e d f o r x 8 6
# M I P S : T R U E i f c o n f i g u r e d f o r m i p s
# B U I L D _ A N D R O I D : a l w a y s T R U E
# B U I L D _ W I T H _ A N D R O I D _ N D K : T R U E i f N D K i s u s e d
# B U I L D _ W I T H _ S T A N D A L O N E _ T O O L C H A I N : T R U E i f s t a n d a l o n e t o o l c h a i n i s u s e d
# A N D R O I D _ N D K _ H O S T _ S Y S T E M _ N A M E : " w i n d o w s " , " l i n u x - x 8 6 " o r " d a r w i n - x 8 6 " d e p e n d i n g o n h o s t p l a t f o r m
# A N D R O I D _ N D K _ A B I _ N A M E : " a r m e a b i " , " a r m e a b i - v 7 a " o r " x 8 6 " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ N D K _ A B I _ N A M E : " a r m e a b i " , " a r m e a b i - v 7 a " , " x 8 6 " o r " m i p s " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ A R C H _ N A M E : " a r m " o r " x 8 6 " o r " m i p s " d e p e n d i n g o n A N D R O I D _ A B I
# T O O L _ O S _ S U F F I X : " " o r " . e x e " d e p e n d i n g o n h o s t p l a t f o r m
# A N D R O I D _ S Y S R O O T : p a t h t o t h e c o m p i l e r s y s r o o t
# A N D R O I D _ S Y S T E M _ I N C L U D E _ D I R S
# A N D R O I D _ S Y S T E M _ L I B _ D I R S
# T O O L _ O S _ S U F F I X : " " o r " . e x e " d e p e n d i n g o n h o s t p l a t f o r m
# O b s o l e t e :
# A R M E A B I _ N D K _ N A M E : s u p e r s e d e d b y A N D R O I D _ N D K _ A B I _ N A M E
#