Commit 25e2442d authored by Ghislain MARY's avatar Ghislain MARY

Use CMake toolchain from Android NDK.

parent 210a3c55
......@@ -26,4 +26,4 @@ project(gdbserver LANGUAGES) # Dummy project
configure_file(gdb.setup.in gdb.setup @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gdb.setup" DESTINATION bin)
install(PROGRAMS "${CMAKE_ANDROID_NDK}/prebuilt/android-${CMAKE_ANDROID_ARCH}/gdbserver/gdbserver" DESTINATION bin)
install(PROGRAMS "${CMAKE_ANDROID_NDK}/prebuilt/android-${ANDROID_SYSROOT_ABI}/gdbserver/gdbserver" DESTINATION bin)
......@@ -165,24 +165,19 @@ lcb_builder_install_target(x264 "install-lib-static")
# Copy c++ library to install prefix
if(CMAKE_ANDROID_NDK_VERSION VERSION_LESS 16)
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"
)
else()
file(COPY "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++_shared.so"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)
if(ENABLE_SANITIZER)
set(SANITIZER_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if(SANITIZER_ARCH MATCHES "^arm")
set(SANITIZER_ARCH "arm")
endif()
file(GLOB_RECURSE _clang_rt_library "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/*/clang/*/lib/linux/libclang_rt.asan-${SANITIZER_ARCH}-android.so")
if(_clang_rt_library)
file(COPY ${_clang_rt_library} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/android/wrap.sh.cmake" "${CMAKE_INSTALL_PREFIX}/lib/wrap.sh" @ONLY)
endif()
file(COPY "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++_shared.so"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)
if(ENABLE_SANITIZER)
set(SANITIZER_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if(SANITIZER_ARCH MATCHES "^arm")
set(SANITIZER_ARCH "arm")
endif()
file(GLOB_RECURSE _clang_rt_library "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}/*/clang/*/lib/linux/libclang_rt.asan-${SANITIZER_ARCH}-android.so")
if(_clang_rt_library)
list(GET _clang_rt_library 0 _clang_rt_library)
file(COPY ${_clang_rt_library} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/android/wrap.sh.cmake" "${CMAKE_INSTALL_PREFIX}/lib/wrap.sh" @ONLY)
endif()
endif()
......
......@@ -33,27 +33,13 @@ file(READ "${CMAKE_ANDROID_NDK}/source.properties" SOURCE_PROPERTIES_CONTENT)
string(REGEX MATCH "Pkg\\.Revision = ([0-9]+)\\." NDK_VERSION_MATCH "${SOURCE_PROPERTIES_CONTENT}")
set(CMAKE_ANDROID_NDK_VERSION ${CMAKE_MATCH_1})
set(CMAKE_SYSTEM_NAME "Android")
if(NOT CMAKE_ANDROID_API)
set(CMAKE_ANDROID_API 16)
endif()
set(ANDROID_NATIVE_API_LEVEL "android-16")
set(ANDROID_CPP_FEATURES "rtti exceptions")
set(ANDROID_STL "c++_shared")
if(CMAKE_ANDROID_NDK_VERSION VERSION_LESS 16)
set(CMAKE_ANDROID_STL_TYPE "gnustl_shared")
else()
set(CMAKE_ANDROID_STL_TYPE "c++_shared")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a ${CMAKE_EXE_LINKER_FLAGS}")
endif()
include("${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake")
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
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(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
......
......@@ -20,5 +20,5 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "armv5te")
set(ANDROID_ABI "armeabi")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
......@@ -20,7 +20,5 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
set(CMAKE_ANDROID_API 21)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
set(ANDROID_ABI "arm64-v8a")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
......@@ -20,7 +20,5 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "armv7-a")
set(CMAKE_ANDROID_ARM_NEON 1)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
set(ANDROID_ABI "armeabi-v7a with NEON")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
......@@ -20,6 +20,5 @@
#
############################################################################
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
set(ANDROID_ABI "x86")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
......@@ -20,7 +20,5 @@
#
############################################################################
set(CMAKE_ANDROID_API 21)
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
set(ANDROID_ABI "x86_64")
include("${CMAKE_CURRENT_LIST_DIR}/android/toolchain-android.cmake")
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