Skip to content

Commit acbb9fc

Browse files
committed
Updated to the latest SDL2 frameworks
(cherry picked from commit 8e22c06)
1 parent 01c98d6 commit acbb9fc

File tree

220 files changed

+33030
-13918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+33030
-13918
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# based on the files generated by CMake's write_basic_package_version_file
2+
3+
# SDL2 CMake version configuration file:
4+
# This file is meant to be placed in Resources/CMake of a SDL2 framework
5+
6+
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
7+
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory of SDL2.framework")
8+
return()
9+
endif()
10+
11+
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h" _sdl_version_h)
12+
string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
13+
set(_sdl_major "${CMAKE_MATCH_1}")
14+
string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
15+
set(_sdl_minor "${CMAKE_MATCH_1}")
16+
string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}")
17+
set(_sdl_patch "${CMAKE_MATCH_1}")
18+
if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
19+
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
20+
else()
21+
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
22+
return()
23+
endif()
24+
25+
if(PACKAGE_FIND_VERSION_RANGE)
26+
# Package version must be in the requested version range
27+
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
28+
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
29+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
30+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
31+
else()
32+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
33+
endif()
34+
else()
35+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
36+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
37+
else()
38+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
39+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
40+
set(PACKAGE_VERSION_EXACT TRUE)
41+
endif()
42+
endif()
43+
endif()
44+
45+
# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
46+
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
47+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
48+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# SDL2 CMake configuration file:
2+
# This file is meant to be placed in Resources/CMake of a SDL2 framework
3+
4+
# INTERFACE_LINK_OPTIONS needs CMake 3.12
5+
cmake_minimum_required(VERSION 3.12)
6+
7+
include(FeatureSummary)
8+
set_package_properties(SDL2 PROPERTIES
9+
URL "https://www.libsdl.org/"
10+
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
11+
)
12+
13+
# Copied from `configure_package_config_file`
14+
macro(set_and_check _var _file)
15+
set(${_var} "${_file}")
16+
if(NOT EXISTS "${_file}")
17+
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
18+
endif()
19+
endmacro()
20+
21+
# Copied from `configure_package_config_file`
22+
macro(check_required_components _NAME)
23+
foreach(comp ${${_NAME}_FIND_COMPONENTS})
24+
if(NOT ${_NAME}_${comp}_FOUND)
25+
if(${_NAME}_FIND_REQUIRED_${comp})
26+
set(${_NAME}_FOUND FALSE)
27+
endif()
28+
endif()
29+
endforeach()
30+
endmacro()
31+
32+
set(SDL2_FOUND TRUE)
33+
34+
# Compute the installation prefix relative to this file.
35+
set(SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") # > /SDL2.framework/Resources/CMake/
36+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/Current/Resources/CMake
37+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/A/Resources/CMake/
38+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/Resources/
39+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/
40+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/
41+
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/
42+
get_filename_component(SDL2_FRAMEWORK_PARENT_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /
43+
44+
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
45+
46+
set_and_check(SDL2_PREFIX "${SDL2_FRAMEWORK_PATH}")
47+
set_and_check(SDL2_EXEC_PREFIX "${SDL2_FRAMEWORK_PATH}")
48+
set_and_check(SDL2_INCLUDE_DIR "${SDL2_FRAMEWORK_PATH}/Headers")
49+
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR};${SDL2_FRAMEWORK_PATH}")
50+
set_and_check(SDL2_BINDIR "${SDL2_FRAMEWORK_PATH}")
51+
set_and_check(SDL2_LIBDIR "${SDL2_FRAMEWORK_PATH}")
52+
53+
set(SDL2_LIBRARIES "SDL2::SDL2")
54+
55+
# All targets are created, even when some might not be requested though COMPONENTS.
56+
# This is done for compatibility with CMake generated SDL2-target.cmake files.
57+
58+
if(NOT TARGET SDL2::SDL2)
59+
add_library(SDL2::SDL2 SHARED IMPORTED)
60+
set_target_properties(SDL2::SDL2
61+
PROPERTIES
62+
FRAMEWORK "TRUE"
63+
IMPORTED_LOCATION "${SDL2_FRAMEWORK_PATH}/Versions/A/SDL2"
64+
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
65+
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
66+
INTERFACE_SDL2_SHARED "ON"
67+
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
68+
INTERFACE_SDL_VERSION "SDL2"
69+
)
70+
endif()
71+
set(SDL2_SDL2_FOUND TRUE)
72+
73+
if(NOT TARGET SDL2::SDL2main)
74+
add_library(SDL2::SDL2main INTERFACE IMPORTED)
75+
endif()
76+
set(SDL2_SDL2main_FOUND TRUE)
77+
78+
check_required_components(SDL2)

Xcode/iOS/SDL2.framework/Headers/SDL.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages
@@ -25,7 +25,6 @@
2525
* Main include header for the SDL library
2626
*/
2727

28-
2928
#ifndef SDL_h_
3029
#define SDL_h_
3130

@@ -41,6 +40,7 @@
4140
#include <SDL2/SDL_events.h>
4241
#include <SDL2/SDL_filesystem.h>
4342
#include <SDL2/SDL_gamecontroller.h>
43+
#include <SDL2/SDL_guid.h>
4444
#include <SDL2/SDL_haptic.h>
4545
#include <SDL2/SDL_hidapi.h>
4646
#include <SDL2/SDL_hints.h>
@@ -69,6 +69,8 @@
6969
extern "C" {
7070
#endif
7171

72+
/* WIKI CATEGORY: Init */
73+
7274
/* As of version 0.5, SDL is loaded dynamically into the application */
7375

7476
/**
@@ -129,7 +131,7 @@ extern "C" {
129131
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
130132
* this call will increase the ref-count and return.
131133
*
132-
* \param flags subsystem initialization flags
134+
* \param flags subsystem initialization flags.
133135
* \returns 0 on success or a negative error code on failure; call
134136
* SDL_GetError() for more information.
135137
*

Xcode/iOS/SDL2.framework/Headers/SDL_assert.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages
@@ -22,7 +22,7 @@
2222
#ifndef SDL_assert_h_
2323
#define SDL_assert_h_
2424

25-
#include <SDL2/SDL_config.h>
25+
#include <SDL2/SDL_stdinc.h>
2626

2727
#include <SDL2/begin_code.h>
2828
/* Set up for C function definitions, even when using C++ */
@@ -51,12 +51,18 @@ assert can have unique static variables associated with it.
5151
/* Don't include intrin.h here because it contains C++ code */
5252
extern void __cdecl __debugbreak(void);
5353
#define SDL_TriggerBreakpoint() __debugbreak()
54+
#elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
55+
#define SDL_TriggerBreakpoint() __builtin_debugtrap()
5456
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
5557
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
58+
#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
59+
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
5660
#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
5761
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
5862
#elif defined(__APPLE__) && defined(__arm__)
5963
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
64+
#elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) )
65+
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" )
6066
#elif defined(__386__) && defined(__WATCOMC__)
6167
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
6268
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
@@ -69,7 +75,7 @@ assert can have unique static variables associated with it.
6975

7076
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
7177
# define SDL_FUNCTION __func__
72-
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
78+
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
7379
# define SDL_FUNCTION __FUNCTION__
7480
#else
7581
# define SDL_FUNCTION "???"
@@ -123,12 +129,10 @@ typedef struct SDL_AssertData
123129
const struct SDL_AssertData *next;
124130
} SDL_AssertData;
125131

126-
#if (SDL_ASSERT_LEVEL > 0)
127-
128132
/* Never call this directly. Use the SDL_assert* macros. */
129133
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
130-
const char *,
131-
const char *, int)
134+
const char *,
135+
const char *, int)
132136
#if defined(__clang__)
133137
#if __has_feature(attribute_analyzer_noreturn)
134138
/* this tells Clang's static analysis that we're a custom assert function,
@@ -149,9 +153,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
149153
#define SDL_enabled_assert(condition) \
150154
do { \
151155
while ( !(condition) ) { \
152-
static struct SDL_AssertData sdl_assert_data = { \
153-
0, 0, #condition, 0, 0, 0, 0 \
154-
}; \
156+
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
155157
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
156158
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
157159
continue; /* go again. */ \
@@ -162,8 +164,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
162164
} \
163165
} while (SDL_NULL_WHILE_LOOP_CONDITION)
164166

165-
#endif /* enabled assertions support code */
166-
167167
/* Enable various levels of assertions. */
168168
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
169169
# define SDL_assert(condition) SDL_disabled_assert(condition)
@@ -193,8 +193,8 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
193193
* A callback that fires when an SDL assertion fails.
194194
*
195195
* \param data a pointer to the SDL_AssertData structure corresponding to the
196-
* current assertion
197-
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler()
196+
* current assertion.
197+
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler().
198198
* \returns an SDL_AssertState value indicating how to handle the failure.
199199
*/
200200
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
@@ -214,8 +214,8 @@ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
214214
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
215215
*
216216
* \param handler the SDL_AssertionHandler function to call when an assertion
217-
* fails or NULL for the default handler
218-
* \param userdata a pointer that is passed to `handler`
217+
* fails or NULL for the default handler.
218+
* \param userdata a pointer that is passed to `handler`.
219219
*
220220
* \since This function is available since SDL 2.0.0.
221221
*
@@ -256,7 +256,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void
256256
* data, it is safe to pass a NULL pointer to this function to ignore it.
257257
*
258258
* \param puserdata pointer which is filled with the "userdata" pointer that
259-
* was passed to SDL_SetAssertionHandler()
259+
* was passed to SDL_SetAssertionHandler().
260260
* \returns the SDL_AssertionHandler that is called when an assert triggers.
261261
*
262262
* \since This function is available since SDL 2.0.2.

0 commit comments

Comments
 (0)