|
|
|
@ -15,48 +15,76 @@ IF(NOT NDK_ROOT)
|
|
|
|
|
|
|
|
|
|
IF(CMAKE_HOST_WIN32)
|
|
|
|
|
FILE(TO_CMAKE_PATH ${NDK_ROOT} NDK_ROOT)
|
|
|
|
|
ENDIF(CMAKE_HOST_WIN32)
|
|
|
|
|
ENDIF(NOT NDK_ROOT)
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
IF(NOT TARGET_CPU)
|
|
|
|
|
SET(TARGET_CPU "armv7")
|
|
|
|
|
ENDIF(NOT TARGET_CPU)
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
SET(ARMV7_HARD_FLOAT OFF)
|
|
|
|
|
|
|
|
|
|
IF(TARGET_CPU STREQUAL "armv7")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "armeabi-v7a")
|
|
|
|
|
IF(ARMV7_HARD_FLOAT)
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "${LIBRARY_ARCHITECTURE}-hard")
|
|
|
|
|
ENDIF()
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 4)
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "armv5")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "armeabi")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "armv5")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 4)
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "arm64")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "arm64-v8a")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "arm64")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "arm64")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "aarch64-linux-android")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "aarch64-linux-android")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 21)
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "x86")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "x86")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "x86")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "x86")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "x86")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "i686")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "i686-linux-android")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 9)
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "x86_64")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "x86_64")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "x86_64")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "x86_64")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "x86_64-linux-android")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 21)
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "mips")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "mips")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "mips")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "mips")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "mipsel-linux-android")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "mipsel")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "mipsel-linux-android")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 9)
|
|
|
|
|
ENDIF(TARGET_CPU STREQUAL "armv7")
|
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "mips64")
|
|
|
|
|
SET(LIBRARY_ARCHITECTURE "mips64")
|
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "mips64")
|
|
|
|
|
SET(TOOLCHAIN_ARCH "mips64")
|
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "mips64el-linux-android")
|
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "mips64el-linux-android")
|
|
|
|
|
SET(MINIMUM_NDK_TARGET 21)
|
|
|
|
|
ELSE()
|
|
|
|
|
MESSAGE(FATAL_ERROR "Unable to process TARGET_CPU ${TARGET_CPU}")
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
|
|
|
|
|
SET(ANDROID_COMPILER "GCC")
|
|
|
|
|
|
|
|
|
|
IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang")
|
|
|
|
|
SET(ANDROID_COMPILER "clang")
|
|
|
|
|
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
|
|
|
|
|
SET(CLANG ON)
|
|
|
|
|
ELSE()
|
|
|
|
|
SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION})
|
|
|
|
@ -64,7 +92,11 @@ ENDIF()
|
|
|
|
|
|
|
|
|
|
IF(NOT NDK_TARGET)
|
|
|
|
|
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
|
|
|
|
|
ENDIF(NOT NDK_TARGET)
|
|
|
|
|
ELSE()
|
|
|
|
|
IF(NDK_TARGET LESS MINIMUM_NDK_TARGET)
|
|
|
|
|
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
IF(CMAKE_HOST_WIN32)
|
|
|
|
|
SET(TOOLCHAIN_HOST "windows")
|
|
|
|
@ -75,7 +107,7 @@ ELSEIF(CMAKE_HOST_APPLE)
|
|
|
|
|
ELSEIF(CMAKE_HOST_UNIX)
|
|
|
|
|
SET(TOOLCHAIN_HOST "linux")
|
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX "")
|
|
|
|
|
ENDIF(CMAKE_HOST_WIN32)
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
MACRO(SEARCH_TOOLCHAIN _COMPILER)
|
|
|
|
|
SET(${_COMPILER}_TOOLCHAIN_VERSIONS)
|
|
|
|
@ -110,7 +142,7 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER)
|
|
|
|
|
FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*")
|
|
|
|
|
IF(_TOOLCHAIN_PREFIXES)
|
|
|
|
|
LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT)
|
|
|
|
|
ENDIF(_TOOLCHAIN_PREFIXES)
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
@ -123,8 +155,14 @@ ENDIF()
|
|
|
|
|
SEARCH_TOOLCHAIN(GCC)
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}")
|
|
|
|
|
MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}")
|
|
|
|
|
MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
|
|
|
|
|
|
IF(CLANG_TOOLCHAIN_ROOT)
|
|
|
|
|
MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}")
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
IF(GCC_TOOLCHAIN_ROOT)
|
|
|
|
|
MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
|
|
|
|
|
|
|
|
|
@ -137,14 +175,7 @@ SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++")
|
|
|
|
|
IF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
|
|
|
|
|
# NDK version >= 8b
|
|
|
|
|
SET(STL_DIR "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
|
|
|
|
|
ENDIF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
|
|
|
|
|
|
|
|
|
|
# Determine bin prefix for toolchain
|
|
|
|
|
FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-*-gcc${TOOLCHAIN_BIN_SUFFIX}")
|
|
|
|
|
IF(_TOOLCHAIN_BIN_PREFIXES)
|
|
|
|
|
LIST(GET _TOOLCHAIN_BIN_PREFIXES 0 _TOOLCHAIN_BIN_PREFIX)
|
|
|
|
|
STRING(REGEX REPLACE "${GCC_TOOLCHAIN_ROOT}/bin/([a-z0-9-]+)-gcc${TOOLCHAIN_BIN_SUFFIX}" "\\1" TOOLCHAIN_BIN_PREFIX "${_TOOLCHAIN_BIN_PREFIX}")
|
|
|
|
|
ENDIF(_TOOLCHAIN_BIN_PREFIXES)
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
SET(STL_INCLUDE_DIR "${STL_DIR}/include")
|
|
|
|
|
SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}")
|
|
|
|
@ -160,39 +191,45 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
|
|
|
|
|
|
MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY)
|
|
|
|
|
IF("${_BINARY}" MATCHES "clang")
|
|
|
|
|
SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE )
|
|
|
|
|
ELSE()
|
|
|
|
|
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDMACRO(SET_TOOLCHAIN_BINARY)
|
|
|
|
|
MACRO(SET_TOOLCHAIN_BINARY_LLVM _NAME _BINARY)
|
|
|
|
|
SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE )
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY)
|
|
|
|
|
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
# Force the compilers to GCC for Android
|
|
|
|
|
include (CMakeForceCompiler)
|
|
|
|
|
|
|
|
|
|
IF(CLANG)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER clang)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER clang++)
|
|
|
|
|
MESSAGE(STATUS "Using clang compiler")
|
|
|
|
|
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++)
|
|
|
|
|
|
|
|
|
|
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang)
|
|
|
|
|
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang)
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Using clang compiler")
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++)
|
|
|
|
|
ELSE()
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++)
|
|
|
|
|
MESSAGE(STATUS "Using GCC compiler")
|
|
|
|
|
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_C_COMPILER gcc)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_CXX_COMPILER g++)
|
|
|
|
|
|
|
|
|
|
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU)
|
|
|
|
|
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU)
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Using GCC compiler")
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_LINKER ld)
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_STRIP strip)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_AR ar)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_LINKER ld)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_NM nm)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_OBJCOPY objcopy)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_OBJDUMP objdump)
|
|
|
|
|
SET_TOOLCHAIN_BINARY(CMAKE_RANLIB ranlib)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_STRIP strip)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_NM nm)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_OBJCOPY objcopy)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_OBJDUMP objdump)
|
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_RANLIB ranlib)
|
|
|
|
|