@ -64,6 +64,10 @@
# 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
# 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
# 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 .
#
@ -148,6 +152,9 @@
# [ ~ ] A N D R O I D _ A P I _ L E V E L i s r e n a m e d t o A N D R O I D _ N A T I V E _ A P I _ L E V E L
# - m o d i f i e d J a n u a r y 2 0 1 2 A n d r e y K a m a e v a n d r e y . k a m a e v @ i t s e e z . c o m
# [ + ] a d d e d s t l p o r t _ s t a t i c support ( experimental )
# [ + ] a d d e d s p e c i a l c h e c k f o r c y g w i n
# [ + ] f i l t e r e d o u t h i d d e n files ( starting with . ) w h i l e g l o b b i n g i n s i d e N D K
# [ + ] a u t o m a t i c a l l y a p p l i e d G L E S v 2 l i n k a g e f i x f o r N D K r e v i s i o n s 5 - 6
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# t h i s o n e i s i m p o r t a n t
@ -169,7 +176,16 @@ set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
set ( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
option ( ANDROID_USE_STLPORT "Experimental: use stlport_static instead of gnustl_static" FALSE )
macro ( __LIST_FILTER listvar regex )
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 )
@ -244,6 +260,7 @@ 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}." )
@ -265,6 +282,28 @@ macro( __COPY_IF_DIFFERENT _source _destination )
unset ( __fileCopyProcess )
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
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
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 )
if ( CYGWIN )
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." )
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
set ( __new_path "$ENV{PATH}" )
__LIST_FILTER ( __new_path "cygwin" )
set ( ENV{PATH} "${__new_path}" )
unset ( __new_path )
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
set ( TOOL_OS_SUFFIX "" )
if ( CMAKE_HOST_APPLE )
@ -376,6 +415,7 @@ 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}" )
file ( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
__LIST_FILTER ( __availableToolchains "^[.]" )
set ( __availableToolchainMachines "" )
set ( __availableToolchainArchs "" )
set ( __availableToolchainCompilerVersions "" )
@ -475,7 +515,7 @@ endif()
if ( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
__INIT_VARIABLE ( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM 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 )
mark_as_advanced ( ANDROID_FORCE_ARM_BUILD )
else ( )
unset ( ANDROID_FORCE_ARM_BUILD CACHE )
endif ( )
@ -710,7 +750,7 @@ if( ANDROID_USE_STLPORT )
if ( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
set ( LINKER_FLAGS "${LINKER_FLAGS} -Wl,--start-group -lstlport_static" )
endif ( )
else ( )
else ( ANDROID_USE_STLPORT )
if ( EXISTS "${__stlLibPath}/libgnustl_static.a" )
__COPY_IF_DIFFERENT ( "${__stlLibPath}/libgnustl_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
elseif ( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
@ -748,14 +788,25 @@ unset( __stlIncludePath )
unset ( __stlLibPath )
# o t h e r l i n k e r f l a g s
# if ( NOT ANDROID_USE_STLPORT )
__INIT_VARIABLE ( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
set ( ANDROID_NO_UNDEFINED ${ ANDROID_NO_UNDEFINED } CACHE BOOL "Don't all undefined symbols" FORCE )
MARK_AS_ADVANCED ( ANDROID_NO_UNDEFINED )
if ( ANDROID_NO_UNDEFINED )
set ( LINKER_FLAGS "-Wl,--no-undefined ${LINKER_FLAGS}" )
endif ( )
# endif ( )
__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 )
if ( ANDROID_NO_UNDEFINED )
set ( LINKER_FLAGS "-Wl,--no-undefined ${LINKER_FLAGS}" )
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 .
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES ON )
else ( )
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES OFF )
endif ( )
set ( ANDROID_SO_UNDEFINED ${ ANDROID_SO_UNDEFINED } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
mark_as_advanced ( ANDROID_SO_UNDEFINED )
if ( ANDROID_SO_UNDEFINED )
set ( LINKER_FLAGS "${LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
endif ( )
if ( ARMEABI_V7A )
# t h i s i s * r e q u i r e d * t o u s e t h e f o l l o w i n g l i n k e r f l a g s t h a t r o u t e s a r o u n d
# a C P U b u g i n s o m e C o r t e x - A 8 i m p l e m e n t a t i o n s :
@ -839,7 +890,7 @@ macro( find_host_program )
endmacro ( )
set ( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
MARK_AS_ADVANCED ( ANDROID_SET_OBSOLETE_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}" )
@ -851,9 +902,11 @@ endif()
# 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 _ N A T I V E _ A P I _ L E V E L : 3 , 4 , 5 , 8 , 9 , 14 ( depends on NDK version )
# A N D R O I D _ N O _ U N D E F I N E D : O N / O F F
# A N D R O I D _ S O _ U N D E F I N E D : O F F / ON ( default depends on NDK version )
# 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
# L I B R A R Y _ O U T P U T _ P A T H _ R O O T : < a n y p a t h >
# A N D R O I D _ U S E _ S T L P O R T : O N / OFF ( default ) - E X P E R I M E N T A L ! ! !
# A N D R O I D _ U S E _ S T L P O R T : O F F / O N - E X P E R I M E N T A L ! ! !
# A N D R O I D _ F O R B I D _ S Y G W I N : O N / O F F
# 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