Atlas - SdlAndroidScript.cmake
Home / ext / SDL / cmake / android Lines: 1 | Size: 2383 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]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() 75[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.