@ -203,7 +203,7 @@ 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 ( FATAL _ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
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 )
@ -214,7 +214,7 @@ macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
file ( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
list ( LENGTH __gccExePath __gccExePathsCount )
if ( NOT __gccExePathsCount EQUAL 1 )
message ( SEND_ERROR "Could not uniquely determine machine name for compiler from ${_root}." )
message ( WARNING "Could not uniquely determine machine name for compiler from ${_root}." )
set ( ${ _var } "" )
else ( )
get_filename_component ( __gccExeName "${__gccExePath}" NAME_WE )
@ -448,7 +448,7 @@ if( ANDROID_TOOLCHAIN_NAME )
endif ( )
list ( GET __availableToolchainArchs ${ __toolchainIdx } __toolchainArch )
if ( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME )
message ( FATAL _ERROR "Previously selected toolchain \" ${ ANDROID_TOOLCHAIN_NAME } \" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform. " )
message ( SEND _ERROR "Previously selected toolchain \" ${ ANDROID_TOOLCHAIN_NAME } \" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform. " )
endif ( )
else ( )
set ( __toolchainIdx -1 )
@ -491,13 +491,13 @@ string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVE
# 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 ( FATAL _ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
message ( SEND _ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
endif ( )
unset ( __levelIdx )
if ( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL ( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if ( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
message ( FATAL _ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
message ( SEND _ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif ( )
unset ( __realApiLevel )
endif ( )
@ -532,6 +532,10 @@ set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHI
set ( CMAKE_OBJDUMP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" )
set ( CMAKE_RANLIB "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" )
# 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
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" )
@ -548,23 +552,23 @@ endif()
set ( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS ON CACHE INTERNAL "" FORCE )
# i n c l u d e s
include_directories ( SYSTEM "${ANDROID_SYSROOT}/usr/include" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
if ( __stlIncludePath AND EXISTS "${__stlIncludePath}" )
include_directories ( SYSTEM "${__stlIncludePath}" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" )
endif ( )
# S T L b i t s i n c l u d e s
if ( __stlLibPath AND EXISTS "${__stlLibPath}/include" )
include_directories ( SYSTEM "${__stlLibPath}/include" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" )
endif ( )
if ( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb/bits" )
include_directories ( SYSTEM "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
elseif ( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
include_directories ( SYSTEM "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
elseif ( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
include_directories ( SYSTEM "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
list ( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
elseif ( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/bits" )
include_directories ( SYSTEM "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
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
@ -637,7 +641,9 @@ elseif( X86 )
endif ( )
# l i n k e r f l a g s
set ( LINKER_FLAGS "-L\" ${ CMAKE_BINARY_DIR } /systemlibs/ ${ ANDROID_NDK_ABI_NAME } \" -L\ "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}\" " )
list ( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}" "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
# set ( LINKER_FLAGS "-L\" ${ CMAKE_BINARY_DIR } /systemlibs/ ${ ANDROID_NDK_ABI_NAME } \" -L\ "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}\" " )
set ( LINKER_FLAGS "" )
# S T L
if ( NOT EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
if ( EXISTS "${__stlLibPath}/libgnustl_static.a" )
@ -674,6 +680,7 @@ if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a"
set ( LINKER_FLAGS "${LINKER_FLAGS} -lsupc++" )
endif ( )
# c l e a n u p f o r S T L s e a r c h
unset ( __stlIncludePath )
unset ( __stlLibPath )
@ -702,6 +709,9 @@ set( CMAKE_SHARED_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" )
set ( CMAKE_MODULE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -Wl,-z,nocopyreloc ${LINKER_FLAGS}" 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
set ( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
@ -803,7 +813,9 @@ endif()
# 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 _ A R C H _ N A M E : " a r m " 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
# 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
# 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 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
# 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
#