-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Make SDL3.framework path detection more robust by searching upwards #14259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
is meant to be put in a very specific location during package creation.
I don't know what this fixes. Can you please provide a reproducer for the error?
Of course! I confirm the official release (https://github.com/libsdl-org/SDL/releases/download/release-3.2.24/SDL3-3.2.24.dmg) has the same issue. In the
I'm getting the same issue when I build the XCFramework directly from the main branch. xcodebuild -project Xcode/SDL/SDL.xcodeproj -target "SDL3.xcframework" -configuration Release SYMROOT="build/" |
https://github.com/mpaghq/fluidsynth/actions/runs/18559446061/job/52918890912 This is a project I'm using SDL. As seen in the 'build' step logs, finding the header fails due to CMake configuration. |
Thanks! I can reproduce your error (on ci, I don't own Apple hw).
So the first error actually happens in (While you're at it, can you also fix the error message? |
@madebr Thanks for the reply! |
Thanks to the power of GitHub, you can run these on your fork! Assuming you have python3 build-scripts/create-release.py -R mpaghq/SDL --ref main |
Oh cool thanks! It runs fine :) https://github.com/mpaghq/SDL/actions/runs/18582543141/job/52980355332 |
Looks good! diff --git a/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake b/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
index d63c926ae..87df5a2bb 100644
--- a/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
+++ b/Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake
@@ -3,7 +3,7 @@
# 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
@@ -32,26 +32,28 @@ endmacro()
set(SDL3_FOUND TRUE)
-# Compute the installation prefix relative to this file.
-set(_sdl3_framework_path "${CMAKE_CURRENT_LIST_DIR}")
-get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH)
+# 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 "")
-# Search upwards for the .framework directory
set(_current_path "${_sdl3_framework_path}")
-set(_found_framework FALSE)
-foreach(i RANGE 10) # max 10 levels up
- if (IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "\\.framework$")
+while(NOT _sdl3_framework_path)
+ if (IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "/SDL3\\.framework$")
set(_sdl3_framework_path "${_current_path}")
- set(_found_framework TRUE)
break()
endif()
- if ("${_current_path}" STREQUAL "")
+ get_filename_component(_next_current_path "${_current_path}" DIRECTORY)
+ if ("${_current_path}" STREQUAL "${_next_current_path}")
break()
endif()
- get_filename_component(_current_path "${_current_path}" DIRECTORY)
+ set(_next_current_path "${_current_path}")
endforeach()
+set(_next_current_path)
+set(_next_current_path)
-if(NOT _found_framework)
+if(NOT _sdl3_framework_path)
message(FATAL_ERROR "Could not find SDL3.framework root from ${CMAKE_CURRENT_LIST_DIR}")
endif()
diff --git a/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake b/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
index ad331216f..80a127872 100644
--- a/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
+++ b/Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake
@@ -4,7 +4,7 @@
# 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)
# Find SDL_version.h
set(_sdl_version_h_path "")
@@ -16,6 +16,7 @@ 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()
|
@madebr Thanks a lot! I've made the changes as yours :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some styling nits, but ok to merge!
(I cannot commit on your branch, otherwise I would've applied these myself)
Co-authored-by: Anonymous Maarten <[email protected]>
Co-authored-by: Anonymous Maarten <[email protected]>
Thanks!! I've applied the patch :) |
Merged, thanks! |
Thanks a lot!! Have a good day :-) |
Description
Replaces the hardcoded path traversal for finding the SDL3 framework root with a flexible upward search loop.
The hardcoded path traversal of 4 levels is not suitable for iOS frameworks(
SDL3.framework/CMake/SDL3Config.cmake
).The new method is more robust and less likely to break.
Existing Issue(s)
Hopefully #14121