1
0

FindSdlAndroid.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #[=======================================================================[
  2. FindSdlAndroid
  3. ----------------------
  4. Locate various executables that are essential to creating an Android APK archive.
  5. This find module uses the FindSdlAndroidBuildTools module to locate some Android utils.
  6. Imported targets
  7. ^^^^^^^^^^^^^^^^
  8. This module defines the following :prop_tgt:`IMPORTED` target(s):
  9. `` SdlAndroid::aapt2 ``
  10. Imported executable for the "android package tool" v2
  11. `` SdlAndroid::apksigner``
  12. Imported executable for the APK signer tool
  13. `` SdlAndroid::d8 ``
  14. Imported executable for the dex compiler
  15. `` SdlAndroid::zipalign ``
  16. Imported executable for the zipalign util
  17. `` SdlAndroid::adb ``
  18. Imported executable for the "android debug bridge" tool
  19. `` SdlAndroid::keytool ``
  20. Imported executable for the keytool, a key and certificate management utility
  21. `` SdlAndroid::zip ``
  22. Imported executable for the zip, for packaging and compressing files
  23. Result variables
  24. ^^^^^^^^^^^^^^^^
  25. This module will set the following variables in your project:
  26. `` AAPT2_BIN ``
  27. Path of aapt2
  28. `` APKSIGNER_BIN ``
  29. Path of apksigner
  30. `` D8_BIN ``
  31. Path of d8
  32. `` ZIPALIGN_BIN ``
  33. Path of zipalign
  34. `` ADB_BIN ``
  35. Path of adb
  36. `` KEYTOOL_BIN ``
  37. Path of keytool
  38. `` ZIP_BIN ``
  39. Path of zip
  40. #]=======================================================================]
  41. cmake_minimum_required(VERSION 3.7...3.28)
  42. if(NOT PROJECT_NAME MATCHES "^SDL.*")
  43. message(WARNING "This module is internal to SDL and is currently not supported.")
  44. endif()
  45. find_package(SdlAndroidBuildTools MODULE)
  46. function(_sdl_android_find_create_imported_executable NAME)
  47. string(TOUPPER "${NAME}" NAME_UPPER)
  48. set(varname "${NAME_UPPER}_BIN")
  49. find_program("${varname}" NAMES "${NAME}" PATHS ${SDL_ANDROID_BUILD_TOOLS_ROOT})
  50. if(EXISTS "${${varname}}" AND NOT TARGET SdlAndroid::${NAME})
  51. add_executable(SdlAndroid::${NAME} IMPORTED)
  52. set_property(TARGET SdlAndroid::${NAME} PROPERTY IMPORTED_LOCATION "${${varname}}")
  53. endif()
  54. endfunction()
  55. if(SdlAndroidBuildTools_FOUND)
  56. _sdl_android_find_create_imported_executable(aapt2)
  57. _sdl_android_find_create_imported_executable(apksigner)
  58. _sdl_android_find_create_imported_executable(d8)
  59. _sdl_android_find_create_imported_executable(zipalign)
  60. endif()
  61. _sdl_android_find_create_imported_executable(adb)
  62. _sdl_android_find_create_imported_executable(keytool)
  63. _sdl_android_find_create_imported_executable(zip)
  64. include(FindPackageHandleStandardArgs)
  65. find_package_handle_standard_args(SdlAndroid
  66. VERSION_VAR
  67. REQUIRED_VARS
  68. AAPT2_BIN
  69. APKSIGNER_BIN
  70. D8_BIN
  71. ZIPALIGN_BIN
  72. KEYTOOL_BIN
  73. ZIP_BIN
  74. )