• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Platform defines.
2set(CMAKE_SYSTEM_NAME		Linux)
3set(CMAKE_SYSTEM_PROCESSOR	arm-eabi)
4
5set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
6
7set(CMAKE_CROSSCOMPILING 1)
8
9# dE defines
10set(DE_CPU		"DE_CPU_ARM")
11set(DE_OS		"DE_OS_ANDROID")
12set(DE_COMPILER	"DE_COMPILER_GCC")
13
14# NDK installation path
15set(ANDROID_NDK_PATH	"/opt/android-ndk-r4/"	CACHE STRING "Android NDK installation path")
16set(ANDROID_NDK_HOST_OS	"linux-x86"				CACHE STRING "Android ndk host os")
17set(ANDROID_NDK_TARGET	"android-5"				CACHE STRING "Android target")
18set(ANDROID_ABI			"armeabi-v7a"			CACHE STRING "Android ABI")
19
20# \todo [pyry] Detect host type
21set(ANDROID_CC_PATH	"${ANDROID_NDK_PATH}/build/prebuilt/${ANDROID_NDK_HOST_OS}/arm-eabi-4.4.0/")
22set(CROSS_COMPILE	"${ANDROID_CC_PATH}bin/arm-eabi-")
23
24include(CMakeForceCompiler)
25
26if (ANDROID_NDK_HOST_OS STREQUAL "linux-x86")
27	cmake_force_c_compiler("${CROSS_COMPILE}gcc"		GNU)
28	cmake_force_cxx_compiler("${CROSS_COMPILE}g++"		GNU)
29elseif (ANDROID_NDK_HOST_OS STREQUAL "windows")
30	cmake_force_c_compiler("${CROSS_COMPILE}gcc.exe"	GNU)
31	cmake_force_cxx_compiler("${CROSS_COMPILE}g++.exe"	GNU)
32else ()
33	message(FATAL_ERROR "Unknown ANDROID_NDK_HOST_OS")
34endif ()
35
36set(CMAKE_SHARED_LIBRARY_C_FLAGS "")
37set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
38
39set(CMAKE_C_CREATE_SHARED_LIBRARY
40  "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
41set(CMAKE_CXX_CREATE_SHARED_LIBRARY
42  "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
43
44
45# Search libs and include files (but not programs) from toolchain dir.
46set(CMAKE_FIND_ROOT_PATH
47	"${ANDROID_NDK_PATH}/build/platforms/${ANDROID_NDK_TARGET}/arch-arm"
48	"${ANDROID_CC_PATH}arm-eabi"
49	)
50set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
51set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
52set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
53
54include_directories(
55	"${ANDROID_NDK_PATH}/build/platforms/${ANDROID_NDK_TARGET}/arch-arm/usr/include"
56	)
57
58link_directories(
59	"${ANDROID_NDK_PATH}/build/platforms/${ANDROID_NDK_TARGET}/arch-arm/usr/lib"
60	)
61
62set(NDK_FLAGS "-fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -mfloat-abi=softfp -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -D__ANDROID__ -D__STDC_INT64__")
63
64if (ANDROID_ABI STREQUAL "armeabi-v7a")
65	# For armeabi-v7a
66	set(NDK_FLAGS "${NDK_FLAGS} -march=armv7-a -mfpu=vfp")
67
68elseif (ANDROID_ABI STREQUAL "armeabi")
69	# For armeabi (ARMv5TE)
70	set(NDK_FLAGS "${NDK_FLAGS} -march=armv5te")
71
72else ()
73	message(FATAL_ERROR "Unknown Android ABI \"${ANDROID_ABI}\"")
74endif ()
75
76# \note Hacky workaround for flags...
77set(CMAKE_C_FLAGS	"${NDK_FLAGS}" CACHE STRING "" FORCE)
78set(CMAKE_CXX_FLAGS	"${NDK_FLAGS}" CACHE STRING "" FORCE)
79set(CMAKE_SHARED_LINKER_FLAGS "-nostdlib -Wl,-shared,-Bsymbolic -Wl,--no-undefined" CACHE STRING "" FORCE)
80