@ -250,6 +250,9 @@ set( CMAKE_SYSTEM_NAME Linux )
# 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
set ( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
set ( ANDROID_SUPPORTED_NDK_VERSIONS ${ ANDROID_EXTRA_NDK_VERSIONS } -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
if ( NOT DEFINED ANDROID_NDK_SEARCH_PATHS )
if ( CMAKE_HOST_WIN32 )
@ -949,20 +952,6 @@ if( APPLE )
mark_as_advanced ( CMAKE_INSTALL_NAME_TOOL )
endif ( )
# f l a g s a n d d e f i n i t i o n s
remove_definitions ( -DANDROID )
add_definitions ( -DANDROID )
if ( ANDROID_SYSROOT MATCHES "[ ;\" ] " )
set ( ANDROID_CXX_FLAGS "--sysroot=\" ${ ANDROID_SYSROOT } \"" )
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 ( )
# F o r c e s e t c o m p i l e r s b e c a u s e s t a n d a r d i d e n t i f i c a t i o n w o r k s b a d l y f o r u s
include ( CMakeForceCompiler )
CMAKE_FORCE_C_COMPILER ( "${CMAKE_C_COMPILER}" GNU )
@ -983,60 +972,54 @@ set( CMAKE_ASM_COMPILER_FORCED TRUE )
set ( CMAKE_COMPILER_IS_GNUASM 1 )
set ( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
# N D K f l a g s
if ( ARMEABI OR ARMEABI_V7A )
# N D K a l s o d e f i n e s - f f u n c t i o n - s e c t i o n s - f u n w i n d - t a b l e s b u t t h e y r e s u l t i n w o r s e O p e n C V p e r f o r m a n c e
set ( _CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" )
set ( _CMAKE_C_FLAGS "-fPIC -Wno-psabi" )
remove_definitions ( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
add_definitions ( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
# e x t r a a r m - s p e c i f i c f l a g s
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
elseif ( X86 )
set ( _CMAKE_CXX_FLAGS "-funwind-tables" )
set ( _CMAKE_C_FLAGS "-funwind-tables" )
elseif ( MIPS )
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" )
set ( _CMAKE_C_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" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
# f l a g s a n d d e f i n i t i o n s
remove_definitions ( -DANDROID )
add_definitions ( -DANDROID )
if ( ANDROID_SYSROOT MATCHES "[ ;\" ] " )
set ( ANDROID_CXX_FLAGS "--sysroot=\" ${ ANDROID_SYSROOT } \"" )
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 ( _CMAKE_CXX_FLAGS "" )
set ( _CMAKE_C_FLAGS "" )
set ( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
endif ( )
# r e l e a s e a n d d e b u g f l a g s
# N D K f l a g s
if ( ARMEABI OR ARMEABI_V7A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" )
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 ) .
# 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" )
set ( _CMAKE_CXX_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
set ( _CMAKE_C_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
set ( ANDROID_CXX_FLAGS_RELEASE "-mthumb" )
set ( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=64" )
else ( )
# a l w a y s c o m p i l e A R M E A B I _ V 6 i n a r m m o d e ; o t h e r w i s e t h e r e i s n o d i f f e r e n c e f r o m A R M E A B I
# 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 "-marm -O3 -fstrict-aliasing" )
set ( _CMAKE_C_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
set ( _CMAKE_CXX_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
set ( _CMAKE_C_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
set ( ANDROID_CXX_FLAGS_RELEASE "-marm" )
set ( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=300" )
endif ( )
elseif ( X86 )
set ( _CMAKE_CXX_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
set ( _CMAKE_C_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
set ( _CMAKE_CXX_FLAGS_DEBUG "-O0 -finline-limit=300" )
set ( _CMAKE_C_FLAGS_DEBUG "-O0 -finline-limit=300" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
set ( ANDROID_CXX_FLAGS_RELEASE "" )
set ( ANDROID_CXX_FLAGS_DEBUG "-finline-limit=300" )
elseif ( MIPS )
set ( _CMAKE_CXX_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
set ( _CMAKE_C_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
set ( _CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
set ( _CMAKE_C_FLAGS_DEBUG "-O0 -g" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -frename-registers" )
set ( ANDROID_CXX_FLAGS_RELEASE "-finline-limit=300 -fno-strict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-finline-functions -fgcse-after-reload -frerun-cse-after-loop" )
elseif ( )
set ( ANDROID_CXX_FLAGS_RELEASE "" )
set ( ANDROID_CXX_FLAGS_DEBUG "" )
endif ( )
if ( NOT X86 )
set ( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" )
endif ( )
set ( _CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
set ( _CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
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" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # g o o d / n e c e s s a r y w h e n p o r t i n g d e s k t o p l i b r a r i e s
set ( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -fomit-frame-pointer " )
set ( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer " )
# A B I - s p e c i f i c f l a g s
if ( ARMEABI_V7A )
@ -1052,125 +1035,142 @@ elseif( ARMEABI_V6 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
elseif ( ARMEABI )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
elseif ( X86 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" ) # s s e ?
endif ( )
# S T L
if ( 0 AND EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
# u s e g c c a s a C + + l i n k e r t o a v o i d a u t o m a t i c p i c k i n g o f l i b s d t c + +
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
if ( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
if ( ANDROID_STL MATCHES "gnustl" )
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
else ( )
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> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
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> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
endif ( )
if ( EXISTS "${__libstl}" )
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \" ${ __libstl } \"")
set ( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \" ${ __libstl } \"")
set ( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \" ${ __libstl } \"")
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \" ${ __libstl } \"" )
set ( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \" ${ __libstl } \"" )
set ( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \" ${ __libstl } \"" )
endif ( )
if ( EXISTS "${__libsupcxx}" )
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \" ${ __libsupcxx } \"")
set ( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \" ${ __libsupcxx } \"")
set ( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \" ${ __libsupcxx } \"")
set ( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \" ${ __libsupcxx } \"" )
set ( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \" ${ __libsupcxx } \"" )
set ( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \" ${ __libsupcxx } \"" )
# C o b j e c t s :
set ( CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_C_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
set ( CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
set ( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \" ${ __libsupcxx } \"")
set ( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \" ${ __libsupcxx } \"")
set ( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \" ${ __libsupcxx } \"")
set ( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \" ${ __libsupcxx } \"" )
set ( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \" ${ __libsupcxx } \"" )
set ( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \" ${ __libsupcxx } \"" )
endif ( )
endif ( )
# v a r i a b l e s c o n t r o l l i n g o p t i o n a l b u i l d f l a g s
if ( ANDROID_NDK_RELEASE STRLESS "r7" )
# 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 m i s s i n g e x t e r 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 ( )
__INIT_VARIABLE ( ANDROID_NO_UNDEFINED OBSOLETE_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 )
__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_GOLD_LINKER ${ ANDROID_GOLD_LINKER } CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts)" )
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" )
mark_as_advanced ( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO )
# l i n k e r f l a g s
set ( ANDROID_LINKER_FLAGS "" )
__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 ( ANDROID_LINKER_FLAGS "-Wl,--no-undefined ${ANDROID_LINKER_FLAGS}" )
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 :
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" )
endif ( )
if ( ANDROID_NDK_RELEASE STRLESS "r7" )
# 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 m i s s i n g e x t e r 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 )
if ( ANDROID_NO_UNDEFINED )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
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 ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
endif ( )
__INIT_VARIABLE ( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
set ( ANDROID_FUNCTION_LEVEL_LINKING ${ ANDROID_FUNCTION_LEVEL_LINKING } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
mark_as_advanced ( ANDROID_FUNCTION_LEVEL_LINKING )
if ( ANDROID_FUNCTION_LEVEL_LINKING )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
set ( ANDROID_LINKER_FLAGS "-Wl,--gc-sections ${ANDROID_LINKER_FLAGS}" )
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 :
set ( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
endif ( )
if ( CMAKE_HOST_UNIX AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND ( ARMEABI_V7A OR X86 ) )
__INIT_VARIABLE ( ANDROID_USE_GOLD_LINKER VALUES ON )
set ( ANDROID_USE_GOLD_LINKER ${ ANDROID_USE_GOLD_LINKER } CACHE BOOL "Enables gold linker" FORCE )
mark_as_advanced ( ANDROID_USE_GOLD_LINKER )
if ( ANDROID_USE_GOLD_LINKER )
if ( CMAKE_HOST_UNIX AND ( ARMEABI_V7A OR X86 ) AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
if ( ANDROID_GOLD_LINKER )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
endif ( )
endif ( )
if ( ANDROID_NOEXECSTACK )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" )
endif ( )
if ( ANDROID_RELRO )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" )
endif ( )
# 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" )
set ( CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
set ( CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
set ( CMAKE_C_FLAGS_DEBUG "${_CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
set ( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
set ( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )
set ( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" )
set ( CMAKE_C_FLAGS "" CACHE STRING "c flags" )
set ( CMAKE_CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG" CACHE STRING "c++ Release flags" )
set ( CMAKE_C_FLAGS_RELEASE "-O3 -g -DNDEBUG" CACHE STRING "c Release flags" )
set ( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG " CACHE STRING "c++ Debug flags" )
set ( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG " CACHE STRING "c Debug flags" )
set ( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" )
set ( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" )
# 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}" )
set ( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}" )
set ( CMAKE_C_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}" )
set ( CMAKE_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}" )
set ( CMAKE_C_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}" )
set ( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
set ( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
if ( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
else ( )
set ( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
set ( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
endif ( )
# c o n f i g u r e r t t i
if ( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
if ( ANDROID_RTTI )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti " )
set ( CMAKE_CXX_FLAGS "-frtti ${CMAKE_CXX_FLAGS}" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti " )
set ( CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}" )
endif ( )
endif ( )
# c o n f i g u r e e x c e p t i o s
if ( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES )
if ( ANDROID_EXCEPTIONS )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions " )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions " )
set ( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_C_FLAGS "-fexceptions ${CMAKE_C_FLAGS}" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions " )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions " )
set ( CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}" )
endif ( )
endif ( )
@ -1239,11 +1239,13 @@ 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" )
set ( ${ VAR } "armeabi-v7a" )
elseif ( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
set ( ${ VAR } "x86" )
set ( ${ VAR } "x86" )
elseif ( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" )
set ( ${ VAR } "mips" )
else ( )
set ( ${ VAR } "unknown" )
set ( ${ VAR } "unknown" )
endif ( )
endmacro ( )
@ -1251,10 +1253,22 @@ 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" )
set ( __toolchain_config "" )
foreach ( __var NDK_CCACHE ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED
A N D R O I D _ S O _ U N D E F I N E D 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 L I B R A R Y _ O U T P U T _ P A T H _ R O O T A N D R O I D _ S T L
A N D R O I D _ S T L _ F O R C E _ F E A T U R E S A N D R O I D _ F O R B I D _ S Y G W I 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 _ F U N C T I O N _ L E V E L _ L I N K I N G A N D R O I D _ U S E _ G O L D _ L I N K E R )
foreach ( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES
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 _ T O O L C H A I N _ N A M E
A N D R O I D _ A B I
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 _ S T L
A N D R O I D _ S T L _ F O R C E _ F E A T U R E S
A N D R O I D _ F O R C E _ A R M _ B U I L D
A N D R O I D _ N O _ U N D E F I N E D
A N D R O I D _ S O _ U N D E F I N E D
A N D R O I D _ F U N C T I O N _ L E V E L _ L I N K I N G
A N D R O I D _ G O L D _ L I N K E R
A N D R O I D _ N O E X E C S T A C K
A N D R O I D _ R E L R O
)
if ( DEFINED ${ __var } )
if ( "${__var}" MATCHES " " )
set ( __toolchain_config "${__toolchain_config}set( ${__var} \" ${ ${__var } }\ " CACHE INTERNAL \" \" ) \ n " )
@ -1286,7 +1300,9 @@ endif()
# 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 _ F U N C T I O N _ L E V E L _ L I N K I N G : O N / O F F
# A N D R O I D _ U S E _ G O L D _ L I N K E R : O N / OFF ( default depends on NDK version and host & target platforms )
# A N D R O I D _ G O L D _ L I N K E R : O N / O F F
# A N D R O I D _ N O E X E C S T A C K : O N / O F F
# A N D R O I D _ R E L R O : O N / O F F
# V a r i a b l e s t h a t t a k e s e f f e c t o n l y a t f i r s t r u n :
# 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 : g n u s t l _ s t a t i c / g n u s t l _ s h a r e d / s t l p o r t _ s t a t i c / s t l p o r t _ s h a r e d / g a b i + + _ s t a t i c / g a b i + + _ s h a r e d / s y s t e m _ r e / s y s t e m / n o n e