@ -30,7 +30,7 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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 1 0 d
# 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 ) .
# R e q u i r e s c m a k e 2 . 6 . 3 o r newer ( 2.8.9 or newer is recommended ) .
# S e e h o m e p a g e : h t t p s : / / g i t h u b . c o m / t a k a - n o - m e / a n d r o i d - c m a k e
#
# U s a g e L i n u x :
@ -39,12 +39,6 @@
# $ c m a k e - 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 . .
# $ m a k e - j 8
#
# U s a g e Linux ( using standalone toolchain ) :
# $ e x p o r t 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 = / a b s o l u t e / p a t h / t o / a n d r o i d - t o o l c h a i n
# $ m k d i r b u i l d & & c d b u i l d
# $ c m a k e - 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 . .
# $ m a k e - j 8
#
# U s a g e W i n d o w s :
# Y o u n e e d n a t i v e p o r t o f m a k e t o b u i l d y o u r p r o j e c t .
# A n d r o i d N D K r7 ( and newer ) a l r e a d y h a s m a k e . e x e o n b o a r d .
@ -63,11 +57,6 @@
# A N D R O I D _ N D K = / o p t / a n d r o i d - n d k - p a t h t o t h e N D K r o o 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 _ S T A N D A L O N E _ T O O L C H A I N = / o p t / a n d r o i d - t o o l c h a i n - p a t h t o t h e
# s t a n d a l o n e t o o l c h a i n . T h i s o p t i o n i s n o t u s e d i f f u l l N D K i s f o u n d
# ( 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
# 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 .
@ -123,8 +112,8 @@
# * x 8 6 _ 6 4 - c l a n g 3 . 5
#
# 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 .
# 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 " 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 .
#
# 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 .
@ -133,13 +122,6 @@
# 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 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 .
#
# A N D R O I D _ S T L = g n u s t l _ s t a t i c - s p e c i f y t h e r u n t i m e t o u s e .
#
# P o s s i b l e v a l u e s a r e :
@ -200,12 +182,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 .
#
# 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 .
# D e f a u l t i s $ { C M A K E _ S O U R C E _ D I R } , a n d t h e a n d r o i d l i b s w i l l a l w a y s b e
# u n d e r t h e $ { L I B R A R Y _ O U T P U T _ P A T H _ R O O T } / l i b s / $ { A N D R O I D _ N D K _ A B I _ N A M E }
# ( d e p e n d i n g o n t h e t a r g e t A B I ) . T h i s i s c o n v e n i e n t f o r A n d r o i d p a c k a g i n g .
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmake_minimum_required ( VERSION 2.6.3 )
@ -235,22 +211,22 @@ endif()
# t h i s o n e n o t s o m u c h
set ( CMAKE_SYSTEM_VERSION 1 )
# r p a t h m a k e s l o w s e n c e f o r A n d r o i d
# r p a t h m a k e s l o w s e n s e f o r A n d r o i d
set ( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" )
set ( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
# N D K s e a r c h p a t h s
set ( ANDROID_SUPPORTED_NDK_VERSIONS ${ ANDROID_EXTRA_NDK_VERSIONS } -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
if ( NOT DEFINED ANDROID_NDK_SEARCH_PATHS )
if ( NOT DEFINED ANDROID_NDK_SEARCH_PATHS )
if ( CMAKE_HOST_WIN32 )
file ( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
set ( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk " "$ENV{SystemDrive}/NVPACK/android-ndk " )
set ( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}" "$ENV{SystemDrive}/NVPACK" )
else ( )
file ( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS )
set ( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk " )
set ( ANDROID_NDK_SEARCH_PATHS /opt "${ANDROID_NDK_SEARCH_PATHS}/NVPACK" )
endif ( )
endif ( )
if ( NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH )
if ( NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH )
set ( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
endif ( )
@ -272,106 +248,90 @@ set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 )
macro ( __LIST_FILTER listvar regex )
if ( ${ listvar } )
foreach ( __val ${ ${listvar } } )
if ( __val MATCHES "${regex}" )
list ( REMOVE_ITEM ${ listvar } "${__val}" )
endif ( )
endforeach ( )
endif ( )
if ( ${ listvar } )
foreach ( __val ${ ${listvar } } )
if ( __val MATCHES "${regex}" )
list ( REMOVE_ITEM ${ listvar } "${__val}" )
endif ( )
endforeach ( )
endif ( )
endmacro ( )
macro ( __INIT_VARIABLE var_name )
set ( __test_path 0 )
foreach ( __var ${ ARGN } )
if ( __var STREQUAL "PATH" )
set ( __test_path 1 )
break ( )
endif ( )
endforeach ( )
if ( __test_path AND NOT EXISTS "${${var_name}}" )
unset ( ${ var_name } CACHE )
endif ( )
if ( "${${var_name}}" STREQUAL "" )
set ( __values 0 )
set ( __test_path 0 )
foreach ( __var ${ ARGN } )
if ( __var STREQUAL "VALUES" )
set ( __values 1 )
elseif ( NOT __var STREQUAL "PATH" )
set ( __obsolete 0 )
if ( __var MATCHES "^OBSOLETE_.*$" )
string ( REPLACE "OBSOLETE_" "" __var "${__var}" )
set ( __obsolete 1 )
endif ( )
if ( __var MATCHES "^ENV_.*$" )
string ( REPLACE "ENV_" "" __var "${__var}" )
set ( __value "$ENV{${__var}}" )
elseif ( DEFINED ${ __var } )
set ( __value "${${__var}}" )
else ( )
if ( __values )
set ( __value "${__var}" )
else ( )
set ( __value "" )
endif ( )
endif ( )
if ( NOT "${__value}" STREQUAL "" )
if ( __test_path )
if ( EXISTS "${__value}" )
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 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 ( )
if ( __var STREQUAL "PATH" )
set ( __test_path 1 )
break ( )
endif ( )
endif ( )
endif ( )
endforeach ( )
unset ( __value )
unset ( __values )
unset ( __obsolete )
elseif ( __test_path )
file ( TO_CMAKE_PATH "${${var_name}}" ${ var_name } )
endif ( )
unset ( __test_path )
if ( __test_path AND NOT EXISTS "${${var_name}}" )
unset ( ${ var_name } CACHE )
endif ( )
if ( " ${${var_name}}" STREQUAL " " )
set ( __values 0 )
foreach ( __var ${ ARGN } )
if ( __var STREQUAL "VALUES" )
set ( __values 1 )
elseif ( NOT __var STREQUAL "PATH" )
if ( __var MATCHES "^ENV_.*$" )
string ( REPLACE "ENV_" "" __var "${__var}" )
set ( __value "$ENV{${__var}}" )
elseif ( DEFINED ${ __var } )
set ( __value "${${__var}}" )
elseif ( __values )
set ( __value "${__var}" )
else ( )
set ( __value "" )
endif ( )
if ( NOT " ${__value}" STREQUAL " " AND ( NOT __test_path OR EXISTS "${__value}" ) )
set ( ${ var_name } "${__value}" )
break ( )
endif ( )
endif ( )
endforeach ( )
unset ( __value )
unset ( __values )
endif ( )
if ( __test_path )
file ( TO_CMAKE_PATH "${${var_name}}" ${ var_name } )
endif ( )
unset ( __test_path )
endmacro ( )
macro ( __DETECT_NATIVE_API_LEVEL _var _path )
SET ( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" )
FILE ( STRINGS ${ _path } __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if ( NOT __apiFileContent )
message ( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
endif ( )
string ( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${ _var } "${__apiFileContent}" )
unset ( __apiFileContent )
unset ( __ndkApiLevelRegex )
set ( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" )
file ( STRINGS ${ _path } __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if ( NOT __apiFileContent )
message ( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
endif ( )
string ( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${ _var } "${__apiFileContent}" )
unset ( __apiFileContent )
unset ( __ndkApiLevelRegex )
endmacro ( )
macro ( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
if ( EXISTS "${_root}" )
file ( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER ( __gccExePath "^[.].*" )
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 } "" )
file ( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER ( __gccExePath "^[.].*" )
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 )
else ( )
set ( ${ _var } "" )
endif ( )
endmacro ( )
@ -419,17 +379,19 @@ if( NOT ANDROID_NDK_HOST_X64 )
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
__INIT_VARIABLE ( ANDROID_NDK PATH ENV_ANDROID_NDK )
if ( NOT ANDROID_NDK AND NOT ANDROID_STANDALONE_TOOLCHAIN )
__INIT_VARIABLE ( ANDROID_NDK PATH ENV_ANDROID_NDK )
endif ( )
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
__INIT_VARIABLE ( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT )
__INIT_VARIABLE ( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN )
if ( NOT ANDROID_STANDALONE_TOOLCHAIN )
# t r y t o f i n d A n d r o i d N D K i n o n e o f t h e t h e d e f a u l t l o c a t i o n s
set ( __ndkSearchPaths )
foreach ( __ndkSearchPath ${ ANDROID_NDK_SEARCH_PATHS } )
foreach ( suffix ${ ANDROID_SUPPORTED_NDK_VERSIONS } )
list ( APPEND __ndkSearchPaths "${__ndkSearchPath}${suffix}" )
list ( APPEND __ndkSearchPaths "${__ndkSearchPath}/android-ndk ${suffix}" )
endforeach ( )
endforeach ( )
__INIT_VARIABLE ( ANDROID_NDK PATH VALUES ${ __ndkSearchPaths } )
@ -487,7 +449,7 @@ else()
o r
e x p o r t 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 = ~ / m y - a n d r o i d - t o o l c h a i n
o r p u t t h e t o o l c h a i n o r N D K i n t h e d e f a u l t p a t h :
s u d o l n - s ~ / m y - a n d r o i d - n d k $ { A N D R O I D _ N D K _ S E A R C H _ P A T H }
s u d o l n - s ~ / m y - a n d r o i d - n d k $ { A N D R O I D _ N D K _ S E A R C H _ P A T H } / a n d r o i d - n d k
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 ( )
@ -636,7 +598,7 @@ if( BUILD_WITH_ANDROID_NDK )
endif ( )
if ( NOT __availableToolchains )
file ( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" )
if ( __availableToolchains )
if ( __availableToolchainsLst )
list ( SORT __availableToolchainsLst ) # w e n e e d c l a n g t o g o a f t e r g c c
endif ( )
__LIST_FILTER ( __availableToolchainsLst "^[.]" )
@ -669,7 +631,7 @@ if( NOT ANDROID_SUPPORTED_ABIS )
endif ( )
# 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 } )
__INIT_VARIABLE ( ANDROID_ABI 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
list ( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx )
if ( __androidAbiIdx EQUAL -1 )
@ -760,7 +722,7 @@ if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMa
endif ( )
if ( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
__INIT_VARIABLE ( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF )
__INIT_VARIABLE ( ANDROID_FORCE_ARM_BUILD VALUES OFF )
set ( ANDROID_FORCE_ARM_BUILD ${ ANDROID_FORCE_ARM_BUILD } CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE )
mark_as_advanced ( ANDROID_FORCE_ARM_BUILD )
else ( )
@ -845,6 +807,7 @@ else()
unset ( __realApiLevel )
endif ( )
set ( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
set ( CMAKE_ANDROID_API ${ ANDROID_NATIVE_API_LEVEL } )
if ( CMAKE_VERSION VERSION_GREATER "2.8" )
list ( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
set_property ( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ ANDROID_SUPPORTED_NATIVE_API_LEVELS } )
@ -863,16 +826,7 @@ endif()
# r u n t i m e choice ( STL, rtti, exceptions )
if ( NOT ANDROID_STL )
# h o n o r l e g a c y A N D R O I D _ U S E _ S T L P O R T
if ( DEFINED ANDROID_USE_STLPORT )
if ( ANDROID_USE_STLPORT )
set ( ANDROID_STL stlport_static )
endif ( )
message ( WARNING "You are using an obsolete variable ANDROID_USE_STLPORT to select the STL variant. Use -DANDROID_STL=stlport_static instead." )
endif ( )
if ( NOT ANDROID_STL )
set ( ANDROID_STL gnustl_static )
endif ( )
endif ( )
set ( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" )
set ( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" )
@ -1033,7 +987,7 @@ if( BUILD_WITH_ANDROID_NDK )
set ( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
elseif ( ANDROID_STL MATCHES "gabi" )
if ( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # b e f o r e r 7
message ( FATAL_ERROR "gabi++ is not aw ailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++." )
message ( FATAL_ERROR "gabi++ is not av ailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++." )
endif ( )
set ( ANDROID_RTTI ON )
set ( ANDROID_EXCEPTIONS OFF )
@ -1144,7 +1098,12 @@ if( NOT CMAKE_C_COMPILER )
endif ( )
set ( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" )
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" )
if ( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" )
# U s e g c c - a r i f w e h a v e i t f o r b e t t e r L T O s u p p o r t .
set ( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
else ( )
set ( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
endif ( )
set ( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
set ( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" )
set ( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
@ -1233,7 +1192,7 @@ endif()
# N D K f l a g s
if ( ARM64_V8A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -ffunction-sections -f unwind-tables" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
if ( NOT ANDROID_COMPILER_IS_CLANG )
@ -1263,7 +1222,7 @@ elseif( X86 OR X86_64 )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
elseif ( MIPS OR MIPS64 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -ffunction-sections -f unwind-tables -fmessage-length=0" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -funwind-tables -fmessage-length=0" )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" )
if ( NOT ANDROID_COMPILER_IS_CLANG )
@ -1348,7 +1307,7 @@ if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
else ( )
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES OFF )
endif ( )
__INIT_VARIABLE ( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
__INIT_VARIABLE ( ANDROID_NO_UNDEFINED VALUES ON )
__INIT_VARIABLE ( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
__INIT_VARIABLE ( ANDROID_GOLD_LINKER VALUES ON )
__INIT_VARIABLE ( ANDROID_NOEXECSTACK VALUES ON )
@ -1356,7 +1315,7 @@ __INIT_VARIABLE( ANDROID_RELRO VALUES ON )
set ( ANDROID_NO_UNDEFINED ${ ANDROID_NO_UNDEFINED } CACHE BOOL "Show all undefined symbols as linker errors" )
set ( ANDROID_SO_UNDEFINED ${ ANDROID_SO_UNDEFINED } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
set ( ANDROID_FUNCTION_LEVEL_LINKING ${ ANDROID_FUNCTION_LEVEL_LINKING } CACHE BOOL "Allows or disallows undefined symbols in shared libraries " )
set ( ANDROID_FUNCTION_LEVEL_LINKING ${ ANDROID_FUNCTION_LEVEL_LINKING } CACHE BOOL "Put each function in separate section and enable garbage collection of unused input sections at link time " )
set ( ANDROID_GOLD_LINKER ${ ANDROID_GOLD_LINKER } CACHE BOOL "Enables gold linker" )
set ( ANDROID_NOEXECSTACK ${ ANDROID_NOEXECSTACK } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
set ( ANDROID_RELRO ${ ANDROID_RELRO } CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" )
@ -1531,27 +1490,31 @@ if( ANDROID_EXPLICIT_CRT_LINK )
endif ( )
# 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" )
if ( NOT _CMAKE_IN_TRY_COMPILE )
if ( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
set ( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
else ( )
set ( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
endif ( )
set ( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
if ( DEFINED LIBRARY_OUTPUT_PATH_ROOT
O R E X I S T S " $ { C M A K E _ S O U R C E _ D I R } / A n d r o i d M a n i f e s t . x m l "
OR ( EXISTS "${CMAKE_SOURCE_DIR}/../AndroidManifest.xml" AND EXISTS "${CMAKE_SOURCE_DIR}/../jni/" ) )
set ( LIBRARY_OUTPUT_PATH_ROOT ${ CMAKE_SOURCE_DIR } CACHE PATH "Root for binaries output, set this to change where Android libs are installed to" )
if ( NOT _CMAKE_IN_TRY_COMPILE )
if ( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
set ( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
else ( )
set ( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
endif ( )
set ( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for Android libs" )
endif ( )
endif ( )
# c o p y s h a e d s t l l i b r a r y t o b u i l d d i r e c t o r y
if ( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" )
get_filename_component ( __libstlname "${__libstl}" NAME )
execute_process ( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
if ( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
message ( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
endif ( )
unset ( __fileCopyProcess )
unset ( __libstlname )
if ( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" AND DEFINED LIBRARY_OUTPUT_PATH )
get_filename_component ( __libstlname "${__libstl}" NAME )
execute_process ( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
if ( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
message ( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
endif ( )
unset ( __fileCopyProcess )
unset ( __libstlname )
endif ( )
@ -1612,25 +1575,10 @@ macro( find_host_program )
endmacro ( )
macro ( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
if ( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" )
set ( ${ VAR } "armeabi" )
elseif ( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
set ( ${ VAR } "armeabi-v7a" )
elseif ( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
set ( ${ VAR } "x86" )
elseif ( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" )
set ( ${ VAR } "mips" )
else ( )
set ( ${ VAR } "unknown" )
endif ( )
endmacro ( )
# e x p o r t t o o l c h a i n s e t t i n g s f o r t h e try_compile ( ) c o m m a n d
if ( NOT PROJECT _NAME STREQUAL " CMAKE_TRY_COMPILE" )
if ( NOT _CMAKE_IN_TRY_COMPILE )
set ( __toolchain_config "" )
foreach ( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES
foreach ( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN
A N D R O I D _ N D K _ H O S T _ X 6 4
A N D R O I D _ N D K
A N D R O I D _ N D K _ L A Y O U T
@ -1652,7 +1600,7 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
A N D R O I D _ A P P _ P I E
)
if ( DEFINED ${ __var } )
if ( "${__var}" MATCHES " " )
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 " )
@ -1677,16 +1625,6 @@ if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
endif ( )
# s e t s o m e o b s o l e t e v a r i a b l e s f o r b a c k w a r d c o m p a t i b i l i t y
set ( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
mark_as_advanced ( ANDROID_SET_OBSOLETE_VARIABLES )
if ( ANDROID_SET_OBSOLETE_VARIABLES )
set ( ANDROID_API_LEVEL ${ ANDROID_NATIVE_API_LEVEL } )
set ( ARM_TARGET "${ANDROID_ABI}" )
set ( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" )
endif ( )
# V a r i a b l e s c o n t r o l l i n g b e h a v i o r o r s e t b y c m a k e t o o l c h a i n :
# A N D R O I D _ A B I : " a r m e a b i - v 7 a " ( d e f a u l t ) , " a r m e a b i " , " a r m e a b i - v 7 a w i t h N E O N " , " a r m e a b i - v 7 a w i t h V F P V 3 " , " a r m e a b i - v 6 w i t h V F P " , " x 8 6 " , " m i p s " , " a r m 6 4 - v 8 a " , " x 8 6 _ 6 4 " , " m i p s 6 4 "
# A N D R O I D _ N A T I V E _ A P I _ L E V E L : 3 , 4 , 5 , 8 , 9 , 1 4 , 1 5 , 1 6 , 1 7 , 1 8 , 1 9 , 21 ( depends on NDK version )
@ -1700,22 +1638,15 @@ endif()
# A N D R O I D _ R E L R O : O N / O F F
# A N D R O I D _ F O R C E _ A R M _ B U I L D : O N / O F F
# A N D R O I D _ S T L _ F O R C E _ F E A T U R E S : O N / O F F
# 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 / O F F
# A N D R O I D _ L I B M _ P A T H : p a t h t o l i b m . so ( set to something like $ ( TOP ) /out/target/product/<product_name>/obj/lib/libm.so ) t o w o r k a r o u n d u n r e s o l v e d ` s i n c o s `
# C a n b e s e t o n l y a t t h e f i r s t r u n :
# A N D R O I D _ N D K
# 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
# A N D R O I D _ N D K : p a t h t o y o u r N D K i n s t a l l
# N D K _ C C A C H E : p a t h t o y o u r c c a c h e e x e c u t a b l e
# A N D R O I D _ T O O L C H A I N _ N A M E : t h e N D K n a m e o f c o m p i l e r t o o l c h a i n
# A N D R O I D _ N D K _ H O S T _ X 6 4 : t r y t o u s e x 8 6 _ 6 4 toolchain ( default for x64 host systems )
# A N D R O I D _ N D K _ L A Y O U T : t h e i n n e r N D K structure ( RELEASE, LINARO, ANDROID )
# L I B R A R Y _ O U T P U T _ P A T H _ R O O T : < a n y v a l i d p a t h >
# N D K _ C C A C H E : < p a t h t o y o u r c c a c h e e x e c u t a b l e >
# O b s o l e t e :
# A N D R O I D _ A P I _ L E V E L : s u p e r s e d e d b y A N D R O I D _ N A T I V E _ A P I _ L E V E L
# A R M _ T A R G E T : s u p e r s e d e d b y A N D R O I D _ A B I
# A R M _ T A R G E T S : s u p e r s e d e d b y ANDROID_ABI ( can be set only )
# A N D R O I D _ N D K _ T O O L C H A I N _ R O O T : s u p e r s e d e d b y ANDROID_STANDALONE_TOOLCHAIN ( can be set only )
# A N D R O I D _ U S E _ S T L P O R T : s u p e r s e d e d b y A N D R O I D _ S T L = s t l p o r t _ s t a t i c
# A N D R O I D _ L E V E L : s u p e r s e d e d b y ANDROID_NATIVE_API_LEVEL ( completely removed )
# 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
#
# P r i m a r y r e a d - o n l y v a r i a b l e s :
# A N D R O I D : a l w a y s T R U E
@ -1729,7 +1660,6 @@ endif()
# X 8 6 _ 6 4 : T R U E i f c o n f i g u r e d f o r x 8 6 _ 6 4
# 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
# M I P S 6 4 : T R U E i f c o n f i g u r e d f o r m i p s 6 4
# 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
@ -1740,8 +1670,6 @@ endif()
# 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
# 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 _ C O M P I L E R _ I S _ C L A N G : T R U E i f c l a n g c o m p i l e r i s u s e d
# 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
#
# Secondary ( less stable ) r e a d - o n l y v a r i a b l e s :
# A N D R O I D _ C O M P I L E R _ V E R S I O N : G C C v e r s i o n used ( not Clang version )
@ -1756,12 +1684,10 @@ endif()
# A N D R O I D _ R T T I : i f r t t i i s e n a b l e d b y t h e r u n t i m e
# A N D R O I D _ E X C E P T I O N S : i f e x c e p t i o n s a r e e n a b l e d b y t h e r u n t i m e
# A N D R O I D _ G C C _ T O O L C H A I N _ N A M E : r e a d - o n l y , d i f f e r s f r o m A N D R O I D _ T O O L C H A I N _ N A M E o n l y i f c l a n g i s u s e d
# A N D R O I D _ L I B M _ P A T H : p a t h t o l i b m . so ( set to something like $ ( TOP ) /out/target/product/<product_name>/obj/lib/libm.so ) t o w o r k a r o u n d u n r e s o l v e d ` s i n c o s `
#
# D e f a u l t s :
# A N D R O I D _ D E F A U L T _ N D K _ A P I _ L E V E L
# A N D R O I D _ D E F A U L T _ N D K _ A P I _ L E V E L _ $ { A R C H }
# A N D R O I D _ N D K _ S E A R C H _ P A T H S
# 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
# A N D R O I D _ S U P P O R T E D _ A B I S _ $ { A R C H }
# A N D R O I D _ S U P P O R T E D _ N D K _ V E R S I O N S