summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake')
-rw-r--r--src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake
new file mode 100644
index 0000000..15dea2d
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake
@@ -0,0 +1,74 @@
1#[=======================================================================[
2
3This CMake script is meant to be used in CMake script mode (cmake -P).
4It wraps commands that communicate with an actual Android device.
5Because
6
7#]=======================================================================]
8
9cmake_minimum_required(VERSION 3.16...3.28)
10
11if(NOT CMAKE_SCRIPT_MODE_FILE)
12 message(FATAL_ERROR "This file can only be used in CMake script mode")
13endif()
14if(NOT ADB)
15 set(ADB "adb")
16endif()
17
18if(NOT ACTION)
19 message(FATAL_ERROR "Missing ACTION argument")
20endif()
21
22if(ACTION STREQUAL "uninstall")
23 # The uninstall action attempts to uninstall all packages. All failures are ignored.
24 foreach(package IN LISTS PACKAGES)
25 message("Uninstalling ${package} ...")
26 execute_process(
27 COMMAND ${ADB} uninstall ${package}
28 RESULT_VARIABLE res
29 )
30 message("... result=${res}")
31 endforeach()
32elseif(ACTION STREQUAL "install")
33 # The install actions attempts to install APK's to an Android device using adb. Failures are ignored.
34 set(failed_apks "")
35 foreach(apk IN LISTS APKS)
36 message("Installing ${apk} ...")
37 execute_process(
38 COMMAND ${ADB} install -d -r --streaming ${apk}
39 RESULT_VARIABLE res
40 )
41 message("... result=${res}")
42 if(NOT res EQUAL 0)
43 list(APPEND failed_apks ${apk})
44 endif()
45 endforeach()
46 if(failed_apks)
47 message(FATAL_ERROR "Failed to install ${failed_apks}")
48 endif()
49elseif(ACTION STREQUAL "build-install-run")
50 if(NOT EXECUTABLES)
51 message(FATAL_ERROR "Missing EXECUTABLES (don't know what executables to build/install and start")
52 endif()
53 if(NOT BUILD_FOLDER)
54 message(FATAL_ERROR "Missing BUILD_FOLDER (don't know where to build the APK's")
55 endif()
56 set(install_targets "")
57 foreach(executable IN LISTS EXECUTABLES)
58 list(APPEND install_targets "install-${executable}")
59 endforeach()
60 execute_process(
61 COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target ${install_targets}
62 RESULT_VARIABLE res
63 )
64 if(NOT res EQUAL 0)
65 message(FATAL_ERROR "Failed to install APK(s) for ${EXECUTABLES}")
66 endif()
67 list(GET EXECUTABLES 0 start_executable)
68 execute_process(
69 COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target start-${start_executable}
70 RESULT_VARIABLE res
71 )
72else()
73 message(FATAL_ERROR "Unknown ACTION=${ACTION}")
74endif()