|
|
@ -28,14 +28,14 @@ IF(TARGET_CPU STREQUAL "armv7")
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(MINIMUM_NDK_TARGET 4)
|
|
|
|
SET(MINIMUM_NDK_TARGET 9)
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "armv5")
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "armv5")
|
|
|
|
SET(LIBRARY_ARCHITECTURE "armeabi")
|
|
|
|
SET(LIBRARY_ARCHITECTURE "armeabi")
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "armv5")
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "armv5")
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
SET(TOOLCHAIN_ARCH "arm")
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
|
|
|
|
SET(MINIMUM_NDK_TARGET 4)
|
|
|
|
SET(MINIMUM_NDK_TARGET 9)
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "arm64")
|
|
|
|
ELSEIF(TARGET_CPU STREQUAL "arm64")
|
|
|
|
SET(LIBRARY_ARCHITECTURE "arm64-v8a")
|
|
|
|
SET(LIBRARY_ARCHITECTURE "arm64-v8a")
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "arm64")
|
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR "arm64")
|
|
|
@ -76,14 +76,9 @@ ELSE()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
|
|
|
|
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
|
|
|
|
SET(ANDROID_COMPILER "GCC")
|
|
|
|
SET(ANDROID_COMPILER "clang")
|
|
|
|
|
|
|
|
|
|
|
|
IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang")
|
|
|
|
|
|
|
|
SET(ANDROID_COMPILER "clang")
|
|
|
|
SET(ANDROID_COMPILER "clang")
|
|
|
|
SET(CLANG ON)
|
|
|
|
SET(CLANG ON)
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION})
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT NDK_TARGET)
|
|
|
|
IF(NOT NDK_TARGET)
|
|
|
|
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
|
|
|
|
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
|
|
|
@ -94,88 +89,71 @@ ELSE()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
IF(CMAKE_HOST_WIN32)
|
|
|
|
IF(CMAKE_HOST_WIN32)
|
|
|
|
SET(TOOLCHAIN_HOST "windows")
|
|
|
|
SET(TOOLCHAIN_HOST "windows-x86_64")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX ".exe")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX ".exe")
|
|
|
|
ELSEIF(CMAKE_HOST_APPLE)
|
|
|
|
ELSEIF(CMAKE_HOST_APPLE)
|
|
|
|
SET(TOOLCHAIN_HOST "apple")
|
|
|
|
SET(TOOLCHAIN_HOST "apple")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX "")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX "")
|
|
|
|
ELSEIF(CMAKE_HOST_UNIX)
|
|
|
|
ELSEIF(CMAKE_HOST_UNIX)
|
|
|
|
SET(TOOLCHAIN_HOST "linux")
|
|
|
|
SET(TOOLCHAIN_HOST "linux-x86_64")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX "")
|
|
|
|
SET(TOOLCHAIN_BIN_SUFFIX "")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
MACRO(SEARCH_TOOLCHAIN _COMPILER)
|
|
|
|
# clang
|
|
|
|
SET(${_COMPILER}_TOOLCHAIN_VERSIONS)
|
|
|
|
SET(CLANG_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${CLANG_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}")
|
|
|
|
FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-*")
|
|
|
|
|
|
|
|
|
|
|
|
IF(EXISTS ${CLANG_TOOLCHAIN_ROOT})
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Found LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
MESSAGE(FATAL_ERROR "No LLVM toolchain found in default search path ${CLANG_TOOLCHAIN_ROOT}")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# gcc
|
|
|
|
|
|
|
|
SET(GCC_TOOLCHAIN_VERSIONS)
|
|
|
|
|
|
|
|
FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${GCC_TOOLCHAIN_PREFIX}-*")
|
|
|
|
IF(_TOOLCHAIN_VERSIONS)
|
|
|
|
IF(_TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(SORT _TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(SORT _TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(REVERSE _TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(REVERSE _TOOLCHAIN_VERSIONS)
|
|
|
|
FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS})
|
|
|
|
FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS})
|
|
|
|
STRING(REGEX REPLACE ".+${_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}")
|
|
|
|
STRING(REGEX REPLACE ".+${_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}")
|
|
|
|
IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
|
|
|
|
IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
|
|
|
|
LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION})
|
|
|
|
LIST(APPEND GCC_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION})
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
|
|
|
ENDFOREACH()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
# try prefixes without version
|
|
|
|
IF(NOT GCC_TOOLCHAIN_VERSIONS)
|
|
|
|
SET(_TOOLCHAIN_WITHOUT_VERSION "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}")
|
|
|
|
MESSAGE(FATAL_ERROR "No GCC version found in default search path ${NDK_ROOT}/toolchains")
|
|
|
|
IF(EXISTS ${_TOOLCHAIN_WITHOUT_VERSION})
|
|
|
|
|
|
|
|
LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS "default")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT ${_COMPILER}_TOOLCHAIN_VERSIONS)
|
|
|
|
|
|
|
|
MESSAGE(FATAL_ERROR "No Android ${_COMPILER} toolchain found in default search path ${NDK_ROOT}/toolchains")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
IF(${_COMPILER}_TOOLCHAIN_VERSIONS)
|
|
|
|
IF(GCC_TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(FIND ${_COMPILER}_TOOLCHAIN_VERSIONS "${${_COMPILER}_TOOLCHAIN_VERSION}" _INDEX)
|
|
|
|
LIST(FIND GCC_TOOLCHAIN_VERSIONS "${GCC_TOOLCHAIN_VERSION}" _INDEX)
|
|
|
|
IF(_INDEX EQUAL -1)
|
|
|
|
IF(_INDEX EQUAL -1)
|
|
|
|
LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION)
|
|
|
|
LIST(GET GCC_TOOLCHAIN_VERSIONS 0 GCC_TOOLCHAIN_VERSION)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
ELSE()
|
|
|
|
LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION)
|
|
|
|
LIST(GET GCC_TOOLCHAIN_VERSIONS 0 GCC_TOOLCHAIN_VERSION)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "TOOLCHAIN_PREFIX = ${${_COMPILER}_TOOLCHAIN_VERSION}")
|
|
|
|
SET(GCC_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${GCC_TOOLCHAIN_PREFIX}-${GCC_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}")
|
|
|
|
|
|
|
|
|
|
|
|
IF("${${_COMPILER}_TOOLCHAIN_VERSION}" STREQUAL "default")
|
|
|
|
|
|
|
|
MESSAGE(STATUS "default")
|
|
|
|
|
|
|
|
SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
MESSAGE(STATUS "not default")
|
|
|
|
|
|
|
|
SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT EXISTS "${${_COMPILER}_TOOLCHAIN_ROOT}")
|
|
|
|
IF(NOT EXISTS "${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*")
|
|
|
|
FILE(GLOB _TOOLCHAIN_PREFIXES "${GCC_TOOLCHAIN_ROOT}*")
|
|
|
|
IF(_TOOLCHAIN_PREFIXES)
|
|
|
|
IF(_TOOLCHAIN_PREFIXES)
|
|
|
|
LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT)
|
|
|
|
LIST(GET _TOOLCHAIN_PREFIXES 0 GCC_TOOLCHAIN_ROOT)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(CLANG)
|
|
|
|
|
|
|
|
SEARCH_TOOLCHAIN(CLANG)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use clang ${CLANG_TOOLCHAIN_VERSION}")
|
|
|
|
IF(EXISTS "${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
ENDIF()
|
|
|
|
MESSAGE(STATUS "Found GCC toolchain in ${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
SEARCH_TOOLCHAIN(GCC)
|
|
|
|
MESSAGE(FATAL_ERROR "No GCC toolchain found in default search path ${GCC_TOOLCHAIN_ROOT}")
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# NDK
|
|
|
|
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
|
|
|
|
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}")
|
|
|
|
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} found in ${PLATFORM_ROOT}")
|
|
|
|
|
|
|
|
|
|
|
|
# include dirs
|
|
|
|
# include dirs
|
|
|
|
SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include")
|
|
|
|
SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include")
|
|
|
@ -208,17 +186,18 @@ MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY)
|
|
|
|
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
|
|
|
|
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
|
|
|
|
ENDMACRO()
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
# Force the compilers to GCC for Android
|
|
|
|
SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
include (CMakeForceCompiler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(CLANG)
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Using clang compiler")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++)
|
|
|
|
|
|
|
|
|
|
|
|
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang)
|
|
|
|
SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER})
|
|
|
|
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang)
|
|
|
|
SET(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_BIN_PREFIX})
|
|
|
|
|
|
|
|
SET(CMAKE_C_COMPILER_FORCED TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
|
|
|
|
SET(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN_BIN_PREFIX})
|
|
|
|
|
|
|
|
SET(CMAKE_CXX_COMPILER_FORCED TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar)
|
|
|
|
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar)
|
|
|
@ -231,19 +210,6 @@ IF(CLANG)
|
|
|
|
IF(NOT EXISTS "${CMAKE_AR}")
|
|
|
|
IF(NOT EXISTS "${CMAKE_AR}")
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar)
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_GCC(CMAKE_STRIP strip)
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_STRIP strip)
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_NM nm)
|
|
|
|
SET_TOOLCHAIN_BINARY_GCC(CMAKE_NM nm)
|
|
|
|