SDL: release: sync scripts with main branch

From 024221d448d8e9b6f50cf1d97249008b55c0e344 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 3 Nov 2025 00:11:55 +0100
Subject: [PATCH] release: sync scripts with main branch

[ci skip]
---
 .github/workflows/release.yml                 | 54 ++++++++++++++++++-
 .../resources/CMake/SDL3Config.cmake          | 38 +++++++++----
 .../resources/CMake/SDL3ConfigVersion.cmake   | 21 ++++++--
 build-scripts/build-release.py                |  3 +-
 4 files changed, 97 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 18055d7e4946e..cc297516091e2 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -204,10 +204,22 @@ jobs:
               -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}"  \
               -DCMAKE_SYSTEM_NAME=iOS                                       \
               -DCMAKE_OSX_ARCHITECTURES="arm64"                             \
-              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                             \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                            \
               -Werror=dev                                                   \
               -B build_ios
           cmake --build build_ios --config Release --verbose
+
+          cmake -S "${{ steps.src.outputs.path }}/cmake/test"                                          \
+              -DTEST_FULL=FALSE                                                                        \
+              -DTEST_STATIC=FALSE                                                                      \
+              -DTEST_TEST=FALSE                                                                        \
+              -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64"  \
+              -DCMAKE_SYSTEM_NAME=iOS                                                                  \
+              -DCMAKE_OSX_ARCHITECTURES="arm64"                                                        \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                                                       \
+              -Werror=dev                                                                              \
+              -B build_ios2
+          cmake --build build_ios2 --config Release --verbose
       - name: 'CMake (configure + build) tvOS'
         run: |
           cmake -S "${{ steps.src.outputs.path }}/cmake/test"               \
@@ -217,10 +229,22 @@ jobs:
               -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}"  \
               -DCMAKE_SYSTEM_NAME=tvOS                                      \
               -DCMAKE_OSX_ARCHITECTURES="arm64"                             \
-              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                             \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                            \
               -Werror=dev                                                   \
               -B build_tvos
           cmake --build build_tvos --config Release --verbose
+
+          cmake -S "${{ steps.src.outputs.path }}/cmake/test"                                          \
+              -DTEST_FULL=FALSE                                                                        \
+              -DTEST_STATIC=FALSE                                                                      \
+              -DTEST_TEST=FALSE                                                                        \
+              -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64" \
+              -DCMAKE_SYSTEM_NAME=tvOS                                                                 \
+              -DCMAKE_OSX_ARCHITECTURES="arm64"                                                        \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                                                       \
+              -Werror=dev                                                                              \
+              -B build_tvos2
+          cmake --build build_tvos2 --config Release --verbose
       - name: 'CMake (configure + build) iOS simulator'
         run: |
           sysroot=$(xcodebuild -version -sdk iphonesimulator Path)
@@ -237,6 +261,19 @@ jobs:
               -Werror=dev                                                   \
               -B build_ios_simulator
           cmake --build build_ios_simulator --config Release --verbose
+
+          cmake -S "${{ steps.src.outputs.path }}/cmake/test"                                                          \
+              -DTEST_FULL=FALSE                                                                                        \
+              -DTEST_STATIC=FALSE                                                                                      \
+              -DTEST_TEST=FALSE                                                                                        \
+              -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64_x86_64-simulator" \
+              -DCMAKE_SYSTEM_NAME=iOS                                                                                  \
+              -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"                                                                 \
+              -DCMAKE_OSX_SYSROOT="${sysroot}"                                                                         \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                                                                       \
+              -Werror=dev                                                                                              \
+              -B build_ios_simulator2
+          cmake --build build_ios_simulator2 --config Release --verbose
       - name: 'CMake (configure + build) tvOS simulator'
         run: |
           sysroot=$(xcodebuild -version -sdk appletvsimulator Path)
@@ -254,6 +291,19 @@ jobs:
               -B build_tvos_simulator
           cmake --build build_tvos_simulator --config Release --verbose
 
+          cmake -S "${{ steps.src.outputs.path }}/cmake/test"                                                           \
+              -DTEST_FULL=FALSE                                                                                         \
+              -DTEST_STATIC=FALSE                                                                                       \
+              -DTEST_TEST=FALSE                                                                                         \
+              -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64_x86_64-simulator" \
+              -DCMAKE_SYSTEM_NAME=tvOS                                                                                  \
+              -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"                                                                  \
+              -DCMAKE_OSX_SYSROOT="${sysroot}"                                                                          \
+              -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0                                                                        \
+              -Werror=dev                                                                                               \
+              -B build_tvos_simulator2
+          cmake --build build_tvos_simulator2 --config Release --verbose
+
   msvc:
     needs: [src]
     runs-on: windows-2025
diff --git a/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake b/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
index 784d27dbb018c..796166535e15c 100644
--- a/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
+++ b/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
@@ -1,8 +1,9 @@
 # SDL3 CMake configuration file:
-# This file is meant to be placed in Resources/CMake of a SDL3 framework
+# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
+# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
 
 # INTERFACE_LINK_OPTIONS needs CMake 3.12
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12...4.0)
 
 include(FeatureSummary)
 set_package_properties(SDL3 PROPERTIES
@@ -31,16 +32,31 @@ endmacro()
 
 set(SDL3_FOUND TRUE)
 
-# Compute the installation prefix relative to this file.
-set(_sdl3_framework_path "${CMAKE_CURRENT_LIST_DIR}")                               # > /SDL3.framework/Resources/CMake/
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH)     # > /SDL3.framework/Versions/Current/Resources/CMake
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH)     # > /SDL3.framework/Versions/A/Resources/CMake/
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH)         # > /SDL3.framework/Versions/A/Resources/
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH)         # > /SDL3.framework/Versions/A/
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH)         # > /SDL3.framework/Versions/
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH)         # > /SDL3.framework/
-get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH)  # > /
+# Compute the installation prefix relative to this file:
+# search upwards for the .framework directory
+set(_current_path "${CMAKE_CURRENT_LIST_DIR}")
+get_filename_component(_current_path "${_current_path}" REALPATH)
+set(_sdl3_framework_path "")
 
+while(NOT _sdl3_framework_path)
+    if(IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "/SDL3\\.framework$")
+        set(_sdl3_framework_path "${_current_path}")
+        break()
+    endif()
+    get_filename_component(_next_current_path "${_current_path}" DIRECTORY)
+    if("${_current_path}" STREQUAL "${_next_current_path}")
+        break()
+    endif()
+    set(_current_path "${_next_current_path}")
+endwhile()
+unset(_current_path)
+unset(_next_current_path)
+
+if(NOT _sdl3_framework_path)
+    message(FATAL_ERROR "Could not find SDL3.framework root from ${CMAKE_CURRENT_LIST_DIR}")
+endif()
+
+get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH)
 
 # All targets are created, even when some might not be requested though COMPONENTS.
 # This is done for compatibility with CMake generated SDL3-target.cmake files.
diff --git a/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake b/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
index 74329c438b81c..77188b7f42c01 100644
--- a/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
+++ b/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
@@ -1,16 +1,26 @@
 # based on the files generated by CMake's write_basic_package_version_file
 
 # SDL CMake version configuration file:
-# This file is meant to be placed in Resources/CMake of a SDL3 framework
+# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
+# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
 
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.12...4.0)
 
-if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
-    message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory of SDL2.framework")
+# Find SDL_version.h
+set(_sdl_version_h_path "")
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
+    set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
+elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
+    set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
+endif()
+
+if(NOT _sdl_version_h_path)
+    message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory or the CMake directory of SDL3.framework.")
+    set(PACKAGE_VERSION_UNSUITABLE TRUE)
     return()
 endif()
 
-file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h" _sdl_version_h)
+file(READ "${_sdl_version_h_path}" _sdl_version_h)
 string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
@@ -24,6 +34,7 @@ else()
     return()
 endif()
 
+unset(_sdl_version_h_path)
 unset(_sdl_major_re)
 unset(_sdl_major)
 unset(_sdl_minor_re)
diff --git a/build-scripts/build-release.py b/build-scripts/build-release.py
index e25bda8c11ce0..da9e1f4874b41 100755
--- a/build-scripts/build-release.py
+++ b/build-scripts/build-release.py
@@ -1028,6 +1028,7 @@ def create_android_archives(self, android_api: int, android_home: Path, android_
                     # NDK 21e does not support -ffile-prefix-map
                     # f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
                     # f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
+                    f"-DANDROID_USE_LEGACY_TOOLCHAIN=0",
                     f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
                     f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
                     f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
@@ -1517,7 +1518,7 @@ def main(argv=None) -> int:
         if args.android_home is None or not Path(args.android_home).is_dir():
             parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
         if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
-            parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
+            parser.error("Invalid $ANDROID_NDK_HOME or --android-ndk-home: must be a directory containing the Android NDK")
         if args.android_api is None:
             with section_printer.group("Detect Android APIS"):
                 args.android_api = releaser._detect_android_api(android_home=args.android_home)