Skip to content

Commit

Permalink
Updated to the latest SDL2 frameworks
Browse files Browse the repository at this point in the history
(cherry picked from commit 948f3be)
  • Loading branch information
slouken committed Feb 7, 2025
1 parent cf88078 commit 2f24da4
Show file tree
Hide file tree
Showing 220 changed files with 33,030 additions and 13,918 deletions.
48 changes: 48 additions & 0 deletions Xcode/iOS/SDL2.framework/CMake/sdl2-config-version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# based on the files generated by CMake's write_basic_package_version_file

# SDL2 CMake version configuration file:
# This file is meant to be placed in Resources/CMake of a SDL2 framework

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")
return()
endif()

file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h" _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}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_version_h}")
set(_sdl_patch "${CMAKE_MATCH_1}")
if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
else()
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
return()
endif()

if(PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()

# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
78 changes: 78 additions & 0 deletions Xcode/iOS/SDL2.framework/CMake/sdl2-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SDL2 CMake configuration file:
# This file is meant to be placed in Resources/CMake of a SDL2 framework

# INTERFACE_LINK_OPTIONS needs CMake 3.12
cmake_minimum_required(VERSION 3.12)

include(FeatureSummary)
set_package_properties(SDL2 PROPERTIES
URL "https://www.libsdl.org/"
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
)

# Copied from `configure_package_config_file`
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()

# Copied from `configure_package_config_file`
macro(check_required_components _NAME)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(NOT ${_NAME}_${comp}_FOUND)
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()

set(SDL2_FOUND TRUE)

# Compute the installation prefix relative to this file.
set(SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") # > /SDL2.framework/Resources/CMake/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/Current/Resources/CMake
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/A/Resources/CMake/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/Resources/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/
get_filename_component(SDL2_FRAMEWORK_PARENT_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /

# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.

set_and_check(SDL2_PREFIX "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_EXEC_PREFIX "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_INCLUDE_DIR "${SDL2_FRAMEWORK_PATH}/Headers")
set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR};${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_BINDIR "${SDL2_FRAMEWORK_PATH}")
set_and_check(SDL2_LIBDIR "${SDL2_FRAMEWORK_PATH}")

set(SDL2_LIBRARIES "SDL2::SDL2")

# All targets are created, even when some might not be requested though COMPONENTS.
# This is done for compatibility with CMake generated SDL2-target.cmake files.

if(NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2
PROPERTIES
FRAMEWORK "TRUE"
IMPORTED_LOCATION "${SDL2_FRAMEWORK_PATH}/Versions/A/SDL2"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
INTERFACE_SDL2_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL2"
)
endif()
set(SDL2_SDL2_FOUND TRUE)

if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main INTERFACE IMPORTED)
endif()
set(SDL2_SDL2main_FOUND TRUE)

check_required_components(SDL2)
8 changes: 5 additions & 3 deletions Xcode/iOS/SDL2.framework/Headers/SDL.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand All @@ -25,7 +25,6 @@
* Main include header for the SDL library
*/


#ifndef SDL_h_
#define SDL_h_

Expand All @@ -41,6 +40,7 @@
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_filesystem.h>
#include <SDL2/SDL_gamecontroller.h>
#include <SDL2/SDL_guid.h>
#include <SDL2/SDL_haptic.h>
#include <SDL2/SDL_hidapi.h>
#include <SDL2/SDL_hints.h>
Expand Down Expand Up @@ -69,6 +69,8 @@
extern "C" {
#endif

/* WIKI CATEGORY: Init */

/* As of version 0.5, SDL is loaded dynamically into the application */

/**
Expand Down Expand Up @@ -129,7 +131,7 @@ extern "C" {
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
* this call will increase the ref-count and return.
*
* \param flags subsystem initialization flags
* \param flags subsystem initialization flags.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
Expand Down
34 changes: 17 additions & 17 deletions Xcode/iOS/SDL2.framework/Headers/SDL_assert.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand All @@ -22,7 +22,7 @@
#ifndef SDL_assert_h_
#define SDL_assert_h_

#include <SDL2/SDL_config.h>
#include <SDL2/SDL_stdinc.h>

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

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__
#else
# define SDL_FUNCTION "???"
Expand Down Expand Up @@ -123,12 +129,10 @@ typedef struct SDL_AssertData
const struct SDL_AssertData *next;
} SDL_AssertData;

#if (SDL_ASSERT_LEVEL > 0)

/* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *,
const char *, int)
const char *,
const char *, int)
#if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function,
Expand All @@ -149,9 +153,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
#define SDL_enabled_assert(condition) \
do { \
while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \
0, 0, #condition, 0, 0, 0, 0 \
}; \
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \
Expand All @@ -162,8 +164,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
} \
} while (SDL_NULL_WHILE_LOOP_CONDITION)

#endif /* enabled assertions support code */

/* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition)
Expand Down Expand Up @@ -193,8 +193,8 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
* A callback that fires when an SDL assertion fails.
*
* \param data a pointer to the SDL_AssertData structure corresponding to the
* current assertion
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler()
* current assertion.
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler().
* \returns an SDL_AssertState value indicating how to handle the failure.
*/
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
Expand All @@ -214,8 +214,8 @@ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
*
* \param handler the SDL_AssertionHandler function to call when an assertion
* fails or NULL for the default handler
* \param userdata a pointer that is passed to `handler`
* fails or NULL for the default handler.
* \param userdata a pointer that is passed to `handler`.
*
* \since This function is available since SDL 2.0.0.
*
Expand Down Expand Up @@ -256,7 +256,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void
* data, it is safe to pass a NULL pointer to this function to ignore it.
*
* \param puserdata pointer which is filled with the "userdata" pointer that
* was passed to SDL_SetAssertionHandler()
* was passed to SDL_SetAssertionHandler().
* \returns the SDL_AssertionHandler that is called when an assert triggers.
*
* \since This function is available since SDL 2.0.2.
Expand Down
Loading

0 comments on commit 2f24da4

Please sign in to comment.