|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
# ------------------------------------------------------------------------------ |
|
|
|
|
# Android CMake toolchain file, for use with the Android NDK r5-r8 |
|
|
|
|
# Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended). |
|
|
|
|
# Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended). |
|
|
|
|
# See home page: http://code.google.com/p/android-cmake/ |
|
|
|
|
# |
|
|
|
|
# The file is mantained by the OpenCV project. And also can be found at |
|
|
|
@ -44,7 +44,8 @@ |
|
|
|
|
# ANDROID_ABI=armeabi-v7a - specifies the target Application Binary |
|
|
|
|
# Interface (ABI). This option nearly matches to the APP_ABI variable |
|
|
|
|
# used by ndk-build tool from Android NDK. |
|
|
|
|
# Possible values are: |
|
|
|
|
# |
|
|
|
|
# Possible targets are: |
|
|
|
|
# "armeabi" - matches to the NDK ABI with the same name. |
|
|
|
|
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. |
|
|
|
|
# "armeabi-v7a" - matches to the NDK ABI with the same name. |
|
|
|
@ -56,6 +57,8 @@ |
|
|
|
|
# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP. |
|
|
|
|
# "x86" - matches to the NDK ABI with the same name. |
|
|
|
|
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation. |
|
|
|
|
# "mips" - matches to the NDK ABI with the same name |
|
|
|
|
# (not testes on real devices) |
|
|
|
|
# |
|
|
|
|
# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for. |
|
|
|
|
# Option is read-only when standalone toolchain used. |
|
|
|
@ -183,6 +186,7 @@ |
|
|
|
|
# - modified August 2012 |
|
|
|
|
# [+] updated for NDK r8b |
|
|
|
|
# [~] all intermediate files generated by toolchain are moved into CMakeFiles |
|
|
|
|
# [~] libstdc++ and libsupc are removed from explicit link libraries |
|
|
|
|
# ------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
|
|
cmake_minimum_required( VERSION 2.6.3 ) |
|
|
|
@ -705,6 +709,7 @@ if( APPLE ) |
|
|
|
|
endif() |
|
|
|
|
mark_as_advanced( CMAKE_INSTALL_NAME_TOOL ) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
# export directories |
|
|
|
|
set( ANDROID_SYSTEM_INCLUDE_DIRS "" ) |
|
|
|
|
set( ANDROID_SYSTEM_LIB_DIRS "" ) |
|
|
|
@ -728,7 +733,7 @@ if( __stlIncludePath AND EXISTS "${__stlIncludePath}" ) |
|
|
|
|
list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" ) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
#STL bits includes |
|
|
|
|
# c++ bits includes |
|
|
|
|
if( __stlLibPath AND EXISTS "${__stlLibPath}/include" ) |
|
|
|
|
list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" ) |
|
|
|
|
endif() |
|
|
|
@ -796,7 +801,7 @@ endif() |
|
|
|
|
|
|
|
|
|
if( ANDROID_USE_STLPORT ) |
|
|
|
|
set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" ) |
|
|
|
|
set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" ) |
|
|
|
|
set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-exceptions" ) |
|
|
|
|
else() |
|
|
|
|
set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fexceptions" ) |
|
|
|
|
set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fexceptions" ) |
|
|
|
@ -858,15 +863,14 @@ endif() |
|
|
|
|
if( NOT DEFINED __ndklibspath ) |
|
|
|
|
set( __ndklibspath "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ndklibs/${ANDROID_NDK_ABI_NAME}" ) |
|
|
|
|
endif() |
|
|
|
|
list( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) |
|
|
|
|
list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ) |
|
|
|
|
set( ANDROID_LINKER_FLAGS "" ) |
|
|
|
|
|
|
|
|
|
# STL |
|
|
|
|
if( ANDROID_USE_STLPORT ) |
|
|
|
|
if( EXISTS "${__stlLibPath}/libstlport_static.a" ) |
|
|
|
|
__COPY_IF_DIFFERENT( "${__stlLibPath}/libstlport_static.a" "${__ndklibspath}/libstlport_static.a" ) |
|
|
|
|
endif() |
|
|
|
|
if( EXISTS "${__ndklibspath}/libstlport_static.a" ) |
|
|
|
|
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--start-group -lstlport_static" ) |
|
|
|
|
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> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"") |
|
|
|
|
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> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"") |
|
|
|
|
endif() |
|
|
|
|
else( ANDROID_USE_STLPORT ) |
|
|
|
|
if( EXISTS "${__stlLibPath}/libgnustl_static.a" ) |
|
|
|
@ -880,11 +884,6 @@ else( ANDROID_USE_STLPORT ) |
|
|
|
|
elseif( EXISTS "${__stlLibPath}/libstdc++.a" ) |
|
|
|
|
__COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${__ndklibspath}/libstdc++.a" ) |
|
|
|
|
endif() |
|
|
|
|
if( EXISTS "${__ndklibspath}/libstdc++.a" ) |
|
|
|
|
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lstdc++" ) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
#gcc exception & rtti support |
|
|
|
|
if( EXISTS "${__stlLibPath}/libsupc++.a" ) |
|
|
|
|
__COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${__ndklibspath}/libsupc++.a" ) |
|
|
|
|
elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) |
|
|
|
@ -896,9 +895,7 @@ else( ANDROID_USE_STLPORT ) |
|
|
|
|
elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) |
|
|
|
|
__COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${__ndklibspath}/libsupc++.a" ) |
|
|
|
|
endif() |
|
|
|
|
if( EXISTS "${__ndklibspath}/libsupc++.a" ) |
|
|
|
|
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lsupc++" ) |
|
|
|
|
endif() |
|
|
|
|
list( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" ) |
|
|
|
|
endif( ANDROID_USE_STLPORT ) |
|
|
|
|
|
|
|
|
|
# cleanup for STL search |
|
|
|
@ -1044,7 +1041,11 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) |
|
|
|
|
set( __toolchain_config "") |
|
|
|
|
foreach( __var ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING __ndklibspath ) |
|
|
|
|
if( DEFINED ${__var} ) |
|
|
|
|
set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" )\n" ) |
|
|
|
|
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" ) |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
endforeach() |
|
|
|
|
file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" ) |
|
|
|
|