Skip to content

Commit af04b99

Browse files
committed
Make CMake path detection more robust
1 parent 51239c1 commit af04b99

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Xcode/SDL/pkg-support/resources/CMake/SDL3Config.cmake

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
44

55
# INTERFACE_LINK_OPTIONS needs CMake 3.12
6-
cmake_minimum_required(VERSION 3.12)
6+
cmake_minimum_required(VERSION 3.12...4.0)
77

88
include(FeatureSummary)
99
set_package_properties(SDL3 PROPERTIES
@@ -32,26 +32,28 @@ endmacro()
3232

3333
set(SDL3_FOUND TRUE)
3434

35-
# Compute the installation prefix relative to this file.
36-
set(_sdl3_framework_path "${CMAKE_CURRENT_LIST_DIR}")
37-
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH)
35+
# Compute the installation prefix relative to this file:
36+
# search upwards for the .framework directory
37+
set(_current_path "${CMAKE_CURRENT_LIST_DIR}")
38+
get_filename_component(_current_path "${_current_path}" REALPATH)
39+
set(_sdl3_framework_path "")
3840

39-
# Search upwards for the .framework directory
4041
set(_current_path "${_sdl3_framework_path}")
41-
set(_found_framework FALSE)
42-
foreach(i RANGE 10) # max 10 levels up
43-
if (IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "\\.framework$")
42+
while(NOT _sdl3_framework_path)
43+
if (IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "/SDL3\\.framework$")
4444
set(_sdl3_framework_path "${_current_path}")
45-
set(_found_framework TRUE)
4645
break()
4746
endif()
48-
if ("${_current_path}" STREQUAL "")
47+
get_filename_component(_next_current_path "${_current_path}" DIRECTORY)
48+
if ("${_current_path}" STREQUAL "${_next_current_path}")
4949
break()
5050
endif()
51-
get_filename_component(_current_path "${_current_path}" DIRECTORY)
51+
set(_next_current_path "${_current_path}")
5252
endforeach()
53+
set(_next_current_path)
54+
set(_next_current_path)
5355

54-
if(NOT _found_framework)
56+
if(NOT _sdl3_framework_path)
5557
message(FATAL_ERROR "Could not find SDL3.framework root from ${CMAKE_CURRENT_LIST_DIR}")
5658
endif()
5759

Xcode/SDL/pkg-support/resources/CMake/SDL3ConfigVersion.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
55
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
66

7-
cmake_minimum_required(VERSION 3.12)
7+
cmake_minimum_required(VERSION 3.12...4.0)
88

99
# Find SDL_version.h
1010
set(_sdl_version_h_path "")
@@ -16,6 +16,7 @@ endif()
1616

1717
if(NOT _sdl_version_h_path)
1818
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.")
19+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
1920
return()
2021
endif()
2122

0 commit comments

Comments
 (0)