diff options
Diffstat (limited to 'contrib/SDL-3.2.8/cmake/android/FindSdlAndroidBuildTools.cmake')
| -rw-r--r-- | contrib/SDL-3.2.8/cmake/android/FindSdlAndroidBuildTools.cmake | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/cmake/android/FindSdlAndroidBuildTools.cmake b/contrib/SDL-3.2.8/cmake/android/FindSdlAndroidBuildTools.cmake new file mode 100644 index 0000000..999a268 --- /dev/null +++ b/contrib/SDL-3.2.8/cmake/android/FindSdlAndroidBuildTools.cmake | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | #[=======================================================================[ | ||
| 2 | |||
| 3 | FindSdlAndroidBuildTools | ||
| 4 | ---------------------- | ||
| 5 | |||
| 6 | Locate the Android build tools directory. | ||
| 7 | |||
| 8 | |||
| 9 | Imported targets | ||
| 10 | ^^^^^^^^^^^^^^^^ | ||
| 11 | |||
| 12 | This find module defines the following :prop_tgt:`IMPORTED` target(s): | ||
| 13 | |||
| 14 | <none> | ||
| 15 | |||
| 16 | Result variables | ||
| 17 | ^^^^^^^^^^^^^^^^ | ||
| 18 | |||
| 19 | This module will set the following variables in your project: | ||
| 20 | |||
| 21 | `` SdlAndroidBuildTools_FOUND | ||
| 22 | if false, no Android build tools have been found | ||
| 23 | |||
| 24 | `` SDL_ANDROID_BUILD_TOOLS_ROOT | ||
| 25 | path of the Android build tools root directory if found | ||
| 26 | |||
| 27 | `` SDL_ANDROID_BUILD_TOOLS_VERSION | ||
| 28 | the human-readable string containing the android build tools version if found | ||
| 29 | |||
| 30 | Cache variables | ||
| 31 | ^^^^^^^^^^^^^^^ | ||
| 32 | |||
| 33 | These variables may optionally be set to help this module find the correct files: | ||
| 34 | |||
| 35 | ``SDL_ANDROID_BUILD_TOOLS_ROOT`` | ||
| 36 | path of the Android build tools root directory | ||
| 37 | |||
| 38 | |||
| 39 | Variables for locating Android platform | ||
| 40 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| 41 | |||
| 42 | This module responds to the flags: | ||
| 43 | |||
| 44 | ``SDL_ANDROID_HOME | ||
| 45 | First, this module will look for platforms in this CMake variable. | ||
| 46 | |||
| 47 | ``ANDROID_HOME | ||
| 48 | If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`. | ||
| 49 | |||
| 50 | ``$ENV{ANDROID_HOME} | ||
| 51 | If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}` | ||
| 52 | |||
| 53 | #]=======================================================================] | ||
| 54 | |||
| 55 | cmake_minimum_required(VERSION 3.7...3.28) | ||
| 56 | |||
| 57 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
| 58 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
| 59 | endif() | ||
| 60 | |||
| 61 | function(_sdl_is_valid_android_build_tools_root RESULT VERSION BUILD_TOOLS_ROOT) | ||
| 62 | set(result TRUE) | ||
| 63 | set(version -1) | ||
| 64 | |||
| 65 | string(REGEX MATCH "/([0-9.]+)$" root_match "${BUILD_TOOLS_ROOT}") | ||
| 66 | if(root_match | ||
| 67 | AND EXISTS "${BUILD_TOOLS_ROOT}/aapt2" | ||
| 68 | AND EXISTS "${BUILD_TOOLS_ROOT}/apksigner" | ||
| 69 | AND EXISTS "${BUILD_TOOLS_ROOT}/d8" | ||
| 70 | AND EXISTS "${BUILD_TOOLS_ROOT}/zipalign") | ||
| 71 | set(result "${BUILD_TOOLS_ROOT}") | ||
| 72 | set(version "${CMAKE_MATCH_1}") | ||
| 73 | endif() | ||
| 74 | |||
| 75 | set(${RESULT} ${result} PARENT_SCOPE) | ||
| 76 | set(${VERSION} ${version} PARENT_SCOPE) | ||
| 77 | endfunction() | ||
| 78 | |||
| 79 | function(_find_sdl_android_build_tools_root ROOT) | ||
| 80 | cmake_parse_arguments(fsabtr "" "" "" ${ARGN}) | ||
| 81 | set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME}) | ||
| 82 | set(root ${ROOT}-NOTFOUND) | ||
| 83 | foreach(home IN LISTS homes) | ||
| 84 | if(NOT IS_DIRECTORY "${home}") | ||
| 85 | continue() | ||
| 86 | endif() | ||
| 87 | file(GLOB build_tools_roots LIST_DIRECTORIES true "${home}/build-tools/*") | ||
| 88 | set(max_build_tools_version -1) | ||
| 89 | set(max_build_tools_root "") | ||
| 90 | foreach(build_tools_root IN LISTS build_tools_roots) | ||
| 91 | _sdl_is_valid_android_build_tools_root(is_valid build_tools_version "${build_tools_root}") | ||
| 92 | if(is_valid AND build_tools_version GREATER max_build_tools_version) | ||
| 93 | set(max_build_tools_version "${build_tools_version}") | ||
| 94 | set(max_build_tools_root "${build_tools_root}") | ||
| 95 | endif() | ||
| 96 | endforeach() | ||
| 97 | if(max_build_tools_version GREATER -1) | ||
| 98 | set(root ${max_build_tools_root}) | ||
| 99 | break() | ||
| 100 | endif() | ||
| 101 | endforeach() | ||
| 102 | set(${ROOT} ${root} PARENT_SCOPE) | ||
| 103 | endfunction() | ||
| 104 | |||
| 105 | if(NOT DEFINED SDL_ANDROID_BUILD_TOOLS_ROOT) | ||
| 106 | _find_sdl_android_build_tools_root(SDL_ANDROID_BUILD_TOOLS_ROOT) | ||
| 107 | set(SDL_ANDROID_BUILD_TOOLS_ROOT "${SDL_ANDROID_BUILD_TOOLS_ROOT}" CACHE PATH "Path of Android build tools") | ||
| 108 | endif() | ||
| 109 | |||
| 110 | include(FindPackageHandleStandardArgs) | ||
| 111 | |||
| 112 | find_package_handle_standard_args(SdlAndroidBuildTools | ||
| 113 | VERSION_VAR SDL_ANDROID_BUILD_TOOLS_VERSION | ||
| 114 | REQUIRED_VARS SDL_ANDROID_BUILD_TOOLS_ROOT | ||
| 115 | ) | ||
