mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-04 16:28:00 +01:00
127 lines
5.4 KiB
Text
127 lines
5.4 KiB
Text
SET(CMAKE_SYSTEM_NAME Linux)
|
|
SET(CMAKE_SYSTEM_VERSION 1)
|
|
|
|
set(ANDROID_HOME "$ENV{ANDROID_HOME}" CACHE PATH "Path to Android SDK" )
|
|
|
|
#set path for android toolchain -- look
|
|
|
|
set(ANDROID_ALLEGRO_ROOT "$ENV{ANDROID_ALLEGRO_ROOT}" CACHE PATH "Path to Allegro 5 (>=5.2.2) build directory for Android" )
|
|
|
|
message( STATUS "Selected Allegro dir: ${ANDROID_ALLEGRO_ROOT}" )
|
|
if(NOT EXISTS "${ANDROID_ALLEGRO_ROOT}")
|
|
message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to the build directory of Allegro 5 (>=5.2.2) for Android.")
|
|
endif()
|
|
|
|
set(ANDROID_TOOLCHAIN "$ENV{ANDROID_TOOLCHAIN}" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
|
|
|
|
message( STATUS "Selected Android toolchain: ${ANDROID_TOOLCHAIN}" )
|
|
if(NOT EXISTS ${ANDROID_TOOLCHAIN})
|
|
set(ANDROID_TOOLCHAIN "/opt/android-toolchain" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
|
|
message( STATUS "Using default path for toolchain ${ANDROID_TOOLCHAIN}")
|
|
message( STATUS "If you prefer to use a different location, please set the ANDROID_TOOLCHAIN cmake variable.")
|
|
endif()
|
|
|
|
if(NOT EXISTS ${ANDROID_TOOLCHAIN})
|
|
message(FATAL_ERROR
|
|
"${ANDROID_TOOLCHAIN} does not exist!
|
|
You should either set an environment variable:
|
|
export ANDROID_TOOLCHAIN=~/my-toolchain
|
|
or put the toolchain in the default path:
|
|
sudo ln -s ~/android-toolchain /opt/android-toolchain
|
|
")
|
|
endif()
|
|
|
|
find_program(CMAKE_MAKE_PROGRAM make)
|
|
|
|
#setup build targets, mutually exclusive
|
|
set(PossibleArmTargets
|
|
"x86;x86_64;armeabi;armeabi-v7a;armeabi-v7a with NEON;arm64-v8a;mips;mips64")
|
|
set(ARM_TARGETS "armeabi-v7a" CACHE STRING
|
|
"the arm targets for android, recommend armeabi-v7a
|
|
for floating point support and NEON.")
|
|
|
|
if(ARM_TARGETS STREQUAL "x86")
|
|
set(ANDROID_ARCH "i686-linux-android")
|
|
elseif(ARM_TARGETS STREQUAL "x86_64")
|
|
set(ANDROID_ARCH "x86_64-linux-android")
|
|
elseif(ARM_TARGETS STREQUAL "arm64-v8a")
|
|
set(ANDROID_ARCH "aarch64-linux-android")
|
|
elseif(ARM_TARGETS STREQUAL "mips")
|
|
set(ANDROID_ARCH "mipsel-linux-android")
|
|
elseif(ARM_TARGETS STREQUAL "mips64")
|
|
set(ANDROID_ARCH "mips64el-linux-android")
|
|
elseif(ARM_TARGETS STREQUAL "armeabi")
|
|
set(ANDROID_ARCH "arm-linux-androideabi")
|
|
set(ARMEABI true)
|
|
set(NEON false)
|
|
elseif(ARM_TARGETS STREQUAL "armeabi-v7a")
|
|
set(ARMEABI true)
|
|
set(ANDROID_ARCH "arm-linux-androideabi")
|
|
set(NEON false)
|
|
elseif(ARM_TARGETS STREQUAL "armeabi-v7a with NEON")
|
|
set(ARMEABI true)
|
|
set(ANDROID_ARCH "arm-linux-androideabi")
|
|
set(NEON true)
|
|
else()
|
|
message(FATAL_ERROR "Unknown Android target ${ARM_TARGETS}")
|
|
endif()
|
|
|
|
if(WIN32)
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".exe")
|
|
endif()
|
|
|
|
# specify the cross compiler
|
|
SET(CMAKE_C_COMPILER
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-clang${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C compiler" FORCE)
|
|
SET(CMAKE_CXX_COMPILER
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-clang++${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C++ compiler" FORCE)
|
|
#there may be a way to make cmake deduce these TODO deduce the rest of the tools
|
|
set(CMAKE_AR
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ar${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "archive" FORCE)
|
|
set(CMAKE_LINKER
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ld${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "linker" FORCE)
|
|
set(CMAKE_NM
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-nm${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "nm" FORCE)
|
|
set(CMAKE_OBJCOPY
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objcopy" FORCE)
|
|
set(CMAKE_OBJDUMP
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-objdump${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objdump" FORCE)
|
|
set(CMAKE_STRIP
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "strip" FORCE)
|
|
set(CMAKE_RANLIB
|
|
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "ranlib" FORCE)
|
|
|
|
set_property(CACHE ARM_TARGETS PROPERTY STRINGS ${PossibleArmTargets} )
|
|
|
|
set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR}/android/app CACHE PATH
|
|
"root for library output, set this to change where
|
|
android libs are installed to")
|
|
|
|
#set these flags for client use
|
|
set(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARM_TARGETS}
|
|
CACHE PATH "path for android libs" FORCE)
|
|
set(CMAKE_INSTALL_PREFIX ${ANDROID_TOOLCHAIN}/user/${ARM_TARGETS}
|
|
CACHE STRING "path for installing" FORCE)
|
|
|
|
# where is the target environment
|
|
SET(CMAKE_FIND_ROOT_PATH ${ANDROID_TOOLCHAIN}/bin ${ANDROID_TOOLCHAIN}/arm-linux-androideabi ${ANDROID_TOOLCHAIN}/sysroot ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/share)
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
|
# only search for libraries and includes in the ndk toolchain
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
#set these global flags for cmake client scripts to change behavior
|
|
set(ANDROID True)
|
|
set(BUILD_ANDROID True)
|
|
|
|
#make use of ANDROID_CFLAGS, ANDROID_LDFLAGS and ANDROID_CXXFLAGS
|
|
set(CMAKE_C_FLAGS "$ENV{ANDROID_CFLAGS} $ENV{CFLAGS}" CACHE STRING "" FORCE)
|
|
set(CMAKE_CXX_FLAGS "$ENV{ANDROID_CXXFLAGS} $ENV{CXXFLAGS}" CACHE STRING "" FORCE)
|
|
set(CMAKE_SHARED_LINKER_FLAGS "$ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
|
|
set(CMAKE_MODULE_LINKER_FLAGS "$ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
|
|
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-pie $ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
|
|
|
|
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
|
|
if (CMAKE_TOOLCHAIN_FILE)
|
|
endif()
|