Commit 999250f4 authored by Ghislain MARY's avatar Ghislain MARY

Simplify Android toolchain by relying on Android support in CMake 3.7.

parent 6a740319
......@@ -26,11 +26,13 @@ project(androidcpufeatures LANGUAGES C)
include(GNUInstallDirs)
add_library(cpufeatures STATIC "${ANDROID_CPU_FEATURES_INCLUDE_DIRS}/cpu-features.c")
add_library(cpufeatures STATIC "${CMAKE_ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c")
install(TARGETS cpufeatures
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install(FILES "${CMAKE_ANDROID_NDK}/sources/android/cpufeatures/cpu-features.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
......@@ -27,24 +27,34 @@ include(GNUInstallDirs)
set(SUPPORT_SOURCES
"${ANDROID_SUPPORT}/src/musl-multibyte/wctomb.c"
"${CMAKE_ANDROID_NDK}/sources/android/support/src/musl-multibyte/wctomb.c"
)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
list(APPEND SUPPORT_SOURCES
"${ANDROID_SUPPORT}/src/musl-locale/iconv.c"
"${ANDROID_SUPPORT}/src/musl-locale/langinfo.c"
"${ANDROID_SUPPORT}/src/musl-locale/nl_langinfo_l.c"
"${CMAKE_ANDROID_NDK}/sources/android/support/src/musl-locale/iconv.c"
"${CMAKE_ANDROID_NDK}/sources/android/support/src/musl-locale/langinfo.c"
"${CMAKE_ANDROID_NDK}/sources/android/support/src/musl-locale/nl_langinfo_l.c"
)
endif()
add_library(support STATIC ${SUPPORT_SOURCES})
target_include_directories(support PUBLIC "${CMAKE_ANDROID_NDK}/sources/android/support/include")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(support PRIVATE "-std=c99")
endif()
install(TARGETS support
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
install(FILES
"${CMAKE_ANDROID_NDK}/sources/android/support/include/ctype.h"
"${CMAKE_ANDROID_NDK}/sources/android/support/include/iconv.h"
"${CMAKE_ANDROID_NDK}/sources/android/support/include/langinfo.h"
"${CMAKE_ANDROID_NDK}/sources/android/support/include/nl_types.h"
"${CMAKE_ANDROID_NDK}/sources/android/support/include/xlocale.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
......@@ -124,6 +124,7 @@ else()
)
endif()
elseif(ANDROID)
get_filename_component(TOOLCHAIN_PATH "${CMAKE_LINKER}" DIRECTORY)
lcb_configure_options(
"--enable-decoder=h264"
"--disable-iconv"
......@@ -135,14 +136,14 @@ else()
set(FFMPEG_TARGET_OS "linux")
set(FFMPEG_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
lcb_make_options("RANLIB=\"\$RANLIB\"")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
lcb_configure_options("--enable-neon" "--cpu=cortex-a8" "--disable-armv5te" "--enable-armv6" "--enable-armv6t2")
else()
lcb_configure_options("--disable-mmx" "--disable-sse2" "--disable-ssse3" "--disable-asm")
endif()
if(CMAKE_C_COMPILER_TARGET) # When building with clang
lcb_configure_options("--extra-cflags=--target=${CMAKE_C_COMPILER_TARGET} --gcc-toolchain=${EXTERNAL_TOOLCHAIN_PATH}/..")
lcb_configure_options("--extra-ldflags=--target=${CMAKE_C_COMPILER_TARGET} --gcc-toolchain=${EXTERNAL_TOOLCHAIN_PATH}/..")
lcb_configure_options("--extra-cflags=--target=${CMAKE_C_COMPILER_TARGET} --gcc-toolchain=${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
lcb_configure_options("--extra-ldflags=--target=${CMAKE_C_COMPILER_TARGET} --gcc-toolchain=${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
endif()
else()
set(FFMPEG_TARGET_OS "linux")
......
......@@ -51,12 +51,12 @@ else()
if(MSVC)
lcb_additional_options("OS=\"msvc\"")
elseif(ANDROID)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
lcb_additional_options("OS=\"android\" NDKROOT=\"${ANDROID_NDK_PATH}\" NDKLEVEL=${CMAKE_ANDROID_API} TOOLCHAINPREFIX=\"${TOOLCHAIN_PREFIX}\" TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"arm\"")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
lcb_additional_options("OS=\"android\" NDKROOT=\"${CMAKE_ANDROID_NDK}\" NDKLEVEL=${CMAKE_ANDROID_API} TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"arm\"")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
lcb_additional_options("OS=\"android\" NDKROOT=\"${ANDROID_NDK_PATH}\" NDKLEVEL=${CMAKE_ANDROID_API} TOOLCHAINPREFIX=\"${TOOLCHAIN_PREFIX}\" TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"arm64\"")
lcb_additional_options("OS=\"android\" NDKROOT=\"${CMAKE_ANDROID_NDK}\" NDKLEVEL=${CMAKE_ANDROID_API} TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"arm64\"")
else()
lcb_additional_options("OS=\"android\" NDKROOT=\"${ANDROID_NDK_PATH}\" NDKLEVEL=${CMAKE_ANDROID_API} TOOLCHAINPREFIX=\"${TOOLCHAIN_PREFIX}\" TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"x86\"")
lcb_additional_options("OS=\"android\" NDKROOT=\"${CMAKE_ANDROID_NDK}\" NDKLEVEL=${CMAKE_ANDROID_API} TARGET=\"android-${CMAKE_ANDROID_API}\" ARCH=\"x86\"")
endif()
elseif(APPLE)
if(IOS)
......
......@@ -44,7 +44,7 @@ else()
lcb_linking_type("-DENABLE_STATIC=YES")
if(ANDROID)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
lcb_cmake_options("-DENABLE_ARMV7NEON=YES")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi")
lcb_cmake_options("-DENABLE_ARMV5E=YES")
......
......@@ -117,16 +117,13 @@ if(WIN32)
endif()
if(ENABLE_ARMV5E OR ENABLE_ARMV7NEON)
if(ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
set(ARCH_OPTIONS "-mfpu=neon")
endif()
get_directory_property(DIRECTORY_PROPERTY_COMPILE_OPTIONS "COMPILE_OPTIONS")
string(REPLACE ";" " " DIRECTORY_PROPERTY_COMPILE_OPTIONS "${DIRECTORY_PROPERTY_COMPILE_OPTIONS}")
set(CMAKE_ASM_TARGET_FLAG "")
if(CMAKE_C_COMPILER_TARGET)
set(CMAKE_ASM_TARGET_FLAG "--target=${CMAKE_C_COMPILER_TARGET}")
endif()
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${CMAKE_ASM_TARGET_FLAG} ${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS} ${DIRECTORY_PROPERTY_COMPILE_OPTIONS} ${ARCH_OPTIONS} -o <OBJECT> -c <SOURCE>")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${CMAKE_ASM_TARGET_FLAG} ${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS} ${DIRECTORY_PROPERTY_COMPILE_OPTIONS} -o <OBJECT> -c <SOURCE>")
enable_language(ASM)
endif()
......
......@@ -122,16 +122,16 @@ else()
endif()
lcb_linking_type("--enable-static" "--disable-shared" "--enable-pic")
elseif(ANDROID)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv5te")
message(FATAL_ERROR "VPX cannot be built on arm.")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
set(VPX_TARGET "armv7-android-gcc")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(VPX_TARGET "arm64-android-gcc")
else()
set(VPX_TARGET "x86-android-gcc")
endif()
lcb_configure_options("--sdk-path=${ANDROID_NDK_PATH}/")
lcb_configure_options("--sdk-path=${CMAKE_ANDROID_NDK}/")
lcb_linking_type("--enable-static" "--disable-shared" "--enable-pic")
elseif(QNX)
set(VPX_TARGET "armv7-qnx-gcc")
......
......@@ -74,18 +74,15 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_C_FLAGS_MINSIZEREL:STRING
CMAKE_C_FLAGS_RELEASE:STRING
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING
CMAKE_C_FLAGS:STRING
CMAKE_CXX_COMPILER_LAUNCHER:PATH
CMAKE_CXX_FLAGS_DEBUG:STRING
CMAKE_CXX_FLAGS_MINSIZEREL:STRING
CMAKE_CXX_FLAGS_RELEASE:STRING
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING
CMAKE_CXX_FLAGS:STRING
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING
CMAKE_EXE_LINKER_FLAGS:STRING
CMAKE_EXTRA_GENERATOR:STRING
CMAKE_GENERATOR_PLATFORM:STRING
CMAKE_INSTALL_MESSAGE:STRING
......@@ -97,7 +94,6 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING
CMAKE_MODULE_LINKER_FLAGS:STRING
CMAKE_MODULE_PATH:PATH
CMAKE_NO_BUILD_TYPE:BOOL
CMAKE_NO_SYSTEM_FROM_IMPORTED:BOOL
......@@ -108,7 +104,6 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING
CMAKE_SHARED_LINKER_FLAGS:STRING
CMAKE_SKIP_INSTALL_RPATH:BOOL
CMAKE_SKIP_RPATH:BOOL
CMAKE_SKIP_BUILD_RPATH:BOOL
......@@ -355,27 +350,27 @@ macro(linphone_builder_apply_flags)
endif()
if(LINPHONE_BUILDER_CPPFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_C_FLAGS "${AUTOTOOLS_C_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_CXX_FLAGS "${AUTOTOOLS_CXX_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
endif()
if(LINPHONE_BUILDER_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LINPHONE_BUILDER_CFLAGS}")
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_CFLAGS}")
set(AUTOTOOLS_C_FLAGS "${AUTOTOOLS_C_FLAGS} ${LINPHONE_BUILDER_CFLAGS}")
endif()
if(LINPHONE_BUILDER_CXXFLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LINPHONE_BUILDER_CXXFLAGS}")
set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_CXXFLAGS}")
set(AUTOTOOLS_CXX_FLAGS "{AUTOTOOLS_CXX_FLAGS} ${LINPHONE_BUILDER_CXX_FLAGS}")
endif()
if(LINPHONE_BUILDER_OBJCFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(AUTOTOOLS_OBJC_FLAGS "${AUTOTOOLS_OBJC_FLAGS} ${LINPHONE_BUILDER_OBJCFLAGS}")
endif()
if(LINPHONE_BUILDER_LDFLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE}} ${LINPHONE_BUILDER_LDFLAGS}")
set(AUTOTOOLS_LINKER_FLAGS "${AUTOTOOLS_LINKER_FLAGS} ${LINPHONE_BUILDER_LDFLAGS}")
endif()
endmacro()
......
#!/bin/sh
@TOOLCHAIN_STRIP@ $*
@CMAKE_STRIP@ $*
......@@ -75,6 +75,10 @@ include(builders/CMakeLists.txt)
set(EP_bctoolbox_LINKING_TYPE "-DENABLE_STATIC=NO" "-DENABLE_SHARED=YES")
lcb_builder_cmake_options(bctoolbox "-DENABLE_TESTS=NO")
# belcard
lcb_builder_cmake_options(belcard "-DENABLE_TOOLS=NO")
lcb_builder_cmake_options(belcard "-DENABLE_UNIT_TESTS=NO")
# belle-sip
lcb_builder_cmake_options(bellesip "-DENABLE_TESTS=NO")
......@@ -112,6 +116,7 @@ lcb_builder_cmake_options(ms2 "-DENABLE_V4L=NO")
lcb_builder_cmake_options(ms2 "-DENABLE_X11=NO")
lcb_builder_cmake_options(ms2 "-DENABLE_XV=NO")
lcb_builder_cmake_options(ms2 "-DENABLE_DOC=NO")
lcb_builder_cmake_options(ms2 "-DENABLE_UNIT_TESTS=NO")
lcb_builder_linking_type(ms2 "-DENABLE_STATIC=NO" "-DENABLE_SHARED=YES")
# openh264
......@@ -121,6 +126,10 @@ endif()
# opus
lcb_builder_cmake_options(opus "-DENABLE_FIXED_POINT=YES")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv5te")
lcb_builder_cmake_options(opus "-DENABLE_ASM=NO")
lcb_builder_cmake_options(opus "-DENABLE_INTRINSICS=NO")
endif()
# ortp
lcb_builder_cmake_options(ortp "-DENABLE_DOC=NO")
......@@ -132,7 +141,7 @@ lcb_builder_linking_type(polarssl "-DUSE_SHARED_POLARSSL_LIBRARY=NO")
# speex
lcb_builder_cmake_options(speex "-DENABLE_FLOAT_API=NO")
lcb_builder_cmake_options(speex "-DENABLE_FIXED_POINT=YES")
if(NDK_ARCHITECTURE STREQUAL "armeabi-v7a")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
lcb_builder_cmake_options(speex "-DENABLE_ARM_NEON_INTRINSICS=YES")
endif()
......@@ -145,7 +154,7 @@ lcb_builder_install_target(x264 "install-lib-static")
# Copy c++ library to install prefix
file(COPY "${ANDROID_NDK_PATH}/sources/cxx-stl/gnu-libstdc++/${GCC_VERSION}/libs/${NDK_ARCHITECTURE}/libgnustl_shared.so"
file(COPY "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_CXX_ANDROID_TOOLCHAIN_VERSION}/libs/${CMAKE_ANDROID_ARCH_ABI}/libgnustl_shared.so"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)
......
......@@ -20,141 +20,19 @@
#
############################################################################
if(NOT CMAKE_ANDROID_API)
set(CMAKE_ANDROID_API 14)
endif()
set(CMAKE_ANDROID_STL_TYPE gnustl_shared)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
# Define name of the target system
set(CMAKE_SYSTEM_NAME "Linux")
set(ANDROID True)
find_program(ANDROID_NDK_BUILD_PROGRAM ndk-build)
if(NOT ANDROID_NDK_BUILD_PROGRAM)
message(FATAL_ERROR "Cannot find 'ndk-build', make sure you installed the NDK and added it to your PATH")
endif()
get_filename_component(ANDROID_NDK_PATH "${ANDROID_NDK_BUILD_PROGRAM}" DIRECTORY)
find_program(ANDROID_ANDROID_PROGRAM android)
if(NOT ANDROID_ANDROID_PROGRAM)
message(FATAL_ERROR "Cannot find 'android', make sure you installed the SDK and added it to your PATH")
endif()
get_filename_component(ANDROID_SDK_PATH "${ANDROID_ANDROID_PROGRAM}" DIRECTORY)
find_program(ANDROID_ADB_PROGRAM adb)
if(NOT ANDROID_ADB_PROGRAM)
message(FATAL_ERROR "Cannot find 'adb', make sure you installed the SDK platform tools and added it to your PATH")
endif()
get_filename_component(ANDROID_SDK_PLATFORM_TOOLS_PATH "${ANDROID_ADB_PROGRAM}" DIRECTORY)
find_file(CLANG_EXECUTABLE "clang"
PATHS
"${ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/darwin-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/linux-x86/bin"
NO_DEFAULT_PATH
)
if(CLANG_EXECUTABLE)
get_filename_component(TOOLCHAIN_PATH "${CLANG_EXECUTABLE}" DIRECTORY)
set(GCC_VERSION "4.9")
if(NDK_ARCHITECTURE STREQUAL "armeabi-v7a")
set(GCC_LIBRARY_ADDITIONAL_DIR "/armv7-a")
endif()
find_file(GCC_LIBRARY "libgcc.a"
PATHS
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/darwin-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/darwin-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/darwin-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/darwin-x86_64/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x${GCC_LIBRARY_ADDITIONAL_DIR}"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86/lib/gcc/${COMPILER_PREFIX}/${GCC_VERSION}.x"
NO_DEFAULT_PATH
)
if(NOT GCC_LIBRARY)
message(FATAL_ERROR "Cannot find libgcc.a")
endif()
get_filename_component(GCC_LIBRARY_PATH "${GCC_LIBRARY}" DIRECTORY)
find_file(GCC_EXECUTABLE "${COMPILER_PREFIX}-gcc"
PATHS
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/darwin-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/darwin-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86/bin"
NO_DEFAULT_PATH
)
if(NOT GCC_EXECUTABLE)
message(FATAL_ERROR "Cannot find gcc")
endif()
get_filename_component(EXTERNAL_TOOLCHAIN_PATH "${GCC_EXECUTABLE}" DIRECTORY)
#Define the compiler
set(_CMAKE_TOOLCHAIN_PREFIX "${COMPILER_PREFIX}-")
set(CMAKE_C_COMPILER "${CLANG_EXECUTABLE}")
set(CMAKE_C_COMPILER_TARGET "${CLANG_TARGET}")
set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${EXTERNAL_TOOLCHAIN_PATH}/..")
set(CMAKE_CXX_COMPILER "${CLANG_EXECUTABLE}++")
set(CMAKE_CXX_COMPILER_TARGET "${CLANG_TARGET}")
set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${EXTERNAL_TOOLCHAIN_PATH}/..")
set(TOOLCHAIN_PREFIX "${EXTERNAL_TOOLCHAIN_PATH}/${COMPILER_PREFIX}-")
set(TOOLCHAIN_STRIP "${TOOLCHAIN_PREFIX}strip")
else()
set(GCC_VERSION "4.8")
find_file(GCC_EXECUTABLE "${COMPILER_PREFIX}-gcc"
PATHS
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/darwin-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/darwin-x86_64/bin"
"${ANDROID_NDK_PATH}/toolchains/${COMPILER_PREFIX}-${GCC_VERSION}/prebuilt/linux-x86/bin"
"${ANDROID_NDK_PATH}/toolchains/${NDK_ARCHITECTURE}-${GCC_VERSION}/prebuilt/linux-x86/bin"
NO_DEFAULT_PATH
)
if(NOT GCC_EXECUTABLE)
message(FATAL_ERROR "Cannot find the compiler")
endif()
get_filename_component(TOOLCHAIN_PATH "${GCC_EXECUTABLE}" DIRECTORY)
set(TOOLCHAIN_PREFIX "${TOOLCHAIN_PATH}/${COMPILER_PREFIX}-")
set(TOOLCHAIN_CC "${TOOLCHAIN_PREFIX}gcc")
set(TOOLCHAIN_CXX "${TOOLCHAIN_PREFIX}g++")
set(TOOLCHAIN_LD "${TOOLCHAIN_PREFIX}ld")
set(TOOLCHAIN_AR "${TOOLCHAIN_PREFIX}ar")
set(TOOLCHAIN_RANLIB "${TOOLCHAIN_PREFIX}ranlib")
set(TOOLCHAIN_STRIP "${TOOLCHAIN_PREFIX}strip")
set(TOOLCHAIN_NM "${TOOLCHAIN_PREFIX}nm")
# Define the compiler
set(CMAKE_C_COMPILER "${TOOLCHAIN_CC}")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_CXX}")
get_filename_component(CMAKE_ANDROID_NDK "${ANDROID_NDK_BUILD_PROGRAM}" DIRECTORY)
set(CMAKE_SYSTEM_NAME "Android")
if(NOT CMAKE_ANDROID_API)
set(CMAKE_ANDROID_API 14)
endif()
set(CMAKE_ANDROID_STL_TYPE "gnustl_shared")
set(CMAKE_SYSROOT "${ANDROID_NDK_PATH}/platforms/android-${CMAKE_ANDROID_API}/arch-${ARCHITECTURE}")
set(ANDROID_SUPPORT "${ANDROID_NDK_PATH}/sources/android/support")
set(ANDROID_SUPPORT_INCLUDE_DIRS "${ANDROID_SUPPORT}/include")
message(STATUS "Using sysroot path: ${CMAKE_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH "${CMAKE_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${ANDROID_SUPPORT}")
set(CMAKE_FIND_ROOT_PATH "${CMAKE_SYSROOT}" "${CMAKE_INSTALL_PREFIX}")
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
......@@ -162,35 +40,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK_PATH}/sources/cxx-stl/gnu-libstdc++/${GCC_VERSION}/include" "${ANDROID_NDK_PATH}/sources/cxx-stl/gnu-libstdc++/${GCC_VERSION}/libs/${NDK_ARCHITECTURE}/include")
if(EXISTS "${ANDROID_NDK_PATH}/sources/android/cpufeatures/cpu-features.c")
set(ANDROID_CPU_FEATURES_INCLUDE_DIRS "${ANDROID_NDK_PATH}/sources/android/cpufeatures")
elseif(EXISTS "${ANDROID_NDK_PATH}/sources/cpufeatures/cpu-features.c")
set(ANDROID_CPU_FEATURES_INCLUDE_DIRS "${ANDROID_NDK_PATH}/sources/cpufeatures")
else()
message(FATAL_ERROR "Cannot find cpu-features.c")
endif()
include_directories(SYSTEM ${ANDROID_CPU_FEATURES_INCLUDE_DIRS} ${ANDROID_STL_INCLUDE_DIRS} ${ANDROID_SUPPORT_INCLUDE_DIRS})
add_definitions("-DANDROID")
if(GCC_LIBRARY_PATH)
#link_directories("${GCC_LIBRARY_PATH}")
# link_directories has no effet for external projects so add the GCC library path to the compiler flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${GCC_LIBRARY_PATH}" CACHE STRING "linker flags" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${GCC_LIBRARY_PATH}" CACHE STRING "linker flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${GCC_LIBRARY_PATH}" CACHE STRING "linker flags" FORCE)
endif()
set(GNUSTL_PATH "${ANDROID_NDK_PATH}/sources/cxx-stl/gnu-libstdc++/${GCC_VERSION}/libs/${NDK_ARCHITECTURE}")
#link_directories("${GNUSTL_PATH}")
# link_directories has no effet for external projects so add the gnustl library path to the compiler flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${GNUSTL_PATH}" CACHE STRING "linker flags" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${GNUSTL_PATH}" CACHE STRING "linker flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${GNUSTL_PATH}" CACHE STRING "linker flags" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG")
link_libraries("${GNUSTL_PATH}/libgnustl_shared.so")
link_libraries("log")
link_libraries("atomic")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g -DNDEBUG")
......@@ -20,35 +20,5 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "armeabi")
set(ARCHITECTURE "arm")
set(NDK_ARCHITECTURE "armeabi")
set(COMPILER_PREFIX "arm-linux-androideabi")
set(CLANG_TARGET "arm-none-linux-androideabi")
set(CMAKE_SYSTEM_PROCESSOR "armv5te")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
add_compile_options(
"-ffunction-sections"
"-funwind-tables"
"-fstack-protector"
"-no-canonical-prefixes"
"-march=armv5te"
"-mtune=xscale"
"-msoft-float"
"-fomit-frame-pointer"
"-fno-strict-aliasing"
)
if(NOT CLANG_EXECUTABLE)
add_compile_options(
"-finline-limit=64"
)
endif()
link_libraries(
"-no-canonical-prefixes"
"-Wl,--no-undefined"
"-Wl,-z,noexecstack"
"-Wl,-z,relro"
"-Wl,-z,now"
)
......@@ -20,34 +20,7 @@
#
############################################################################
set(CMAKE_ANDROID_API 21)
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
set(ARCHITECTURE "arm64")
set(NDK_ARCHITECTURE "arm64-v8a")
set(COMPILER_PREFIX "aarch64-linux-android")
set(CLANG_TARGET "aarch64-none-linux-android")
set(CMAKE_ANDROID_API 21)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
link_libraries("m")
add_compile_options(
"-ffunction-sections"
"-funwind-tables"
"-fstack-protector"
"-no-canonical-prefixes"
"-fomit-frame-pointer"
"-fno-strict-aliasing"
)
if(NOT CLANG_EXECUTABLE)
add_compile_options(
"-finline-limit=300"
)
endif()
link_libraries(
"-no-canonical-prefixes"
"-Wl,--no-undefined"
"-Wl,-z,noexecstack"
"-Wl,-z,relro"
"-Wl,-z,now"
)
......@@ -20,37 +20,7 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "armeabi-v7a")
set(ARCHITECTURE "arm")
set(NDK_ARCHITECTURE "armeabi-v7a")
set(COMPILER_PREFIX "arm-linux-androideabi")
set(CLANG_TARGET "armv7-none-linux-androideabi")
set(CMAKE_SYSTEM_PROCESSOR "armv7-a")
set(CMAKE_ANDROID_ARM_NEON 1)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
add_compile_options(
"-ffunction-sections"
"-funwind-tables"
"-fstack-protector"
"-no-canonical-prefixes"
"-march=armv7-a"
"-mfpu=vfpv3-d16"
"-mfloat-abi=softfp"
"-fomit-frame-pointer"
"-fno-strict-aliasing"
)
if(NOT CLANG_EXECUTABLE)
add_compile_options(
"-finline-limit=64"
)
endif()
link_libraries(
"-march=armv7-a"
"-Wl,--fix-cortex-a8"
"-no-canonical-prefixes"
"-Wl,--no-undefined"
"-Wl,-z,noexecstack"
"-Wl,-z,relro"
"-Wl,-z,now"
)
......@@ -20,33 +20,6 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "x86")
set(ARCHITECTURE "x86")
set(NDK_ARCHITECTURE "x86")
set(COMPILER_PREFIX "i686-linux-android")
set(CLANG_TARGET "i686-none-linux-androideabi")
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
add_compile_options(
"-ffunction-sections"
"-funwind-tables"
"-fstack-protector"
"-no-canonical-prefixes"
"-fomit-frame-pointer"
"-fstrict-aliasing"
)
if(NOT CLANG_EXECUTABLE)
add_compile_options(
"-funswitch-loops"
"-finline-limit=300"
)
endif()
link_libraries(
"-no-canonical-prefixes"
"-Wl,--no-undefined"
"-Wl,-z,noexecstack"
"-Wl,-z,relro"
"-Wl,-z,now"
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment