-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
73 lines (60 loc) · 2.34 KB
/
Copy pathCMakeLists.txt
File metadata and controls
73 lines (60 loc) · 2.34 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cmake_minimum_required(VERSION 3.12)
if (NOT DEFINED NDK_ROOT)
if (DEFINED ENV{NDK_ROOT})
set(NDK_ROOT "$ENV{NDK_ROOT}")
else ()
message(FATAL_ERROR "Please define NDK_ROOT to point to your NDK path!")
endif ()
endif ()
find_program(ZIP NAMES zip)
# Set the tool chain file
set(CMAKE_TOOLCHAIN_FILE ${NDK_ROOT}/build/cmake/android.toolchain.cmake)
set(ANDROID_ABI arm64-v8a)
set(ANDROID_PLATFORM latest)
set(ANDROID_STL none)
set(ANDROID_LD lld)
add_compile_options(-Wall -Wextra -pedantic -Werror)
set(DEFAULT_FUTURE_DATE "2099-12" CACHE STRING "Select os_patch_level date.")
option(SELF_PACK_EXECUTABLES "Self-pack executables." ON)
set(UPDATE_ZIP "backtothefuture-${DEFAULT_FUTURE_DATE}.zip")
project(BackToTheFuture)
set(CMAKE_C_FLAGS_RELEASE "-O2 -flto")
set(ANDROID_PIE FALSE)
link_libraries("-static")
add_executable(change_os_version change_os_version.c)
if (CMAKE_BUILD_TYPE STREQUAL Release)
add_custom_command(
TARGET change_os_version
POST_BUILD
COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" --strip-all change_os_version
COMMENT "Stripping the executables"
VERBATIM
)
if (SELF_PACK_EXECUTABLES)
include("${CMAKE_ROOT}/Modules/FindSelfPackers.cmake")
if (SELF_PACKER_FOR_EXECUTABLE)
add_custom_command(
TARGET change_os_version
POST_BUILD
COMMAND ${SELF_PACKER_FOR_EXECUTABLE} -9q ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} change_os_version
COMMENT "Packing the executables"
VERBATIM
)
endif ()
endif ()
endif ()
if (NOT CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/META-INF/com/google/android/update-binary
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/META-INF/com/google/android/update-binary
${CMAKE_CURRENT_BINARY_DIR}/META-INF/com/google/android/update-binary
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/META-INF/com/google/android/update-binary
)
endif ()
add_custom_target(zip
DEPENDS change_os_version
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/META-INF/com/google/android/update-binary
COMMAND ${ZIP} ${UPDATE_ZIP} change_os_version META-INF/com/google/android/update-binary
COMMENT "Preparing ${UPDATE_ZIP}"
VERBATIM
)