Atlas - FindSdlAndroidBuildTools.cmake

Home / ext / SDL / cmake / android Lines: 1 | Size: 3534 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1#[=======================================================================[ 2 3FindSdlAndroidBuildTools 4---------------------- 5 6Locate the Android build tools directory. 7 8 9Imported targets 10^^^^^^^^^^^^^^^^ 11 12This find module defines the following :prop_tgt:`IMPORTED` target(s): 13 14<none> 15 16Result variables 17^^^^^^^^^^^^^^^^ 18 19This 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 30Cache variables 31^^^^^^^^^^^^^^^ 32 33These 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 39Variables for locating Android platform 40^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 42This 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 55cmake_minimum_required(VERSION 3.7...3.28) 56 57if(NOT PROJECT_NAME MATCHES "^SDL.*") 58 message(WARNING "This module is internal to SDL and is currently not supported.") 59endif() 60 61function(_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) 77endfunction() 78 79function(_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) 103endfunction() 104 105if(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") 108endif() 109 110include(FindPackageHandleStandardArgs) 111 112find_package_handle_standard_args(SdlAndroidBuildTools 113 VERSION_VAR SDL_ANDROID_BUILD_TOOLS_VERSION 114 REQUIRED_VARS SDL_ANDROID_BUILD_TOOLS_ROOT 115) 116
[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.