diff --git a/cmake/toolchains/android.toolchain.cmake b/cmake/toolchains/android.toolchain.cmake index e6271d9d8..64472ea34 100644 --- a/cmake/toolchains/android.toolchain.cmake +++ b/cmake/toolchains/android.toolchain.cmake @@ -1,10 +1,12 @@ # ------------------------------------------------------------------------------ -# Android CMake toolchain file, for use with the Android NDK r5-r8 +# Android CMake toolchain file, for use with the Android NDK r5-r9 # 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 -# http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake +# The file was forked from the OpenCV project. This version is maintained by +# the SFML project and can be found at http://github.com/LaurentGomila/SFML +# (cmake/toolchains/android.toolchain.cmake). It brings support for the +# latest NDK versions. # # Usage Linux: # $ export ANDROID_NDK=/absolute/path/to/the/android-ndk @@ -114,6 +116,9 @@ # Ethan Rublee ethan.ruble@gmail.com # Andrey Kamaev andrey.kamaev@itseez.com # +# Contributors: +# Jonathan De Wachter dewachter.jonathan@gmail.com +# # Change Log: # - initial version December 2010 # - modified April 2011 @@ -187,6 +192,9 @@ # [+] updated for NDK r8b # [~] all intermediate files generated by toolchain are moved into CMakeFiles # [~] libstdc++ and libsupc are removed from explicit link libraries +# - modified September 2013 +# [+] updated for NDK r9 +# [+] support 64-bits toolchains # ------------------------------------------------------------------------------ cmake_minimum_required( VERSION 2.6.3 ) @@ -206,7 +214,7 @@ set( CMAKE_SYSTEM_NAME Linux ) # this one not so much set( CMAKE_SYSTEM_VERSION 1 ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9 -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) @@ -357,14 +365,24 @@ if( ANDROID_FORBID_SYGWIN ) endif() # detect current host platform + set( TOOL_OS_SUFFIX "" ) if( CMAKE_HOST_APPLE ) set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" ) + if(NOT EXISTS "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}") + set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86_64" ) + endif() elseif( CMAKE_HOST_WIN32 ) set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" ) set( TOOL_OS_SUFFIX ".exe" ) + if(NOT EXISTS "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}") + set( ANDROID_NDK_HOST_SYSTEM_NAME "windows-x86_64" ) + endif() elseif( CMAKE_HOST_UNIX ) set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" ) + if(NOT EXISTS "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}") + set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86_64" ) + endif() else() message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) endif() @@ -800,7 +818,7 @@ else() endif() if( ANDROID_USE_STLPORT ) - set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" ) + set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fno-exceptions" ) set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-exceptions" ) else() set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fexceptions" ) @@ -847,9 +865,9 @@ if( ARMEABI_V7A ) if( NEON ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) elseif( VFPV3 ) - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) else() - set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfp" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) endif() elseif( ARMEABI_V6 ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) @@ -868,9 +886,9 @@ set( ANDROID_LINKER_FLAGS "" ) # STL if( ANDROID_USE_STLPORT ) - if( EXISTS "${__stlLibPath}/libstlport_static.a" ) - set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o \"${__stlLibPath}/libstlport_static.a\"") - set( CMAKE_CXX_CREATE_SHARED_MODULE " -o \"${__stlLibPath}/libstlport_static.a\"") + if( EXISTS "${__stlLibPath}/libstlport_shared.so" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY " -o \"${__stlLibPath}/libstlport_shared.so\"") + set( CMAKE_CXX_CREATE_SHARED_MODULE " -o \"${__stlLibPath}/libstlport_shared.so\"") endif() else( ANDROID_USE_STLPORT ) if( EXISTS "${__stlLibPath}/libgnustl_static.a" )