diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake')
-rw-r--r-- | src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake new file mode 100644 index 0000000..fbe53c3 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake | |||
@@ -0,0 +1,124 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | FindSdlAndroidPlatform | ||
4 | ---------------------- | ||
5 | |||
6 | Locate the Android SDK platform. | ||
7 | |||
8 | |||
9 | Imported targets | ||
10 | ^^^^^^^^^^^^^^^^ | ||
11 | |||
12 | This module defines the following :prop_tgt:`IMPORTED` target(s): | ||
13 | |||
14 | <none> | ||
15 | |||
16 | Result variables | ||
17 | ^^^^^^^^^^^^^^^^ | ||
18 | |||
19 | This find module will set the following variables in your project: | ||
20 | |||
21 | `` SdlAndroidPlatform_FOUND | ||
22 | if false, no Android platform has been found | ||
23 | |||
24 | `` SDL_ANDROID_PLATFORM_ROOT | ||
25 | path of the Android SDK platform root directory if found | ||
26 | |||
27 | `` SDL_ANDROID_PLATFORM_ANDROID_JAR | ||
28 | path of the Android SDK platform jar file if found | ||
29 | |||
30 | `` SDL_ANDROID_PLATFORM_VERSION | ||
31 | the human-readable string containing the android platform version if found | ||
32 | |||
33 | Cache variables | ||
34 | ^^^^^^^^^^^^^^^ | ||
35 | |||
36 | These variables may optionally be set to help this module find the correct files: | ||
37 | |||
38 | ``SDL_ANDROID_PLATFORM_ROOT`` | ||
39 | path of the Android SDK platform root directory | ||
40 | |||
41 | |||
42 | Variables for locating Android platform | ||
43 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
44 | |||
45 | This module responds to the flags: | ||
46 | |||
47 | ``SDL_ANDROID_HOME | ||
48 | First, this module will look for platforms in this CMake variable. | ||
49 | |||
50 | ``ANDROID_HOME | ||
51 | If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`. | ||
52 | |||
53 | ``$ENV{ANDROID_HOME} | ||
54 | If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}` | ||
55 | |||
56 | #]=======================================================================] | ||
57 | |||
58 | cmake_minimum_required(VERSION 3.7...3.28) | ||
59 | |||
60 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
61 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
62 | endif() | ||
63 | |||
64 | function(_sdl_is_valid_android_platform_root RESULT VERSION PLATFORM_ROOT) | ||
65 | set(result FALSE) | ||
66 | set(version -1) | ||
67 | |||
68 | string(REGEX MATCH "/android-([0-9]+)$" root_match "${PLATFORM_ROOT}") | ||
69 | if(root_match AND EXISTS "${PLATFORM_ROOT}/android.jar") | ||
70 | set(result TRUE) | ||
71 | set(version "${CMAKE_MATCH_1}") | ||
72 | endif() | ||
73 | |||
74 | set(${RESULT} ${result} PARENT_SCOPE) | ||
75 | set(${VERSION} ${version} PARENT_SCOPE) | ||
76 | endfunction() | ||
77 | |||
78 | function(_sdl_find_android_platform_root ROOT) | ||
79 | cmake_parse_arguments(sfapr "" "" "" ${ARGN}) | ||
80 | set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME}) | ||
81 | set(root ${ROOT}-NOTFOUND) | ||
82 | foreach(home IN LISTS homes) | ||
83 | if(NOT IS_DIRECTORY "${home}") | ||
84 | continue() | ||
85 | endif() | ||
86 | file(GLOB platform_roots LIST_DIRECTORIES true "${home}/platforms/*") | ||
87 | set(max_platform_version -1) | ||
88 | set(max_platform_root "") | ||
89 | foreach(platform_root IN LISTS platform_roots) | ||
90 | _sdl_is_valid_android_platform_root(is_valid platform_version "${platform_root}") | ||
91 | if(is_valid AND platform_version GREATER max_platform_version) | ||
92 | set(max_platform_version "${platform_version}") | ||
93 | set(max_platform_root "${platform_root}") | ||
94 | endif() | ||
95 | endforeach() | ||
96 | if(max_platform_version GREATER -1) | ||
97 | set(root ${max_platform_root}) | ||
98 | break() | ||
99 | endif() | ||
100 | endforeach() | ||
101 | set(${ROOT} ${root} PARENT_SCOPE) | ||
102 | endfunction() | ||
103 | |||
104 | set(SDL_ANDROID_PLATFORM_ANDROID_JAR "SDL_ANDROID_PLATFORM_ANDROID_JAR-NOTFOUND") | ||
105 | |||
106 | if(NOT DEFINED SDL_ANDROID_PLATFORM_ROOT) | ||
107 | _sdl_find_android_platform_root(_new_sdl_android_platform_root) | ||
108 | set(SDL_ANDROID_PLATFORM_ROOT "${_new_sdl_android_platform_root}" CACHE PATH "Path of Android platform") | ||
109 | unset(_new_sdl_android_platform_root) | ||
110 | endif() | ||
111 | if(SDL_ANDROID_PLATFORM_ROOT) | ||
112 | _sdl_is_valid_android_platform_root(_valid SDL_ANDROID_PLATFORM_VERSION "${SDL_ANDROID_PLATFORM_ROOT}") | ||
113 | if(_valid) | ||
114 | set(SDL_ANDROID_PLATFORM_ANDROID_JAR "${SDL_ANDROID_PLATFORM_ROOT}/android.jar") | ||
115 | endif() | ||
116 | unset(_valid) | ||
117 | endif() | ||
118 | |||
119 | include(FindPackageHandleStandardArgs) | ||
120 | |||
121 | find_package_handle_standard_args(SdlAndroidPlatform | ||
122 | VERSION_VAR SDL_ANDROID_PLATFORM_VERSION | ||
123 | REQUIRED_VARS SDL_ANDROID_PLATFORM_ROOT SDL_ANDROID_PLATFORM_ANDROID_JAR | ||
124 | ) | ||