-
Notifications
You must be signed in to change notification settings - Fork 6
/
cmake_caches.cmake
52 lines (46 loc) · 1.96 KB
/
cmake_caches.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copied from NDK's android.toolchain.cmake:
if(ANDROID_ABI STREQUAL armeabi-v7a)
set(ANDROID_SYSROOT_ABI arm)
set(ANDROID_TOOLCHAIN_NAME arm-linux-androideabi)
set(ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_NAME})
set(ANDROID_HEADER_TRIPLE arm-linux-androideabi)
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
set(ANDROID_LLVM_TRIPLE armv7-unknown-linux-android)
elseif(ANDROID_ABI STREQUAL arm64-v8a)
set(ANDROID_SYSROOT_ABI arm64)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ANDROID_TOOLCHAIN_NAME aarch64-linux-android)
set(ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_NAME})
set(ANDROID_LLVM_TRIPLE aarch64-unknown-linux-android)
set(ANDROID_HEADER_TRIPLE aarch64-linux-android)
elseif(ANDROID_ABI STREQUAL x86_64)
set(ANDROID_SYSROOT_ABI x86_64)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(ANDROID_TOOLCHAIN_NAME x86_64-linux-android)
set(ANDROID_TOOLCHAIN_ROOT ${ANDROID_ABI})
set(ANDROID_LLVM_TRIPLE x86_64-unknown-linux-android)
set(ANDROID_HEADER_TRIPLE x86_64-linux-android)
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set(ANDROID_HOST_TAG linux-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(ANDROID_HOST_TAG darwin-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(ANDROID_HOST_TAG windows-x86_64)
endif()
######################################################################
# Make a list that we then convert to a (space-delimited) string, below
set(SWIFT_FLAGS
-L "${SWIFT_SDK}/usr/lib/${ANDROID_TOOLCHAIN_NAME}/24"
-g # always produce debug symbols
-sdk "${ANDROID_NDK}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}/sysroot"
-resource-dir "${SWIFT_SDK}/usr/lib/swift"
-tools-directory "${ANDROID_NDK}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}/bin"
# -v
)
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
list(APPEND SWIFT_FLAGS -O)
endif()
list(JOIN SWIFT_FLAGS " " SWIFT_FLAGS)
set(CMAKE_Swift_FLAGS "${SWIFT_FLAGS}" CACHE INTERNAL "")
set(CMAKE_Swift_COMPILER_TARGET "${ANDROID_LLVM_TRIPLE}24" CACHE INTERNAL "")