Merge commit '8821e99ab51434f24f3e64dd7ec4cfeeb761a018' as 'external/SDL'

This commit is contained in:
SimoneN64
2024-09-04 22:32:48 +02:00
1913 changed files with 947421 additions and 0 deletions

116
external/SDL/cmake/3rdparty.cmake vendored Normal file
View File

@@ -0,0 +1,116 @@
function(get_clang_tidy_ignored_files OUTVAR)
set(3RD_PARTY_SOURCES
# Public GL headers
"SDL_egl.h"
"SDL_hidapi.h"
"SDL_opengl.h"
"SDL_opengl_glext.h"
"SDL_opengles2_gl2.h"
"SDL_opengles2_gl2ext.h"
"SDL_opengles2_gl2platform.h"
"SDL_opengles2_khrplatform.h"
# stdlib
"SDL_malloc.c"
"SDL_qsort.c"
"SDL_strtokr.c"
# edid
"edid-parse.c"
"edid.h"
# imKStoUCS
"imKStoUCS.c"
"imKStoUCS.h"
# Joystick controller type
"controller_type.h"
"controller_type.c"
# HIDAPI Steam controller
"controller_constants.h"
"controller_structs.h"
# YUV2RGB
"yuv_rgb.c"
"yuv_rgb_lsx_func.h"
"yuv_rgb_sse_func.h"
"yuv_rgb_std_func.h"
# LIBM
"e_atan2.c"
"e_exp.c"
"e_fmod.c"
"e_log10.c"
"e_log.c"
"e_pow.c"
"e_rem_pio2.c"
"e_sqrt.c"
"k_cos.c"
"k_rem_pio2.c"
"k_sin.c"
"k_tan.c"
"s_atan.c"
"s_copysign.c"
"s_cos.c"
"s_fabs.c"
"s_floor.c"
"s_scalbn.c"
"s_sin.c"
"s_tan.c"
"math_private.h"
"math_libm.h"
# EGL
"egl.h"
"eglext.h"
"eglplatform.h"
# GLES2
"gl2.h"
"gl2ext.h"
"gl2platform.h"
# KHR
"khrplatform.h"
# Vulkan
"vk_icd.h"
"vk_layer.h"
"vk_platform.h"
"vk_sdk_platform.h"
"vulkan_android.h"
"vulkan_beta.h"
"vulkan_core.h"
"vulkan_directfb.h"
"vulkan_fuchsia.h"
"vulkan_ggp.h"
"vulkan_ios.h"
"vulkan_macos.h"
"vulkan_metal.h"
"vulkan_screen.h"
"vulkan_vi.h"
"vulkan_wayland.h"
"vulkan_win32.h"
"vulkan_xcb.h"
"vulkan_xlib_xrandr.h"
"vulkan_xlib.h"
"vulkan.h"
"vulkan_enums.hpp"
"vulkan_format_traits.hpp"
"vulkan_funcs.hpp"
"vulkan_handles.hpp"
"vulkan_hash.hpp"
"vulkan_raii.hpp"
"vulkan_static_assertions.hpp"
"vulkan_structs.hpp"
"vulkan_to_string.hpp"
# HIDAPI
"hid.c"
"hid.cpp"
"hid.m"
"hidraw.cpp"
"hidusb.cpp"
"hidapi.h"
# XSETTINGS
"xsettings-client.c"
"xsettings-client.h")
foreach(SOURCE_FILE ${3RD_PARTY_SOURCES})
list(APPEND IGNORED_LIST "{\"name\":\"${SOURCE_FILE}\",\"lines\":[[1,1]]}")
endforeach()
string(REPLACE ";" "," IGNORED_FILES "${IGNORED_LIST}")
set(${OUTVAR}
"${IGNORED_FILES}"
PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,36 @@
if(CPACK_PACKAGE_FILE_NAME MATCHES ".*-src$")
message(FATAL_ERROR "Creating source archives for SDL @PROJECT_VERSION@ is not supported.")
endif()
set(PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
set(SDL_CMAKE_PLATFORM "@SDL_CMAKE_PLATFORM@")
set(SDL_CPU_NAMES "@SDL_CPU_NAMES@")
list(SORT SDL_CPU_NAMES)
string(REPLACE ";" "-" SDL_CPU_NAMES_WITH_DASHES "${SDL_CPU_NAMES}")
if(SDL_CPU_NAMES_WITH_DASHES)
set(SDL_CPU_NAMES_WITH_DASHES "-${SDL_CPU_NAMES_WITH_DASHES}")
endif()
string(TOLOWER "${SDL_CMAKE_PLATFORM}" lower_sdl_cmake_platform)
string(TOLOWER "${SDL_CPU_NAMES}" lower_sdl_cpu_names)
if(lower_sdl_cmake_platform STREQUAL lower_sdl_cpu_names)
set(SDL_CPU_NAMES_WITH_DASHES)
endif()
set(MSVC @MSVC@)
set(MINGW @MINGW@)
if(MSVC)
set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-VC")
elseif(MINGW)
set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-mingw")
endif()
set(CPACK_PACKAGE_FILE_NAME "SDL@PROJECT_VERSION_MAJOR@-@PROJECT_VERSION@-${SDL_CMAKE_PLATFORM}${SDL_CPU_NAMES_WITH_DASHES}")
if(CPACK_GENERATOR STREQUAL "DragNDrop")
set(CPACK_DMG_VOLUME_NAME "SDL@PROJECT_VERSION_MAJOR@ @PROJECT_VERSION@")
# FIXME: use pre-built/create .DS_Store through AppleScript (CPACK_DMG_DS_STORE/CPACK_DMG_DS_STORE_SETUP_SCRIPT)
set(CPACK_DMG_DS_STORE "${PROJECT_SOURCE_DIR}/Xcode/SDL/pkg-support/resources/SDL_DS_Store")
endif()

138
external/SDL/cmake/FindFFmpeg.cmake vendored Normal file
View File

@@ -0,0 +1,138 @@
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
#
# Once done this will define
# FFMPEG_FOUND - System has the all required components.
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
#
# For each of the components it will additionally set.
# - AVCODEC
# - AVDEVICE
# - AVFORMAT
# - AVFILTER
# - AVUTIL
# - POSTPROC
# - SWSCALE
# the following target will be defined
# FFmpeg::SDL::<component> - link to this target to
# the following variables will be defined
# FFmpeg_<component>_FOUND - System has <component>
# FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
# FFmpeg_<component>_LIBRARIES - Link these to use <component>
# FFmpeg_<component>_DEFINITIONS - Compiler switches required for using <component>
# FFmpeg_<component>_VERSION - The components version
#
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
# Copyright (c) 2023, Sam lantinga, <slouken@libsdl.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(FindPackageHandleStandardArgs)
include("${CMAKE_CURRENT_LIST_DIR}/PkgConfigHelper.cmake")
# The default components were taken from a survey over other FindFFMPEG.cmake files
if(NOT FFmpeg_FIND_COMPONENTS)
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
set(FFmpeg_FIND_REQUIRED_${_component} TRUE)
endforeach()
endif()
find_package(PkgConfig QUIET)
#
### Macro: find_component
#
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
# include directories.
#
macro(find_component _component _pkgconfig _library _header)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_${_component} QUIET ${_pkgconfig})
endif()
find_path(FFmpeg_${_component}_INCLUDE_DIRS
NAMES ${_header}
HINTS
${PC_${_component}_INCLUDE_DIRS}
PATH_SUFFIXES
ffmpeg
)
find_library(FFmpeg_${_component}_LIBRARY
NAMES ${_library}
HINTS
${PC_${_component}_LIBRARY_DIRS}
)
if(FFmpeg_${_component}_INCLUDE_DIRS AND FFmpeg_${_component}_LIBRARY)
set(FFmpeg_${_component}_FOUND TRUE)
endif()
if(PC_${_component}_FOUND)
get_flags_from_pkg_config("${FFmpeg_${_component}_LIBRARY}" "PC_${_component}" "${_component}")
endif()
set(FFmpeg_${_component}_VERSION "${PC_${_component}_VERSION}")
set(FFmpeg_${_component}_COMPILE_OPTIONS "${${_component}_options}" CACHE STRING "Extra compile options of FFmpeg ${_component}")
set(FFmpeg_${_component}_LIBRARIES "${${_component}_link_libraries}" CACHE STRING "Extra link libraries of FFmpeg ${_component}")
set(FFmpeg_${_component}_LINK_OPTIONS "${${_component}_link_options}" CACHE STRING "Extra link flags of FFmpeg ${_component}")
set(FFmpeg_${_component}_LINK_DIRECTORIES "${${_component}_link_directories}" CACHE PATH "Extra link directories of FFmpeg ${_component}")
mark_as_advanced(
FFmpeg_${_component}_INCLUDE_DIRS
FFmpeg_${_component}_LIBRARY
FFmpeg_${_component}_COMPILE_OPTIONS
FFmpeg_${_component}_LIBRARIES
FFmpeg_${_component}_LINK_OPTIONS
FFmpeg_${_component}_LINK_DIRECTORIES
)
endmacro()
# Check for all possible component.
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
# Compile the list of required vars
set(_FFmpeg_REQUIRED_VARS)
foreach(_component ${FFmpeg_FIND_COMPONENTS})
list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_${_component}_INCLUDE_DIRS FFmpeg_${_component}_LIBRARY)
endforeach ()
# Give a nice error message if some of the required vars are missing.
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
set(FFMPEG_LIBRARIES)
if(FFmpeg_FOUND)
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
if(FFmpeg_${_component}_FOUND)
list(APPEND FFMPEG_LIBRARIES FFmpeg::SDL::${_component})
if(NOT TARGET FFmpeg::SDL::${_component})
add_library(FFmpeg::SDL::${_component} UNKNOWN IMPORTED)
set_target_properties(FFmpeg::SDL::${_component} PROPERTIES
IMPORTED_LOCATION "${FFmpeg_${_component}_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_${_component}_INCLUDE_DIRS}"
INTERFACE_COMPILE_OPTIONS "${FFmpeg_${_component}_COMPILE_OPTIONS}"
INTERFACE_LINK_LIBRARIES "${FFmpeg_${_component}_LIBRARIES}"
INTERFACE_LINK_OPTIONS "${FFmpeg_${_component}_LINK_OPTIONS}"
INTERFACE_LINK_DIRECTORIES "${FFmpeg_${_component}_LINK_DIRECTORIES}"
)
endif()
endif()
endforeach()
endif()

73
external/SDL/cmake/FindLibUSB.cmake vendored Normal file
View File

@@ -0,0 +1,73 @@
include(FindPackageHandleStandardArgs)
set(LibUSB_PKG_CONFIG_SPEC libusb-1.0>=1.0.16)
set(LibUSB_MIN_API_VERSION 0x01000102)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LibUSB ${LibUSB_PKG_CONFIG_SPEC})
endif()
find_library(LibUSB_LIBRARY
NAMES usb-1.0 libusb-1.0
HINTS ${PC_LibUSB_LIBRARY_DIRS}
)
find_path(LibUSB_INCLUDE_PATH
NAMES libusb.h
PATH_SUFFIXES libusb-1.0
HINTS ${PC_LibUSB_INCLUDE_DIRS}
)
set(LibUSB_API_VERSION "LibUSB_API_VERSION-NOTFOUND")
if(LibUSB_INCLUDE_PATH AND EXISTS "${LibUSB_INCLUDE_PATH}/libusb.h")
file(READ "${LibUSB_INCLUDE_PATH}/libusb.h" LIBUSB_H_TEXT)
if("${LIBUSB_H_TEXT}" MATCHES "#define[ \t]+LIBUSBX?_API_VERSION[ \t]+(0x[0-9a-fA-F]+)" )
set(LibUSB_API_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
if(LibUSB_API_VERSION)
math(EXPR LibUSB_MIN_API_VERSION_decimal "${LibUSB_MIN_API_VERSION}")
math(EXPR LibUSB_API_VERSION_decimal "${LibUSB_API_VERSION}")
if(NOT LibUSB_MIN_API_VERSION_decimal LESS_EQUAL LibUSB_API_VERSION_decimal)
set(LibUSB_LIBRARY "LibUSB_LIBRARY-NOTFOUND")
endif()
else()
set(LibUSB_LIBRARY "LibUSB_LIBRARY-NOTFOUND")
endif()
set(LibUSB_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of LibUSB")
set(LibUSB_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of LibUSB")
set(LibUSB_LINK_FLAGS "" CACHE STRING "Extra link flags of LibUSB")
if(LibUSB_LIBRARY AND LibUSB_INCLUDE_PATH)
if(PC_LibUSB_FOUND)
set(LibUSB_VERSION "${PC_LibUSB_VERSION}")
else()
set(LibUSB_VERSION "1.0.16-or-higher")
endif()
else()
set(LibUSB_VERSION "LibUSB_VERSION-NOTFOUND")
endif()
find_package_handle_standard_args(LibUSB
VERSION_VAR LibUSB_VERSION
REQUIRED_VARS LibUSB_LIBRARY LibUSB_INCLUDE_PATH
)
if(LibUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
add_library(LibUSB::LibUSB IMPORTED UNKNOWN)
set_target_properties(LibUSB::LibUSB
PROPERTIES
IMPORTED_LOCATION "${LibUSB_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LibUSB_INCLUDE_PATH}"
INTERFACE_COMPILE_OPTIONS "${LibUSB_COMPILE_OPTIONS}"
INTERFACE_LINK_LIBRARIES "${LibUSB_LINK_LIBRARIES}"
INTERFACE_LINK_OPTIONS "${LibUSB_LINK_OPTIONS}"
)
endif()

View File

@@ -0,0 +1,284 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_describe_working_tree(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the working tree (--dirty option),
# and adjusting the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# git_local_changes(<var>)
#
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
# Uses the return code of "git diff-index --quiet HEAD --".
# Does not regard untracked files.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
# http://academic.cleardefinition.com
#
# Copyright 2009-2013, Iowa State University.
# Copyright 2013-2020, Ryan Pavlik
# Copyright 2013-2020, Contributors
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
# Function _git_find_closest_git_dir finds the next closest .git directory
# that is part of any directory in the path defined by _start_dir.
# The result is returned in the parent scope variable whose name is passed
# as variable _git_dir_var. If no .git directory can be found, the
# function returns an empty string via _git_dir_var.
#
# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
# neither foo nor bar contain a file/directory .git. This will return
# C:/bla/.git
#
function(_git_find_closest_git_dir _start_dir _git_dir_var)
set(cur_dir "${_start_dir}")
set(git_dir "${_start_dir}/.git")
while(NOT EXISTS "${git_dir}")
# .git dir not found, search parent directories
set(git_previous_parent "${cur_dir}")
get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
if(cur_dir STREQUAL git_previous_parent)
# We have reached the root directory, we are not in git
set(${_git_dir_var}
""
PARENT_SCOPE)
return()
endif()
set(git_dir "${cur_dir}/.git")
endwhile()
set(${_git_dir_var}
"${git_dir}"
PARENT_SCOPE)
endfunction()
function(get_git_head_revision _refspecvar _hashvar)
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
else()
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
endif()
if(NOT "${GIT_DIR}" STREQUAL "")
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
"${GIT_DIR}")
if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
# We've gone above the CMake root dir.
set(GIT_DIR "")
endif()
endif()
if("${GIT_DIR}" STREQUAL "")
set(${_refspecvar}
"GITDIR-NOTFOUND"
PARENT_SCOPE)
set(${_hashvar}
"GITDIR-NOTFOUND"
PARENT_SCOPE)
return()
endif()
# Check if the current source dir is a git submodule or a worktree.
# In both cases .git is a file instead of a directory.
#
if(NOT IS_DIRECTORY ${GIT_DIR})
# The following git command will return a non empty string that
# points to the super project working tree if the current
# source dir is inside a git submodule.
# Otherwise the command will return an empty string.
#
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse
--show-superproject-working-tree
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT "${out}" STREQUAL "")
# If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
${submodule})
string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
ABSOLUTE)
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
else()
# GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree
file(READ ${GIT_DIR} worktree_ref)
# The .git directory contains a path to the worktree information directory
# inside the parent git repo of the worktree.
#
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
${worktree_ref})
string(STRIP ${git_worktree_dir} git_worktree_dir)
_git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
endif()
else()
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${HEAD_SOURCE_FILE}")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake" @ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar}
"${HEAD_REF}"
PARENT_SCOPE)
set(${_hashvar}
"${HEAD_HASH}"
PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_describe_working_tree _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var}
"${out}"
PARENT_SCOPE)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
set(${_var}
"CLEAN"
PARENT_SCOPE)
else()
set(${_var}
"DIRTY"
PARENT_SCOPE)
endif()
endfunction()

View File

@@ -0,0 +1,43 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2009-2012, Iowa State University
# Copyright 2011-2015, Contributors
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# SPDX-License-Identifier: BSL-1.0
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@@ -0,0 +1,34 @@
# Helper for Find modules
function(get_flags_from_pkg_config _library _pc_prefix _out_prefix)
if("${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$")
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
else()
set(_cflags ${_pc_prefix}_CFLAGS_OTHER)
set(_link_libraries ${_pc_prefix}_LIBRARIES)
set(_link_options ${_pc_prefix}_LDFLAGS_OTHER)
set(_library_dirs ${_pc_prefix}_LIBRARY_DIRS)
endif()
# The *_LIBRARIES lists always start with the library itself
list(POP_FRONT "${_link_libraries}")
# Work around CMake's flag deduplication when pc files use `-framework A` instead of `-Wl,-framework,A`
string(REPLACE "-framework;" "-Wl,-framework," "_filtered_link_options" "${${_link_options}}")
set(${_out_prefix}_compile_options
"${${_cflags}}"
PARENT_SCOPE)
set(${_out_prefix}_link_libraries
"${${_link_libraries}}"
PARENT_SCOPE)
set(${_out_prefix}_link_options
"${_filtered_link_options}"
PARENT_SCOPE)
set(${_out_prefix}_link_directories
"${${_library_dirs}}"
PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,177 @@
if(EMSCRIPTEN)
function(SDL_Preseed_CMakeCache)
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "1" CACHE INTERNAL "Have include alloca.h")
set(HAVE_LIBM "1" CACHE INTERNAL "Have library m")
set(HAVE_MALLOC "1" CACHE INTERNAL "Have include malloc.h")
set(LIBC_HAS_ABS "1" CACHE INTERNAL "Have symbol abs")
set(LIBC_HAS_ACOS "1" CACHE INTERNAL "Have symbol acos")
set(LIBC_HAS_ACOSF "1" CACHE INTERNAL "Have symbol acosf")
set(LIBC_HAS_ASIN "1" CACHE INTERNAL "Have symbol asin")
set(LIBC_HAS_ASINF "1" CACHE INTERNAL "Have symbol asinf")
set(LIBC_HAS_ATAN "1" CACHE INTERNAL "Have symbol atan")
set(LIBC_HAS_ATAN2 "1" CACHE INTERNAL "Have symbol atan2")
set(LIBC_HAS_ATAN2F "1" CACHE INTERNAL "Have symbol atan2f")
set(LIBC_HAS_ATANF "1" CACHE INTERNAL "Have symbol atanf")
set(LIBC_HAS_ATOF "1" CACHE INTERNAL "Have symbol atof")
set(LIBC_HAS_ATOI "1" CACHE INTERNAL "Have symbol atoi")
set(LIBC_HAS_BCOPY "1" CACHE INTERNAL "Have symbol bcopy")
set(LIBC_HAS_CALLOC "1" CACHE INTERNAL "Have symbol calloc")
set(LIBC_HAS_CEIL "1" CACHE INTERNAL "Have symbol ceil")
set(LIBC_HAS_CEILF "1" CACHE INTERNAL "Have symbol ceilf")
set(LIBC_HAS_COPYSIGN "1" CACHE INTERNAL "Have symbol copysign")
set(LIBC_HAS_COPYSIGNF "1" CACHE INTERNAL "Have symbol copysignf")
set(LIBC_HAS_COS "1" CACHE INTERNAL "Have symbol cos")
set(LIBC_HAS_COSF "1" CACHE INTERNAL "Have symbol cosf")
set(LIBC_HAS_EXP "1" CACHE INTERNAL "Have symbol exp")
set(LIBC_HAS_EXPF "1" CACHE INTERNAL "Have symbol expf")
set(LIBC_HAS_FABS "1" CACHE INTERNAL "Have symbol fabs")
set(LIBC_HAS_FABSF "1" CACHE INTERNAL "Have symbol fabsf")
set(LIBC_HAS_FLOAT_H "1" CACHE INTERNAL "Have include float.h")
set(LIBC_HAS_FLOOR "1" CACHE INTERNAL "Have symbol floor")
set(LIBC_HAS_FLOORF "1" CACHE INTERNAL "Have symbol floorf")
set(LIBC_HAS_FMOD "1" CACHE INTERNAL "Have symbol fmod")
set(LIBC_HAS_FMODF "1" CACHE INTERNAL "Have symbol fmodf")
set(LIBC_HAS_FOPEN64 "1" CACHE INTERNAL "Have symbol fopen64")
set(LIBC_HAS_FREE "1" CACHE INTERNAL "Have symbol free")
set(LIBC_HAS_FSEEKO "1" CACHE INTERNAL "Have symbol fseeko")
set(LIBC_HAS_FSEEKO64 "1" CACHE INTERNAL "Have symbol fseeko64")
set(LIBC_HAS_GETENV "1" CACHE INTERNAL "Have symbol getenv")
set(LIBC_HAS_ICONV_H "1" CACHE INTERNAL "Have include iconv.h")
set(LIBC_HAS_INDEX "1" CACHE INTERNAL "Have symbol index")
set(LIBC_HAS_INTTYPES_H "1" CACHE INTERNAL "Have include inttypes.h")
set(LIBC_HAS_ISINF "1" CACHE INTERNAL "Have include isinf(double)")
set(LIBC_ISINF_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isinf(float)")
set(LIBC_HAS_ISINFF "1" CACHE INTERNAL "Have include isinff(float)")
set(LIBC_HAS_ISNAN "1" CACHE INTERNAL "Have include isnan(double)")
set(LIBC_ISNAN_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isnan(float)")
set(LIBC_HAS_ISNANF "1" CACHE INTERNAL "Have include isnanf(float)")
set(LIBC_HAS_ITOA "" CACHE INTERNAL "Have symbol itoa")
set(LIBC_HAS_LIMITS_H "1" CACHE INTERNAL "Have include limits.h")
set(LIBC_HAS_LOG "1" CACHE INTERNAL "Have symbol log")
set(LIBC_HAS_LOG10 "1" CACHE INTERNAL "Have symbol log10")
set(LIBC_HAS_LOG10F "1" CACHE INTERNAL "Have symbol log10f")
set(LIBC_HAS_LOGF "1" CACHE INTERNAL "Have symbol logf")
set(LIBC_HAS_LROUND "1" CACHE INTERNAL "Have symbol lround")
set(LIBC_HAS_LROUNDF "1" CACHE INTERNAL "Have symbol lroundf")
set(LIBC_HAS_MALLOC "1" CACHE INTERNAL "Have symbol malloc")
set(LIBC_HAS_MALLOC_H "1" CACHE INTERNAL "Have include malloc.h")
set(LIBC_HAS_MATH_H "1" CACHE INTERNAL "Have include math.h")
set(LIBC_HAS_MEMCMP "1" CACHE INTERNAL "Have symbol memcmp")
set(LIBC_HAS_MEMCPY "1" CACHE INTERNAL "Have symbol memcpy")
set(LIBC_HAS_MEMMOVE "1" CACHE INTERNAL "Have symbol memmove")
set(LIBC_HAS_MEMORY_H "1" CACHE INTERNAL "Have include memory.h")
set(LIBC_HAS_MEMSET "1" CACHE INTERNAL "Have symbol memset")
set(LIBC_HAS_MODF "1" CACHE INTERNAL "Have symbol modf")
set(LIBC_HAS_MODFF "1" CACHE INTERNAL "Have symbol modff")
set(LIBC_HAS_POW "1" CACHE INTERNAL "Have symbol pow")
set(LIBC_HAS_POWF "1" CACHE INTERNAL "Have symbol powf")
set(LIBC_HAS_PUTENV "1" CACHE INTERNAL "Have symbol putenv")
set(LIBC_HAS_REALLOC "1" CACHE INTERNAL "Have symbol realloc")
set(LIBC_HAS_RINDEX "1" CACHE INTERNAL "Have symbol rindex")
set(LIBC_HAS_ROUND "1" CACHE INTERNAL "Have symbol round")
set(LIBC_HAS_ROUNDF "1" CACHE INTERNAL "Have symbol roundf")
set(LIBC_HAS_SCALBN "1" CACHE INTERNAL "Have symbol scalbn")
set(LIBC_HAS_SCALBNF "1" CACHE INTERNAL "Have symbol scalbnf")
set(LIBC_HAS_SETENV "1" CACHE INTERNAL "Have symbol setenv")
set(LIBC_HAS_SIGNAL_H "1" CACHE INTERNAL "Have include signal.h")
set(LIBC_HAS_SIN "1" CACHE INTERNAL "Have symbol sin")
set(LIBC_HAS_SINF "1" CACHE INTERNAL "Have symbol sinf")
set(LIBC_HAS_SQR "" CACHE INTERNAL "Have symbol sqr")
set(LIBC_HAS_SQRT "1" CACHE INTERNAL "Have symbol sqrt")
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h")
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
set(LIBC_HAS_STDLIB_H "1" CACHE INTERNAL "Have include stdlib.h")
set(LIBC_HAS_STRCASESTR "1" CACHE INTERNAL "Have symbol strcasestr")
set(LIBC_HAS_STRCHR "1" CACHE INTERNAL "Have symbol strchr")
set(LIBC_HAS_STRCMP "1" CACHE INTERNAL "Have symbol strcmp")
set(LIBC_HAS_STRINGS_H "1" CACHE INTERNAL "Have include strings.h")
set(LIBC_HAS_STRING_H "1" CACHE INTERNAL "Have include string.h")
set(LIBC_HAS_STRLCAT "1" CACHE INTERNAL "Have symbol strlcat")
set(LIBC_HAS_STRLCPY "1" CACHE INTERNAL "Have symbol strlcpy")
set(LIBC_HAS_STRLEN "1" CACHE INTERNAL "Have symbol strlen")
set(LIBC_HAS_STRNCMP "1" CACHE INTERNAL "Have symbol strncmp")
set(LIBC_HAS_STRNLEN "1" CACHE INTERNAL "Have symbol strnlen")
set(LIBC_HAS_STRNSTR "" CACHE INTERNAL "Have symbol strnstr")
set(LIBC_HAS_STRRCHR "1" CACHE INTERNAL "Have symbol strrchr")
set(LIBC_HAS_STRSTR "1" CACHE INTERNAL "Have symbol strstr")
set(LIBC_HAS_STRTOD "1" CACHE INTERNAL "Have symbol strtod")
set(LIBC_HAS_STRTOK_R "1" CACHE INTERNAL "Have symbol strtok_r")
set(LIBC_HAS_STRTOL "1" CACHE INTERNAL "Have symbol strtol")
set(LIBC_HAS_STRTOLL "1" CACHE INTERNAL "Have symbol strtoll")
set(LIBC_HAS_STRTOUL "1" CACHE INTERNAL "Have symbol strtoul")
set(LIBC_HAS_STRTOULL "1" CACHE INTERNAL "Have symbol strtoull")
set(LIBC_HAS_SYS_TYPES_H "1" CACHE INTERNAL "Have include sys/types.h")
set(LIBC_HAS_TAN "1" CACHE INTERNAL "Have symbol tan")
set(LIBC_HAS_TANF "1" CACHE INTERNAL "Have symbol tanf")
set(LIBC_HAS_TIME_H "1" CACHE INTERNAL "Have include time.h")
set(LIBC_HAS_TRUNC "1" CACHE INTERNAL "Have symbol trunc")
set(LIBC_HAS_TRUNCF "1" CACHE INTERNAL "Have symbol truncf")
set(LIBC_HAS_UNSETENV "1" CACHE INTERNAL "Have symbol unsetenv")
set(LIBC_HAS_VSNPRINTF "1" CACHE INTERNAL "Have symbol vsnprintf")
set(LIBC_HAS_VSSCANF "1" CACHE INTERNAL "Have symbol vsscanf")
set(LIBC_HAS_WCHAR_H "1" CACHE INTERNAL "Have include wchar.h")
set(LIBC_HAS_WCSCMP "1" CACHE INTERNAL "Have symbol wcscmp")
set(LIBC_HAS_WCSDUP "1" CACHE INTERNAL "Have symbol wcsdup")
set(LIBC_HAS_WCSLCAT "" CACHE INTERNAL "Have symbol wcslcat")
set(LIBC_HAS_WCSLCPY "" CACHE INTERNAL "Have symbol wcslcpy")
set(LIBC_HAS_WCSLEN "1" CACHE INTERNAL "Have symbol wcslen")
set(LIBC_HAS_WCSNCMP "1" CACHE INTERNAL "Have symbol wcsncmp")
set(LIBC_HAS_WCSNLEN "1" CACHE INTERNAL "Have symbol wcsnlen")
set(LIBC_HAS_WCSSTR "1" CACHE INTERNAL "Have symbol wcsstr")
set(LIBC_HAS_WCSTOL "1" CACHE INTERNAL "Have symbol wcstol")
set(LIBC_HAS__EXIT "1" CACHE INTERNAL "Have symbol _Exit")
set(LIBC_HAS__I64TOA "" CACHE INTERNAL "Have symbol _i64toa")
set(LIBC_HAS__LTOA "" CACHE INTERNAL "Have symbol _ltoa")
set(LIBC_HAS__STRREV "" CACHE INTERNAL "Have symbol _strrev")
set(LIBC_HAS__UI64TOA "" CACHE INTERNAL "Have symbol _ui64toa")
set(LIBC_HAS__UITOA "" CACHE INTERNAL "Have symbol _uitoa")
set(LIBC_HAS__ULTOA "" CACHE INTERNAL "Have symbol _ultoa")
set(LIBC_HAS__WCSDUP "" CACHE INTERNAL "Have symbol _wcsdup")
set(LIBC_IS_GLIBC "" CACHE INTERNAL "Have symbol __GLIBC__")
set(_ALLOCA_IN_MALLOC_H "" CACHE INTERNAL "Have symbol _alloca")
set(SDL_CPU_EMSCRIPTEN "1" CACHE INTERNAL "Test SDL_CPU_EMSCRIPTEN")
set(HAVE_GCC_WALL "1" CACHE INTERNAL "Test HAVE_GCC_WALL")
set(HAVE_GCC_WUNDEF "1" CACHE INTERNAL "Test HAVE_GCC_WUNDEF")
set(HAVE_GCC_WFLOAT_CONVERSION "1" CACHE INTERNAL "Test HAVE_GCC_WFLOAT_CONVERSION")
set(HAVE_GCC_NO_STRICT_ALIASING "1" CACHE INTERNAL "Test HAVE_GCC_NO_STRICT_ALIASING")
set(HAVE_GCC_WDOCUMENTATION "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION")
set(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND")
set(HAVE_GCC_COMMENT_BLOCK_COMMANDS "1" CACHE INTERNAL "Test HAVE_GCC_COMMENT_BLOCK_COMMANDS")
set(HAVE_GCC_WSHADOW "1" CACHE INTERNAL "Test HAVE_GCC_WSHADOW")
set(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS "1" CACHE INTERNAL "Test HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS")
set(HAVE_GCC_WIMPLICIT_FALLTHROUGH "1" CACHE INTERNAL "Test HAVE_GCC_WIMPLICIT_FALLTHROUGH")
set(HAVE_GCC_FVISIBILITY "1" CACHE INTERNAL "Test HAVE_GCC_FVISIBILITY")
set(HAVE_ST_MTIM "1" CACHE INTERNAL "Test HAVE_ST_MTIM")
set(HAVE_O_CLOEXEC "1" CACHE INTERNAL "Test HAVE_O_CLOEXEC")
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR")
set(COMPILER_SUPPORTS_GCC_ATOMICS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_GCC_ATOMICS")
set(LINKER_SUPPORTS_VERSION_SCRIPT "" CACHE INTERNAL "Test LINKER_SUPPORTS_VERSION_SCRIPT")
set(LINKER_SUPPORTS_WL_NO_UNDEFINED "" CACHE INTERNAL "Test LINKER_SUPPORTS_WL_NO_UNDEFINED")
set(ICONV_IN_LIBC "1" CACHE INTERNAL "Test ICONV_IN_LIBC")
set(ICONV_IN_LIBICONV "" CACHE INTERNAL "Test ICONV_IN_LIBICONV")
set(LIBC_HAS_WORKING_LIBUNWIND "" CACHE INTERNAL "Test LIBC_HAS_WORKING_LIBUNWIND")
set(LIBUNWIND_HAS_WORKINGLIBUNWIND "" CACHE INTERNAL "Test LIBUNWIND_HAS_WORKINGLIBUNWIND")
set(HAVE_GETPAGESIZE "1" CACHE INTERNAL "Have symbol getpagesize")
set(HAVE_SIGACTION "1" CACHE INTERNAL "Have symbol sigaction")
set(HAVE_SA_SIGACTION "1" CACHE INTERNAL "Have symbol sa_sigaction")
set(HAVE_SETJMP "1" CACHE INTERNAL "Have symbol setjmp")
set(HAVE_NANOSLEEP "1" CACHE INTERNAL "Have symbol nanosleep")
set(HAVE_GMTIME_R "1" CACHE INTERNAL "Have symbol gmtime_r")
set(HAVE_LOCALTIME_R "1" CACHE INTERNAL "Have symbol localtime_r")
set(HAVE_NL_LANGINFO "1" CACHE INTERNAL "Have symbol nl_langinfo")
set(HAVE_SYSCONF "1" CACHE INTERNAL "Have symbol sysconf")
set(HAVE_SYSCTLBYNAME "" CACHE INTERNAL "Have symbol sysctlbyname")
set(HAVE_GETAUXVAL "" CACHE INTERNAL "Have symbol getauxval")
set(HAVE_ELF_AUX_INFO "" CACHE INTERNAL "Have symbol elf_aux_info")
set(HAVE_POLL "1" CACHE INTERNAL "Have symbol poll")
set(HAVE_MEMFD_CREATE "" CACHE INTERNAL "Have symbol memfd_create")
set(HAVE_POSIX_FALLOCATE "1" CACHE INTERNAL "Have symbol posix_fallocate")
set(HAVE_DLOPEN_IN_LIBC "1" CACHE INTERNAL "Have symbol dlopen")
endfunction()
endif()

View File

@@ -0,0 +1,182 @@
if(MSVC)
function(SDL_Preseed_CMakeCache)
set(COMPILER_SUPPORTS_W3 "1" CACHE INTERNAL "Test /W3")
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h")
set(HAVE_AUDIOCLIENT_H "1" CACHE INTERNAL "Have include audioclient.h")
set(HAVE_D3D11_H "1" CACHE INTERNAL "Have include d3d11_1.h")
set(HAVE_D3D9_H "1" CACHE INTERNAL "Have include d3d9.h")
set(HAVE_DDRAW_H "1" CACHE INTERNAL "Have include ddraw.h")
set(HAVE_DINPUT_H "1" CACHE INTERNAL "Have include dinput.h")
set(HAVE_DSOUND_H "1" CACHE INTERNAL "Have include dsound.h")
set(HAVE_DXGI_H "1" CACHE INTERNAL "Have include dxgi.h")
set(HAVE_LIBM "" CACHE INTERNAL "Have library m")
set(HAVE_MALLOC "1" CACHE INTERNAL "Have include malloc.h")
set(HAVE_MMDEVICEAPI_H "1" CACHE INTERNAL "Have include mmdeviceapi.h")
set(HAVE_SENSORSAPI_H "1" CACHE INTERNAL "Have include sensorsapi.h")
set(HAVE_SHELLSCALINGAPI_H "1" CACHE INTERNAL "Have include shellscalingapi.h")
set(HAVE_TPCSHRD_H "1" CACHE INTERNAL "Have include tpcshrd.h")
set(HAVE_WIN32_CC "1" CACHE INTERNAL "Test HAVE_WIN32_CC")
set(HAVE_XINPUT_H "1" CACHE INTERNAL "Test HAVE_XINPUT_H")
set(LIBC_HAS_ABS "1" CACHE INTERNAL "Have symbol abs")
set(LIBC_HAS_ACOS "1" CACHE INTERNAL "Have symbol acos")
set(LIBC_HAS_ACOSF "1" CACHE INTERNAL "Have symbol acosf")
set(LIBC_HAS_ASIN "1" CACHE INTERNAL "Have symbol asin")
set(LIBC_HAS_ASINF "1" CACHE INTERNAL "Have symbol asinf")
set(LIBC_HAS_ATAN "1" CACHE INTERNAL "Have symbol atan")
set(LIBC_HAS_ATAN2 "1" CACHE INTERNAL "Have symbol atan2")
set(LIBC_HAS_ATAN2F "1" CACHE INTERNAL "Have symbol atan2f")
set(LIBC_HAS_ATANF "1" CACHE INTERNAL "Have symbol atanf")
set(LIBC_HAS_ATOF "1" CACHE INTERNAL "Have symbol atof")
set(LIBC_HAS_ATOI "1" CACHE INTERNAL "Have symbol atoi")
set(LIBC_HAS_BCOPY "" CACHE INTERNAL "Have symbol bcopy")
set(LIBC_HAS_CALLOC "1" CACHE INTERNAL "Have symbol calloc")
set(LIBC_HAS_CEIL "1" CACHE INTERNAL "Have symbol ceil")
set(LIBC_HAS_CEILF "1" CACHE INTERNAL "Have symbol ceilf")
set(LIBC_HAS_COPYSIGN "1" CACHE INTERNAL "Have symbol copysign")
set(LIBC_HAS_COPYSIGNF "1" CACHE INTERNAL "Have symbol copysignf")
set(LIBC_HAS_COS "1" CACHE INTERNAL "Have symbol cos")
set(LIBC_HAS_COSF "1" CACHE INTERNAL "Have symbol cosf")
set(LIBC_HAS_EXP "1" CACHE INTERNAL "Have symbol exp")
set(LIBC_HAS_EXPF "1" CACHE INTERNAL "Have symbol expf")
set(LIBC_HAS_FABS "1" CACHE INTERNAL "Have symbol fabs")
set(LIBC_HAS_FABSF "1" CACHE INTERNAL "Have symbol fabsf")
set(LIBC_HAS_FLOAT_H "1" CACHE INTERNAL "Have include float.h")
set(LIBC_HAS_FLOOR "1" CACHE INTERNAL "Have symbol floor")
set(LIBC_HAS_FLOORF "1" CACHE INTERNAL "Have symbol floorf")
set(LIBC_HAS_FMOD "1" CACHE INTERNAL "Have symbol fmod")
set(LIBC_HAS_FMODF "1" CACHE INTERNAL "Have symbol fmodf")
set(LIBC_HAS_FOPEN64 "" CACHE INTERNAL "Have symbol fopen64")
set(LIBC_HAS_FREE "1" CACHE INTERNAL "Have symbol free")
set(LIBC_HAS_FSEEKO "" CACHE INTERNAL "Have symbol fseeko")
set(LIBC_HAS_FSEEKO64 "" CACHE INTERNAL "Have symbol fseeko64")
set(LIBC_HAS_GETENV "1" CACHE INTERNAL "Have symbol getenv")
set(LIBC_HAS_ICONV_H "" CACHE INTERNAL "Have include iconv.h")
set(LIBC_HAS_INDEX "" CACHE INTERNAL "Have symbol index")
set(LIBC_HAS_INTTYPES_H "1" CACHE INTERNAL "Have include inttypes.h")
set(LIBC_HAS_ISINF "1" CACHE INTERNAL "Have include isinf(double)")
set(LIBC_ISINF_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isinf(float)")
set(LIBC_HAS_ISINFF "" CACHE INTERNAL "Have include isinff(float)")
set(LIBC_HAS_ISNAN "1" CACHE INTERNAL "Have include isnan(double)")
set(LIBC_ISNAN_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isnan(float)")
set(LIBC_HAS_ISNANF "" CACHE INTERNAL "Have include isnanf(float)")
set(LIBC_HAS_ITOA "1" CACHE INTERNAL "Have symbol itoa")
set(LIBC_HAS_LIMITS_H "1" CACHE INTERNAL "Have include limits.h")
set(LIBC_HAS_LOG "1" CACHE INTERNAL "Have symbol log")
set(LIBC_HAS_LOG10 "1" CACHE INTERNAL "Have symbol log10")
set(LIBC_HAS_LOG10F "1" CACHE INTERNAL "Have symbol log10f")
set(LIBC_HAS_LOGF "1" CACHE INTERNAL "Have symbol logf")
set(LIBC_HAS_LROUND "1" CACHE INTERNAL "Have symbol lround")
set(LIBC_HAS_LROUNDF "1" CACHE INTERNAL "Have symbol lroundf")
set(LIBC_HAS_MALLOC "1" CACHE INTERNAL "Have symbol malloc")
set(LIBC_HAS_MALLOC_H "1" CACHE INTERNAL "Have include malloc.h")
set(LIBC_HAS_MATH_H "1" CACHE INTERNAL "Have include math.h")
set(LIBC_HAS_MEMCMP "1" CACHE INTERNAL "Have symbol memcmp")
set(LIBC_HAS_MEMCPY "1" CACHE INTERNAL "Have symbol memcpy")
set(LIBC_HAS_MEMMOVE "1" CACHE INTERNAL "Have symbol memmove")
set(LIBC_HAS_MEMORY_H "1" CACHE INTERNAL "Have include memory.h")
set(LIBC_HAS_MEMSET "1" CACHE INTERNAL "Have symbol memset")
set(LIBC_HAS_MODF "1" CACHE INTERNAL "Have symbol modf")
set(LIBC_HAS_MODFF "1" CACHE INTERNAL "Have symbol modff")
set(LIBC_HAS_POW "1" CACHE INTERNAL "Have symbol pow")
set(LIBC_HAS_POWF "1" CACHE INTERNAL "Have symbol powf")
set(LIBC_HAS_PUTENV "1" CACHE INTERNAL "Have symbol putenv")
set(LIBC_HAS_REALLOC "1" CACHE INTERNAL "Have symbol realloc")
set(LIBC_HAS_RINDEX "" CACHE INTERNAL "Have symbol rindex")
set(LIBC_HAS_ROUND "1" CACHE INTERNAL "Have symbol round")
set(LIBC_HAS_ROUNDF "1" CACHE INTERNAL "Have symbol roundf")
set(LIBC_HAS_SCALBN "1" CACHE INTERNAL "Have symbol scalbn")
set(LIBC_HAS_SCALBNF "1" CACHE INTERNAL "Have symbol scalbnf")
set(LIBC_HAS_SETENV "" CACHE INTERNAL "Have symbol setenv")
set(LIBC_HAS_SIGNAL_H "1" CACHE INTERNAL "Have include signal.h")
set(LIBC_HAS_SIN "1" CACHE INTERNAL "Have symbol sin")
set(LIBC_HAS_SINF "1" CACHE INTERNAL "Have symbol sinf")
set(LIBC_HAS_SQR "" CACHE INTERNAL "Have symbol sqr")
set(LIBC_HAS_SQRT "1" CACHE INTERNAL "Have symbol sqrt")
set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf")
set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf")
set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h")
set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h")
set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h")
set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h")
set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h")
set(LIBC_HAS_STDLIB_H "1" CACHE INTERNAL "Have include stdlib.h")
set(LIBC_HAS_STRCHR "1" CACHE INTERNAL "Have symbol strchr")
set(LIBC_HAS_STRCMP "1" CACHE INTERNAL "Have symbol strcmp")
set(LIBC_HAS_STRINGS_H "" CACHE INTERNAL "Have include strings.h")
set(LIBC_HAS_STRING_H "1" CACHE INTERNAL "Have include string.h")
set(LIBC_HAS_STRLCAT "" CACHE INTERNAL "Have symbol strlcat")
set(LIBC_HAS_STRLCPY "" CACHE INTERNAL "Have symbol strlcpy")
set(LIBC_HAS_STRLEN "1" CACHE INTERNAL "Have symbol strlen")
set(LIBC_HAS_STRNCMP "1" CACHE INTERNAL "Have symbol strncmp")
set(LIBC_HAS_STRNLEN "1" CACHE INTERNAL "Have symbol strnlen")
set(LIBC_HAS_STRNSTR "" CACHE INTERNAL "Have symbol strnstr")
set(LIBC_HAS_STRRCHR "1" CACHE INTERNAL "Have symbol strrchr")
set(LIBC_HAS_STRSTR "1" CACHE INTERNAL "Have symbol strstr")
set(LIBC_HAS_STRTOD "1" CACHE INTERNAL "Have symbol strtod")
set(LIBC_HAS_STRTOK_R "" CACHE INTERNAL "Have symbol strtok_r")
set(LIBC_HAS_STRTOL "1" CACHE INTERNAL "Have symbol strtol")
set(LIBC_HAS_STRTOLL "1" CACHE INTERNAL "Have symbol strtoll")
set(LIBC_HAS_STRTOUL "1" CACHE INTERNAL "Have symbol strtoul")
set(LIBC_HAS_STRTOULL "1" CACHE INTERNAL "Have symbol strtoull")
set(LIBC_HAS_SYS_TYPES_H "1" CACHE INTERNAL "Have include sys/types.h")
set(LIBC_HAS_TAN "1" CACHE INTERNAL "Have symbol tan")
set(LIBC_HAS_TANF "1" CACHE INTERNAL "Have symbol tanf")
set(LIBC_HAS_TIME_H "1" CACHE INTERNAL "Have include time.h")
set(LIBC_HAS_TRUNC "1" CACHE INTERNAL "Have symbol trunc")
set(LIBC_HAS_TRUNCF "1" CACHE INTERNAL "Have symbol truncf")
set(LIBC_HAS_UNSETENV "" CACHE INTERNAL "Have symbol unsetenv")
set(LIBC_HAS_VSNPRINTF "1" CACHE INTERNAL "Have symbol vsnprintf")
set(LIBC_HAS_VSSCANF "1" CACHE INTERNAL "Have symbol vsscanf")
set(LIBC_HAS_WCHAR_H "1" CACHE INTERNAL "Have include wchar.h")
set(LIBC_HAS_WCSCMP "1" CACHE INTERNAL "Have symbol wcscmp")
set(LIBC_HAS_WCSDUP "1" CACHE INTERNAL "Have symbol wcsdup")
set(LIBC_HAS_WCSLCAT "" CACHE INTERNAL "Have symbol wcslcat")
set(LIBC_HAS_WCSLCPY "" CACHE INTERNAL "Have symbol wcslcpy")
set(LIBC_HAS_WCSLEN "1" CACHE INTERNAL "Have symbol wcslen")
set(LIBC_HAS_WCSNCMP "1" CACHE INTERNAL "Have symbol wcsncmp")
set(LIBC_HAS_WCSNLEN "1" CACHE INTERNAL "Have symbol wcsnlen")
set(LIBC_HAS_WCSSTR "1" CACHE INTERNAL "Have symbol wcsstr")
set(LIBC_HAS_WCSTOL "1" CACHE INTERNAL "Have symbol wcstol")
set(LIBC_HAS__EXIT "1" CACHE INTERNAL "Have symbol _Exit")
set(LIBC_HAS__I64TOA "1" CACHE INTERNAL "Have symbol _i64toa")
set(LIBC_HAS__LTOA "1" CACHE INTERNAL "Have symbol _ltoa")
set(LIBC_HAS__STRREV "1" CACHE INTERNAL "Have symbol _strrev")
set(LIBC_HAS__UI64TOA "1" CACHE INTERNAL "Have symbol _ui64toa")
set(LIBC_HAS__UITOA "" CACHE INTERNAL "Have symbol _uitoa")
set(LIBC_HAS__ULTOA "1" CACHE INTERNAL "Have symbol _ultoa")
set(LIBC_HAS__WCSDUP "1" CACHE INTERNAL "Have symbol _wcsdup")
set(LIBC_IS_GLIBC "" CACHE INTERNAL "Have symbol __GLIBC__")
set(_ALLOCA_IN_MALLOC_H "" CACHE INTERNAL "Have symbol _alloca")
if(CHECK_CPU_ARCHITECTURE_X86)
set(COMPILER_SUPPORTS_AVX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX")
set(COMPILER_SUPPORTS_AVX2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX2")
set(COMPILER_SUPPORTS_MMX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_MMX")
set(COMPILER_SUPPORTS_SSE "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE")
set(COMPILER_SUPPORTS_SSE2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE2")
set(COMPILER_SUPPORTS_SSE3 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE3")
set(COMPILER_SUPPORTS_SSE4_1 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_1")
set(COMPILER_SUPPORTS_SSE4_2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_2")
endif()
if(CHECK_CPU_ARCHITECTURE_X64)
set(COMPILER_SUPPORTS_AVX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX")
set(COMPILER_SUPPORTS_AVX2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX2")
set(COMPILER_SUPPORTS_MMX "" CACHE INTERNAL "Test COMPILER_SUPPORTS_MMX")
set(COMPILER_SUPPORTS_SSE "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE")
set(COMPILER_SUPPORTS_SSE2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE2")
set(COMPILER_SUPPORTS_SSE3 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE3")
set(COMPILER_SUPPORTS_SSE4_1 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_1")
set(COMPILER_SUPPORTS_SSE4_2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_2")
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.1")
set(HAVE_ROAPI_H "1" CACHE INTERNAL "Have include roapi.h")
set(HAVE_WINDOWS_GAMING_INPUT_H "1" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H")
else()
set(HAVE_ROAPI_H "" CACHE INTERNAL "Have include roapi.h")
set(HAVE_WINDOWS_GAMING_INPUT_H "" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H")
endif()
endfunction()
endif()

105
external/SDL/cmake/SDL3Config.cmake.in vendored Normal file
View File

@@ -0,0 +1,105 @@
# SDL cmake project-config input for CMakeLists.txt script
include(FeatureSummary)
set_package_properties(SDL3 PROPERTIES
URL "https://www.libsdl.org/"
DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
)
@PACKAGE_INIT@
set(SDL3_FOUND TRUE)
set(_sdl3_framework @SDL_FRAMEWORK@)
# Find SDL3::Headers
if(NOT TARGET SDL3::Headers)
include("${CMAKE_CURRENT_LIST_DIR}/SDL3headersTargets.cmake")
if(NOT CMAKE_VERSION VERSION_LESS "3.25")
set_property(TARGET SDL3::Headers PROPERTY SYSTEM 0)
endif()
endif()
set(SDL3_Headers_FOUND TRUE)
# Find SDL3::SDL3-shared
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3sharedTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SDL3sharedTargets.cmake")
set(SDL3_SDL3-shared_FOUND TRUE)
endif()
macro(find_sdl3_static_dependencies)
@SDL_FIND_PKG_CONFIG_COMMANDS@
endmacro()
# Find SDL3::SDL3-static
if(_sdl3_framework)
set(SDL3_SDL3-static_FOUND TRUE)
find_sdl3_static_dependencies()
find_package(SDL3-static CONFIG)
if(SDL3_SDL3-static_FOUND AND SDL3-static_FOUND)
set(SDL3_SDL3-static_FOUND TRUE)
endif()
else()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake")
set(SDL3_SDL3-static_FOUND TRUE)
find_sdl3_static_dependencies()
if(SDL3_SDL3-static_FOUND)
if(ANDROID OR HAIKU)
enable_language(CXX)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake")
endif()
endif()
endif()
if(ANDROID AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake")
set(SDL3_Jar_FOUND TRUE)
endif()
if(SDL3_SDL3-shared_FOUND OR SDL3_SDL3-static_FOUND)
set(SDL3_SDL3_FOUND TRUE)
endif()
# Find SDL3::SDL3_test
if(_sdl3_framework)
find_package(SDL3_test CONFIG)
if(SDL3_test_FOUND)
enable_language(OBJC)
set(SDL3_SDL3_test_FOUND TRUE)
endif()
else()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake")
set(SDL3_SDL3_test_FOUND TRUE)
@SDL_TEST_FIND_PKG_CONFIG_COMMANDS@
if(SDL3_SDL3_test_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake")
endif()
endif()
endif()
check_required_components(SDL3)
function(_sdl_create_target_alias_compat NEW_TARGET TARGET)
if(CMAKE_VERSION VERSION_LESS "3.18")
# Aliasing local targets is not supported on CMake < 3.18, so make it global.
add_library(${NEW_TARGET} INTERFACE IMPORTED)
set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}")
else()
add_library(${NEW_TARGET} ALIAS ${TARGET})
endif()
endfunction()
# Make sure SDL3::SDL3 always exists
if(NOT TARGET SDL3::SDL3)
if(TARGET SDL3::SDL3-shared)
_sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-shared)
else()
_sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-static)
endif()
endif()
set(SDL3_LIBRARIES SDL3::SDL3)
set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static)
set(SDL3_STATIC_PRIVATE_LIBS)
set(SDL3TEST_LIBRARY SDL3::SDL3_test)

View File

@@ -0,0 +1,10 @@
@PACKAGE_INIT@
set_and_check(SDL3_JAR "@PACKAGE_SDL_INSTALL_JAVADIR@/SDL3/SDL3-@SDL3_VERSION@.jar")
if(NOT TARGET SDL3::Jar)
add_library(SDL3::Jar INTERFACE IMPORTED)
set_property(TARGET SDL3::Jar PROPERTY JAR_FILE "${SDL3_JAR}")
endif()
unset(SDL3_JAR)

View File

@@ -0,0 +1,103 @@
#[=======================================================================[
FindSdlAndroid
----------------------
Locate various executables that are essential to creating an Android APK archive.
This find module uses the FindSdlAndroidBuildTools module to locate some Android utils.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target(s):
`` SdlAndroid::aapt2 ``
Imported executable for the "android package tool" v2
`` SdlAndroid::apksigner``
Imported executable for the APK signer tool
`` SdlAndroid::d8 ``
Imported executable for the dex compiler
`` SdlAndroid::zipalign ``
Imported executable for the zipalign util
`` SdlAndroid::adb ``
Imported executable for the "android debug bridge" tool
`` SdlAndroid::keytool ``
Imported executable for the keytool, a key and certificate management utility
`` SdlAndroid::zip ``
Imported executable for the zip, for packaging and compressing files
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
`` AAPT2_BIN ``
Path of aapt2
`` APKSIGNER_BIN ``
Path of apksigner
`` D8_BIN ``
Path of d8
`` ZIPALIGN_BIN ``
Path of zipalign
`` ADB_BIN ``
Path of adb
`` KEYTOOL_BIN ``
Path of keytool
`` ZIP_BIN ``
Path of zip
#]=======================================================================]
cmake_minimum_required(VERSION 3.7)
if(NOT PROJECT_NAME MATCHES "^SDL.*")
message(WARNING "This module is internal to SDL and is currently not supported.")
endif()
find_package(SdlAndroidBuildTools MODULE)
function(_sdl_android_find_create_imported_executable NAME)
string(TOUPPER "${NAME}" NAME_UPPER)
set(varname "${NAME_UPPER}_BIN")
find_program("${varname}" NAMES "${NAME}" PATHS ${SDL_ANDROID_BUILD_TOOLS_ROOT})
if(EXISTS "${${varname}}" AND NOT TARGET SdlAndroid::${NAME})
add_executable(SdlAndroid::${NAME} IMPORTED)
set_property(TARGET SdlAndroid::${NAME} PROPERTY IMPORTED_LOCATION "${${varname}}")
endif()
endfunction()
if(SdlAndroidBuildTools_FOUND)
_sdl_android_find_create_imported_executable(aapt2)
_sdl_android_find_create_imported_executable(apksigner)
_sdl_android_find_create_imported_executable(d8)
_sdl_android_find_create_imported_executable(zipalign)
endif()
_sdl_android_find_create_imported_executable(adb)
_sdl_android_find_create_imported_executable(keytool)
_sdl_android_find_create_imported_executable(zip)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SdlAndroid
VERSION_VAR
REQUIRED_VARS
AAPT2_BIN
APKSIGNER_BIN
D8_BIN
ZIPALIGN_BIN
KEYTOOL_BIN
ZIP_BIN
)

View File

@@ -0,0 +1,115 @@
#[=======================================================================[
FindSdlAndroidBuildTools
----------------------
Locate the Android build tools directory.
Imported targets
^^^^^^^^^^^^^^^^
This find module defines the following :prop_tgt:`IMPORTED` target(s):
<none>
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
`` SdlAndroidBuildTools_FOUND
if false, no Android build tools have been found
`` SDL_ANDROID_BUILD_TOOLS_ROOT
path of the Android build tools root directory if found
`` SDL_ANDROID_BUILD_TOOLS_VERSION
the human-readable string containing the android build tools version if found
Cache variables
^^^^^^^^^^^^^^^
These variables may optionally be set to help this module find the correct files:
``SDL_ANDROID_BUILD_TOOLS_ROOT``
path of the Android build tools root directory
Variables for locating Android platform
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This module responds to the flags:
``SDL_ANDROID_HOME
First, this module will look for platforms in this CMake variable.
``ANDROID_HOME
If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`.
``$ENV{ANDROID_HOME}
If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}`
#]=======================================================================]
cmake_minimum_required(VERSION 3.7)
if(NOT PROJECT_NAME MATCHES "^SDL.*")
message(WARNING "This module is internal to SDL and is currently not supported.")
endif()
function(_sdl_is_valid_android_build_tools_root RESULT VERSION BUILD_TOOLS_ROOT)
set(result TRUE)
set(version -1)
string(REGEX MATCH "/([0-9.]+)$" root_match "${BUILD_TOOLS_ROOT}")
if(root_match
AND EXISTS "${BUILD_TOOLS_ROOT}/aapt2"
AND EXISTS "${BUILD_TOOLS_ROOT}/apksigner"
AND EXISTS "${BUILD_TOOLS_ROOT}/d8"
AND EXISTS "${BUILD_TOOLS_ROOT}/zipalign")
set(result "${BUILD_TOOLS_ROOT}")
set(version "${CMAKE_MATCH_1}")
endif()
set(${RESULT} ${result} PARENT_SCOPE)
set(${VERSION} ${version} PARENT_SCOPE)
endfunction()
function(_find_sdl_android_build_tools_root ROOT)
cmake_parse_arguments(fsabtr "" "" "" ${ARGN})
set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME})
set(root ${ROOT}-NOTFOUND)
foreach(home IN LISTS homes)
if(NOT IS_DIRECTORY "${home}")
continue()
endif()
file(GLOB build_tools_roots LIST_DIRECTORIES true "${home}/build-tools/*")
set(max_build_tools_version -1)
set(max_build_tools_root "")
foreach(build_tools_root IN LISTS build_tools_roots)
_sdl_is_valid_android_build_tools_root(is_valid build_tools_version "${build_tools_root}")
if(is_valid AND build_tools_version GREATER max_build_tools_version)
set(max_build_tools_version "${build_tools_version}")
set(max_build_tools_root "${build_tools_root}")
endif()
endforeach()
if(max_build_tools_version GREATER -1)
set(root ${max_build_tools_root})
break()
endif()
endforeach()
set(${ROOT} ${root} PARENT_SCOPE)
endfunction()
if(NOT DEFINED SDL_ANDROID_BUILD_TOOLS_ROOT)
_find_sdl_android_build_tools_root(SDL_ANDROID_BUILD_TOOLS_ROOT)
set(SDL_ANDROID_BUILD_TOOLS_ROOT "${SDL_ANDROID_BUILD_TOOLS_ROOT}" CACHE PATH "Path of Android build tools")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SdlAndroidBuildTools
VERSION_VAR SDL_ANDROID_BUILD_TOOLS_VERSION
REQUIRED_VARS SDL_ANDROID_BUILD_TOOLS_ROOT
)

View File

@@ -0,0 +1,123 @@
#[=======================================================================[
FindSdlAndroidPlatform
----------------------
Locate the Android SDK platform.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target(s):
<none>
Result variables
^^^^^^^^^^^^^^^^
This find module will set the following variables in your project:
`` SdlAndroidPlatform_FOUND
if false, no Android platform has been found
`` SDL_ANDROID_PLATFORM_ROOT
path of the Android SDK platform root directory if found
`` SDL_ANDROID_PLATFORM_ANDROID_JAR
path of the Android SDK platform jar file if found
`` SDL_ANDROID_PLATFORM_VERSION
the human-readable string containing the android platform version if found
Cache variables
^^^^^^^^^^^^^^^
These variables may optionally be set to help this module find the correct files:
``SDL_ANDROID_PLATFORM_ROOT``
path of the Android SDK platform root directory
Variables for locating Android platform
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This module responds to the flags:
``SDL_ANDROID_HOME
First, this module will look for platforms in this CMake variable.
``ANDROID_HOME
If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`.
``$ENV{ANDROID_HOME}
If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}`
#]=======================================================================]
cmake_minimum_required(VERSION 3.7)
if(NOT PROJECT_NAME MATCHES "^SDL.*")
message(WARNING "This module is internal to SDL and is currently not supported.")
endif()
function(_sdl_is_valid_android_platform_root RESULT VERSION PLATFORM_ROOT)
set(result FALSE)
set(version -1)
string(REGEX MATCH "/android-([0-9]+)$" root_match "${PLATFORM_ROOT}")
if(root_match AND EXISTS "${PLATFORM_ROOT}/android.jar")
set(result TRUE)
set(version "${CMAKE_MATCH_1}")
endif()
set(${RESULT} ${result} PARENT_SCOPE)
set(${VERSION} ${version} PARENT_SCOPE)
endfunction()
function(_sdl_find_android_platform_root ROOT)
cmake_parse_arguments(sfapr "" "" "" ${ARGN})
set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME})
set(root ${ROOT}-NOTFOUND)
foreach(home IN LISTS homes)
if(NOT IS_DIRECTORY "${home}")
continue()
endif()
file(GLOB platform_roots LIST_DIRECTORIES true "${home}/platforms/*")
set(max_platform_version -1)
set(max_platform_root "")
foreach(platform_root IN LISTS platform_roots)
_sdl_is_valid_android_platform_root(is_valid platform_version "${platform_root}")
if(is_valid AND platform_version GREATER max_platform_version)
set(max_platform_version "${platform_version}")
set(max_platform_root "${platform_root}")
endif()
endforeach()
if(max_platform_version GREATER -1)
set(root ${max_platform_root})
break()
endif()
endforeach()
set(${ROOT} ${root} PARENT_SCOPE)
endfunction()
set(SDL_ANDROID_PLATFORM_ANDROID_JAR "SDL_ANDROID_PLATFORM_ANDROID_JAR-NOTFOUND")
if(NOT DEFINED SDL_ANDROID_PLATFORM_ROOT)
_sdl_find_android_platform_root(SDL_ANDROID_PLATFORM_ROOT)
set(SDL_ANDROID_PLATFORM_ROOT "${SDL_ANDROID_PLATFORM_ROOT}" CACHE PATH "Path of Android platform")
endif()
if(SDL_ANDROID_PLATFORM_ROOT)
_sdl_is_valid_android_platform_root(_valid SDL_ANDROID_PLATFORM_VERSION "${SDL_ANDROID_PLATFORM_ROOT}")
if(_valid)
set(SDL_ANDROID_PLATFORM_ANDROID_JAR "${SDL_ANDROID_PLATFORM_ROOT}/android.jar")
endif()
unset(_valid)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SdlAndroidPlatform
VERSION_VAR SDL_ANDROID_PLATFORM_VERSION
REQUIRED_VARS SDL_ANDROID_PLATFORM_ROOT SDL_ANDROID_PLATFORM_ANDROID_JAR
)

View File

@@ -0,0 +1,276 @@
#[=======================================================================[
This CMake script contains functions to build an Android APK.
It is (currently) limited to packaging binaries for a single architecture.
#]=======================================================================]
cmake_minimum_required(VERSION 3.7)
if(NOT PROJECT_NAME MATCHES "^SDL.*")
message(WARNING "This module is internal to SDL and is currently not supported.")
endif()
function(_sdl_create_outdir_for_target OUTDIRECTORY TARGET)
set(outdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir")
# Some CMake versions have a slow `cmake -E make_directory` implementation
if(NOT IS_DIRECTORY "${outdir}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${outdir}")
endif()
set("${OUTDIRECTORY}" "${outdir}" PARENT_SCOPE)
endfunction()
function(sdl_create_android_debug_keystore TARGET)
set(output "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_debug.keystore")
add_custom_command(OUTPUT ${output}
COMMAND ${CMAKE_COMMAND} -E rm -f "${output}"
COMMAND SdlAndroid::keytool -genkey -keystore "${output}" -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
)
add_custom_target(${TARGET} DEPENDS "${output}")
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${output}")
endfunction()
function(sdl_android_compile_resources TARGET)
cmake_parse_arguments(arg "" "RESFOLDER" "RESOURCES" ${ARGN})
if(NOT arg_RESFOLDER AND NOT arg_RESOURCES)
message(FATAL_ERROR "Missing RESFOLDER or RESOURCES argument (need one or both)")
endif()
_sdl_create_outdir_for_target(outdir "${TARGET}")
set(out_files "")
set(res_files "")
if(arg_RESFOLDER)
get_filename_component(arg_RESFOLDER "${arg_RESFOLDER}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
file(GLOB_RECURSE res_folder_files "${arg_RESFOLDER}/*")
list(APPEND res_files ${res_folder_files})
foreach(res_file IN LISTS res_files)
file(RELATIVE_PATH rel_res_file "${arg_RESFOLDER}" "${res_file}")
string(REPLACE "/" "_" rel_comp_path "${rel_res_file}")
if(res_file MATCHES ".*res/values.*\\.xml$")
string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}")
endif()
set(comp_path "${outdir}/${rel_comp_path}.flat")
add_custom_command(
OUTPUT "${comp_path}"
COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}"
DEPENDS ${res_file}
)
list(APPEND out_files "${comp_path}")
endforeach()
endif()
if(arg_RESOURCES)
list(APPEND res_files ${arg_RESOURCES})
foreach(res_file IN LISTS arg_RESOURCES)
string(REGEX REPLACE ".*/res/" "" rel_res_file ${res_file})
string(REPLACE "/" "_" rel_comp_path "${rel_res_file}")
if(res_file MATCHES ".*res/values.*\\.xml$")
string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}")
endif()
set(comp_path "${outdir}/${rel_comp_path}.flat")
add_custom_command(
OUTPUT "${comp_path}"
COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}"
DEPENDS ${res_file}
)
list(APPEND out_files "${comp_path}")
endforeach()
endif()
add_custom_target(${TARGET} DEPENDS ${out_files})
set_property(TARGET "${TARGET}" PROPERTY OUTPUTS "${out_files}")
set_property(TARGET "${TARGET}" PROPERTY SOURCES "${res_files}")
endfunction()
function(sdl_android_link_resources TARGET)
cmake_parse_arguments(arg "NO_DEBUG" "MIN_SDK_VERSION;TARGET_SDK_VERSION;ANDROID_JAR;OUTPUT_APK;MANIFEST;PACKAGE" "RES_TARGETS" ${ARGN})
if(arg_MANIFEST)
get_filename_component(arg_MANIFEST "${arg_MANIFEST}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
else()
message(FATAL_ERROR "sdl_add_android_link_resources_target requires a Android MANIFEST path (${arg_MANIFEST})")
endif()
if(NOT arg_PACKAGE)
file(READ "${arg_MANIFEST}" manifest_contents)
string(REGEX MATCH "package=\"([a-zA-Z0-9_.]+)\"" package_match "${manifest_contents}")
if(NOT package_match)
message(FATAL_ERROR "Could not extract package from Android manifest (${arg_MANIFEST})")
endif()
set(arg_PACKAGE "${CMAKE_MATCH_1}")
endif()
set(depends "")
_sdl_create_outdir_for_target(outdir "${TARGET}")
string(REPLACE "." "/" java_r_path "${arg_PACKAGE}")
get_filename_component(java_r_path "${java_r_path}" ABSOLUTE BASE_DIR "${outdir}")
set(java_r_path "${java_r_path}/R.java")
set(command SdlAndroid::aapt2 link)
if(NOT arg_NO_DEBUG)
list(APPEND command --debug-mode)
endif()
if(arg_MIN_SDK_VERSION)
list(APPEND command --min-sdk-version ${arg_MIN_SDK_VERSION})
endif()
if(arg_TARGET_SDK_VERSION)
list(APPEND command --target-sdk-version ${arg_TARGET_SDK_VERSION})
endif()
if(arg_ANDROID_JAR)
list(APPEND command -I "${arg_ANDROID_JAR}")
else()
list(APPEND command -I "${SDL_ANDROID_PLATFORM_ANDROID_JAR}")
endif()
if(NOT arg_OUTPUT_APK)
set(arg_OUTPUT_APK "${TARGET}.apk")
endif()
get_filename_component(arg_OUTPUT_APK "${arg_OUTPUT_APK}" ABSOLUTE BASE_DIR "${outdir}")
list(APPEND command -o "${arg_OUTPUT_APK}")
list(APPEND command --java "${outdir}")
list(APPEND command --manifest "${arg_MANIFEST}")
foreach(res_target IN LISTS arg_RES_TARGETS)
list(APPEND command $<TARGET_PROPERTY:${res_target},OUTPUTS>)
list(APPEND depends $<TARGET_PROPERTY:${res_target},OUTPUTS>)
endforeach()
add_custom_command(
OUTPUT "${arg_OUTPUT_APK}" "${java_r_path}"
COMMAND ${command}
DEPENDS ${depends} ${arg_MANIFEST}
COMMAND_EXPAND_LISTS
VERBATIM
)
add_custom_target(${TARGET} DEPENDS "${arg_OUTPUT_APK}" "${java_r_path}")
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${arg_OUTPUT_APK}")
set_property(TARGET ${TARGET} PROPERTY JAVA_R "${java_r_path}")
set_property(TARGET ${TARGET} PROPERTY OUTPUTS "${${arg_OUTPUT_APK}};${java_r_path}")
endfunction()
function(sdl_add_to_apk_unaligned TARGET)
cmake_parse_arguments(arg "" "APK_IN;NAME;OUTDIR" "ASSETS;NATIVE_LIBS;DEX" ${ARGN})
if(NOT arg_APK_IN)
message(FATAL_ERROR "Missing APK_IN argument")
endif()
if(NOT TARGET ${arg_APK_IN})
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
endif()
_sdl_create_outdir_for_target(workdir ${TARGET})
if(NOT arg_OUTDIR)
set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
if(NOT arg_NAME)
string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}")
if(NOT arg_NAME MATCHES "\\.apk")
set(arg_NAME "${arg_NAME}.apk")
endif()
endif()
get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}")
set(apk_libdir "lib/${ANDROID_ABI}")
set(depends "")
set(commands
COMMAND "${CMAKE_COMMAND}" -E remove_directory -rf "${apk_libdir}" "assets"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${apk_libdir}" "assets"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>" "${apk_file}"
)
set(dex_i "1")
foreach(dex IN LISTS arg_DEX)
set(suffix "${dex_i}")
if(suffix STREQUAL "1")
set(suffix "")
endif()
list(APPEND commands
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${dex},OUTPUT>" "classes${suffix}.dex"
COMMAND SdlAndroid::zip -u -q -j "${apk_file}" "classes${suffix}.dex"
)
math(EXPR dex_i "${dex_i}+1")
list(APPEND depends "$<TARGET_PROPERTY:${dex},OUTPUT>")
endforeach()
foreach(native_lib IN LISTS arg_NATIVE_LIBS)
list(APPEND commands
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${native_lib}> "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>"
COMMAND SdlAndroid::zip -u -q "${apk_file}" "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>"
)
endforeach()
if(arg_ASSETS)
list(APPEND commands
COMMAND "${CMAKE_COMMAND}" -E copy ${arg_ASSETS} "assets"
COMMAND SdlAndroid::zip -u -r -q "${apk_file}" "assets"
)
endif()
add_custom_command(OUTPUT "${apk_file}"
${commands}
DEPENDS ${arg_NATIVE_LIBS} ${depends} "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>"
WORKING_DIRECTORY "${workdir}"
)
add_custom_target(${TARGET} DEPENDS "${apk_file}")
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
endfunction()
function(sdl_apk_align TARGET APK_IN)
cmake_parse_arguments(arg "" "NAME;OUTDIR" "" ${ARGN})
if(NOT TARGET ${arg_APK_IN})
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
endif()
if(NOT arg_OUTDIR)
set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
if(NOT arg_NAME)
string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}")
if(NOT arg_NAME MATCHES "\\.apk")
set(arg_NAME "${arg_NAME}.apk")
endif()
endif()
get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}")
add_custom_command(OUTPUT "${apk_file}"
COMMAND SdlAndroid::zipalign -f 4 "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "${apk_file}"
DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>"
)
add_custom_target(${TARGET} DEPENDS "${apk_file}")
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
endfunction()
function(sdl_apk_sign TARGET APK_IN)
cmake_parse_arguments(arg "" "OUTPUT;KEYSTORE" "" ${ARGN})
if(NOT TARGET ${arg_APK_IN})
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
endif()
if(NOT TARGET ${arg_KEYSTORE})
message(FATAL_ERROR "APK_KEYSTORE (${APK_KEYSTORE}) must be a target providing a keystore")
endif()
if(NOT arg_OUTPUT)
string(REGEX REPLACE "[:-]+" "." arg_OUTPUT "${TARGET}")
if(NOT arg_OUTPUT MATCHES "\\.apk")
set(arg_OUTPUT "${arg_OUTPUT}.apk")
endif()
endif()
get_filename_component(apk_file "${arg_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(OUTPUT "${apk_file}"
COMMAND SdlAndroid::apksigner sign
--ks "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>"
--ks-pass pass:android --in "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" --out "${apk_file}"
DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>"
BYPRODUCTS "${apk_file}.idsig"
)
add_custom_target(${TARGET} DEPENDS "${apk_file}")
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
endfunction()

View File

@@ -0,0 +1,74 @@
#[=======================================================================[
This CMake script is meant to be used in CMake script mode (cmake -P).
It wraps commands that communicate with an actual Android device.
Because
#]=======================================================================]
cmake_minimum_required(VERSION 3.16)
if(NOT CMAKE_SCRIPT_MODE_FILE)
message(FATAL_ERROR "This file can only be used in CMake script mode")
endif()
if(NOT ADB)
set(ADB "adb")
endif()
if(NOT ACTION)
message(FATAL_ERROR "Missing ACTION argument")
endif()
if(ACTION STREQUAL "uninstall")
# The uninstall action attempts to uninstall all packages. All failures are ignored.
foreach(package IN LISTS PACKAGES)
message("Uninstalling ${package} ...")
execute_process(
COMMAND ${ADB} uninstall ${package}
RESULT_VARIABLE res
)
message("... result=${res}")
endforeach()
elseif(ACTION STREQUAL "install")
# The install actions attempts to install APK's to an Android device using adb. Failures are ignored.
set(failed_apks "")
foreach(apk IN LISTS APKS)
message("Installing ${apk} ...")
execute_process(
COMMAND ${ADB} install -d -r --streaming ${apk}
RESULT_VARIABLE res
)
message("... result=${res}")
if(NOT res EQUAL 0)
list(APPEND failed_apks ${apk})
endif()
endforeach()
if(failed_apks)
message(FATAL_ERROR "Failed to install ${failed_apks}")
endif()
elseif(ACTION STREQUAL "build-install-run")
if(NOT EXECUTABLES)
message(FATAL_ERROR "Missing EXECUTABLES (don't know what executables to build/install and start")
endif()
if(NOT BUILD_FOLDER)
message(FATAL_ERROR "Missing BUILD_FOLDER (don't know where to build the APK's")
endif()
set(install_targets "")
foreach(executable IN LISTS EXECUTABLES)
list(APPEND install_targets "install-${executable}")
endforeach()
execute_process(
COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target ${install_targets}
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR "Failed to install APK(s) for ${EXECUTABLES}")
endif()
list(GET EXECUTABLES 0 start_executable)
execute_process(
COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target start-${start_executable}
RESULT_VARIABLE res
)
else()
message(FATAL_ERROR "Unknown ACTION=${ACTION}")
endif()

View File

@@ -0,0 +1,17 @@
if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"")
endif()
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
endforeach()

418
external/SDL/cmake/macros.cmake vendored Normal file
View File

@@ -0,0 +1,418 @@
macro(add_to_alloptions _NEWNAME)
list(APPEND ALLOPTIONS ${_NEWNAME})
endmacro()
macro(set_option _NAME _DESC)
add_to_alloptions(${_NAME})
if(${ARGC} EQUAL 3)
set(_DEFLT ${ARGV2})
else()
set(_DEFLT OFF)
endif()
option(${_NAME} ${_DESC} ${_DEFLT})
endmacro()
macro(dep_option _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
add_to_alloptions("${_NAME}")
cmake_dependent_option("${_NAME}" "${_DESC}" "${_DEFLT}" "${_DEPTEST}" "${_FAILDFLT}")
endmacro()
macro(option_string _NAME _DESC _VALUE)
add_to_alloptions(${_NAME})
set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
set(HAVE_${_NAME} ${_VALUE})
ENDMACRO()
macro(message_bool_option _NAME _VALUE)
set(_PAD "\t")
if(${ARGC} EQUAL 3)
set(_PAD ${ARGV2})
endif()
if(${_VALUE})
message(STATUS " ${_NAME}:${_PAD}ON")
else()
message(STATUS " ${_NAME}:${_PAD}OFF")
endif()
endmacro()
macro(message_tested_option _NAME)
set(_REQVALUE ${${_NAME}})
set(_PAD " ")
if(${ARGC} EQUAL 2)
set(_PAD ${ARGV1})
endif()
string(SUBSTRING "${_NAME}" 0 4 _NAMESTART)
if(_NAMESTART STREQUAL "SDL_")
string(SUBSTRING "${_NAME}" 4 -1 _STRIPPEDNAME)
else()
set(_STRIPPEDNAME "${_NAME}")
endif()
if(NOT HAVE_${_STRIPPEDNAME})
set(HAVE_${_STRIPPEDNAME} OFF)
elseif("${HAVE_${_STRIPPEDNAME}}" MATCHES "1|TRUE|YES|Y")
set(HAVE_${_STRIPPEDNAME} ON)
endif()
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
endmacro()
function(find_stringlength_longest_item inList outLength)
set(maxLength 0)
foreach(item IN LISTS ${inList})
string(LENGTH "${item}" slen)
if(slen GREATER maxLength)
set(maxLength ${slen})
endif()
endforeach()
set("${outLength}" ${maxLength} PARENT_SCOPE)
endfunction()
function(message_dictlist inList)
find_stringlength_longest_item(${inList} maxLength)
foreach(name IN LISTS ${inList})
# Get the padding
string(LENGTH ${name} nameLength)
math(EXPR padLength "(${maxLength} + 1) - ${nameLength}")
string(RANDOM LENGTH ${padLength} ALPHABET " " padding)
message_tested_option(${name} ${padding})
endforeach()
endfunction()
if(APPLE)
include(CheckOBJCSourceCompiles)
enable_language(OBJC)
endif()
function(SDL_detect_linker)
if(CMAKE_VERSION VERSION_LESS 3.29)
if(NOT DEFINED SDL_CMAKE_C_COMPILER_LINKER_ID)
execute_process(COMMAND ${CMAKE_LINKER} -v OUTPUT_VARIABLE LINKER_OUTPUT ERROR_VARIABLE LINKER_OUTPUT)
string(REGEX REPLACE "[\r\n]" " " LINKER_OUTPUT "${LINKER_OUTPUT}")
if(LINKER_OUTPUT MATCHES ".*Microsoft.*")
set(linker MSVC)
else()
set(linker GNUlike)
endif()
message(STATUS "Linker identification: ${linker}")
set(SDL_CMAKE_C_COMPILER_LINKER_ID "${linker}" CACHE STRING "Linker identification")
mark_as_advanced(SDL_CMAKE_C_COMPILER_LINKER_ID)
endif()
set(CMAKE_C_COMPILER_LINKER_ID "${SDL_CMAKE_C_COMPILER_LINKER_ID}" PARENT_SCOPE)
endif()
endfunction()
function(read_absolute_symlink DEST PATH)
file(READ_SYMLINK "${PATH}" p)
if(NOT IS_ABSOLUTE "${p}")
get_filename_component(pdir "${PATH}" DIRECTORY)
set(p "${pdir}/${p}")
endif()
get_filename_component(p "${p}" ABSOLUTE)
set("${DEST}" "${p}" PARENT_SCOPE)
endfunction()
function(win32_implib_identify_dll DEST IMPLIB)
cmake_parse_arguments(ARGS "NOTFATAL" "" "" ${ARGN})
if(CMAKE_DLLTOOL)
execute_process(
COMMAND "${CMAKE_DLLTOOL}" --identify "${IMPLIB}"
RESULT_VARIABLE retcode
OUTPUT_VARIABLE stdout
ERROR_VARIABLE stderr)
if(NOT retcode EQUAL 0)
if(NOT ARGS_NOTFATAL)
message(FATAL_ERROR "${CMAKE_DLLTOOL} failed.")
else()
set("${DEST}" "${DEST}-NOTFOUND" PARENT_SCOPE)
return()
endif()
endif()
string(STRIP "${stdout}" result)
set(${DEST} "${result}" PARENT_SCOPE)
elseif(MSVC)
get_filename_component(CMAKE_C_COMPILER_DIRECTORY "${CMAKE_C_COMPILER}" DIRECTORY CACHE)
find_program(CMAKE_DUMPBIN NAMES dumpbin PATHS "${CMAKE_C_COMPILER_DIRECTORY}")
if(CMAKE_DUMPBIN)
execute_process(
COMMAND "${CMAKE_DUMPBIN}" "-headers" "${IMPLIB}"
RESULT_VARIABLE retcode
OUTPUT_VARIABLE stdout
ERROR_VARIABLE stderr)
if(NOT retcode EQUAL 0)
if(NOT ARGS_NOTFATAL)
message(FATAL_ERROR "dumpbin failed.")
else()
set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE)
return()
endif()
endif()
string(REGEX MATCH "DLL name[ ]+:[ ]+([^\n]+)\n" match "${stdout}")
if(NOT match)
if(NOT ARGS_NOTFATAL)
message(FATAL_ERROR "dumpbin did not find any associated dll for ${IMPLIB}.")
else()
set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE)
return()
endif()
endif()
set(result "${CMAKE_MATCH_1}")
set(${DEST} "${result}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Cannot find dumpbin, please set CMAKE_DUMPBIN cmake variable")
endif()
else()
if(NOT ARGS_NOTFATAL)
message(FATAL_ERROR "Don't know how to identify dll from import library. Set CMAKE_DLLTOOL (for mingw) or CMAKE_DUMPBIN (for MSVC)")
else()
set(${DEST} "${DEST}-NOTFOUND")
endif()
endif()
endfunction()
function(get_actual_target)
set(dst "${ARGV0}")
set(target "${${dst}}")
set(input "${target}")
get_target_property(alias "${target}" ALIASED_TARGET)
while(alias)
set(target "${alias}")
get_target_property(alias "${target}" ALIASED_TARGET)
endwhile()
message(DEBUG "get_actual_target(\"${input}\") -> \"${target}\"")
set("${dst}" "${target}" PARENT_SCOPE)
endfunction()
function(target_get_dynamic_library DEST TARGET)
set(result)
get_actual_target(TARGET)
if(WIN32)
# Use the target dll of the import library
set(props_to_check IMPORTED_IMPLIB)
if(CMAKE_BUILD_TYPE)
list(APPEND props_to_check IMPORTED_IMPLIB_${CMAKE_BUILD_TYPE})
endif()
list(APPEND props_to_check IMPORTED_LOCATION)
if(CMAKE_BUILD_TYPE)
list(APPEND props_to_check IMPORTED_LOCATION_${CMAKE_BUILD_TYPE})
endif()
foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
list(APPEND props_to_check IMPORTED_IMPLIB_${config_type})
list(APPEND props_to_check IMPORTED_LOCATION_${config_type})
endforeach()
foreach(prop_to_check ${props_to_check})
if(NOT result)
get_target_property(propvalue "${TARGET}" ${prop_to_check})
if(propvalue AND EXISTS "${propvalue}")
win32_implib_identify_dll(result "${propvalue}" NOTFATAL)
endif()
endif()
endforeach()
else()
# 1. find the target library a file might be symbolic linking to
# 2. find all other files in the same folder that symbolic link to it
# 3. sort all these files, and select the 1st item on Linux, and last on macOS
set(location_properties IMPORTED_LOCATION)
if(CMAKE_BUILD_TYPE)
list(APPEND location_properties IMPORTED_LOCATION_${CMAKE_BUILD_TYPE})
endif()
foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
list(APPEND location_properties IMPORTED_LOCATION_${config_type})
endforeach()
if(APPLE)
set(valid_shared_library_regex "\\.[0-9]+\\.dylib$")
else()
set(valid_shared_library_regex "\\.so\\.([0-9.]+)?[0-9]")
endif()
foreach(location_property ${location_properties})
if(NOT result)
get_target_property(library_path "${TARGET}" ${location_property})
message(DEBUG "get_target_property(${TARGET} ${location_property}) -> ${library_path}")
if(EXISTS "${library_path}")
get_filename_component(library_path "${library_path}" ABSOLUTE)
while (IS_SYMLINK "${library_path}")
read_absolute_symlink(library_path "${library_path}")
endwhile()
message(DEBUG "${TARGET} -> ${library_path}")
get_filename_component(libdir "${library_path}" DIRECTORY)
file(GLOB subfiles "${libdir}/*")
set(similar_files "${library_path}")
foreach(subfile ${subfiles})
if(IS_SYMLINK "${subfile}")
read_absolute_symlink(subfile_target "${subfile}")
while(IS_SYMLINK "${subfile_target}")
read_absolute_symlink(subfile_target "${subfile_target}")
endwhile()
get_filename_component(subfile_target "${subfile_target}" ABSOLUTE)
if(subfile_target STREQUAL library_path AND subfile MATCHES "${valid_shared_library_regex}")
list(APPEND similar_files "${subfile}")
endif()
endif()
endforeach()
list(SORT similar_files)
message(DEBUG "files that are similar to \"${library_path}\"=${similar_files}")
if(APPLE)
list(REVERSE similar_files)
endif()
list(GET similar_files 0 item)
get_filename_component(result "${item}" NAME)
endif()
endif()
endforeach()
endif()
if(result)
string(TOLOWER "${result}" result_lower)
if(WIN32 OR OS2)
if(NOT result_lower MATCHES ".*dll")
message(FATAL_ERROR "\"${result}\" is not a .dll library")
endif()
elseif(APPLE)
if(NOT result_lower MATCHES ".*dylib.*")
message(FATAL_ERROR "\"${result}\" is not a .dylib shared library")
endif()
else()
if(NOT result_lower MATCHES ".*so.*")
message(FATAL_ERROR "\"${result}\" is not a .so shared library")
endif()
endif()
else()
get_target_property(target_type ${TARGET} TYPE)
if(target_type MATCHES "SHARED_LIBRARY|MODULE_LIBRARY")
# OK
elseif(target_type MATCHES "STATIC_LIBRARY|OBJECT_LIBRARY|INTERFACE_LIBRARY|EXECUTABLE")
message(SEND_ERROR "${TARGET} is not a shared library, but has type=${target_type}")
else()
message(WARNING "Unable to extract dynamic library from target=${TARGET}, type=${target_type}.")
endif()
# TARGET_SONAME_FILE is not allowed for DLL target platforms.
if(WIN32)
set(result "$<TARGET_FILE_NAME:${TARGET}>")
else()
set(result "$<TARGET_SONAME_FILE_NAME:${TARGET}>")
endif()
endif()
set(${DEST} ${result} PARENT_SCOPE)
endfunction()
function(check_linker_supports_version_file VAR)
SDL_detect_linker()
if(CMAKE_C_COMPILER_LINKER_ID MATCHES "^(MSVC)$")
set(LINKER_SUPPORTS_VERSION_SCRIPT FALSE)
else()
cmake_push_check_state(RESET)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n")
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/dummy.sym")
check_c_source_compiles("int func(void) {return 0;} int main(int argc,char*argv[]){(void)argc;(void)argv;return func();}" LINKER_SUPPORTS_VERSION_SCRIPT FAIL_REGEX "(unsupported|syntax error|unrecognized option)")
cmake_pop_check_state()
endif()
set(${VAR} "${LINKER_SUPPORTS_VERSION_SCRIPT}" PARENT_SCOPE)
endfunction()
if(CMAKE_VERSION VERSION_LESS 3.18)
function(check_linker_flag LANG FLAG VAR)
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${FLAG})
if(LANG STREQUAL "C")
include(CheckCSourceCompiles)
check_c_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")
elseif(LANG STREQUAL "CXX")
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")
else()
message(FATAL_ERROR "Unsupported language: ${LANG}")
endif()
cmake_pop_check_state()
endfunction()
else()
cmake_policy(SET CMP0057 NEW) # Support new if() IN_LIST operator. (used inside check_linker_flag, used in CMake 3.18)
include(CheckLinkerFlag)
endif()
if(APPLE)
check_language(OBJC)
if(NOT CMAKE_OBJC_COMPILER)
message(WARNING "Cannot find working OBJC compiler.")
endif()
endif()
function(SDL_PrintSummary)
##### Info output #####
message(STATUS "")
message(STATUS "SDL3 was configured with the following options:")
message(STATUS "")
message(STATUS "Platform: ${CMAKE_SYSTEM}")
message(STATUS "64-bit: ${ARCH_64}")
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Revision: ${SDL_REVISION}")
message(STATUS "Vendor: ${SDL_VENDOR_INFO}")
message(STATUS "")
message(STATUS "Subsystems:")
find_stringlength_longest_item(SDL_SUBSYSTEMS maxLength)
foreach(_SUB IN LISTS SDL_SUBSYSTEMS)
string(LENGTH ${_SUB} _SUBLEN)
math(EXPR _PADLEN "(${maxLength} + 1) - ${_SUBLEN}")
string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
string(TOUPPER ${_SUB} _OPT)
message_bool_option(${_SUB} SDL_${_OPT} ${_PADDING})
endforeach()
message(STATUS "")
message(STATUS "Options:")
list(SORT ALLOPTIONS)
message_dictlist(ALLOPTIONS)
message(STATUS "")
message(STATUS " Build Shared Library: ${SDL_SHARED}")
message(STATUS " Build Static Library: ${SDL_STATIC}")
if(SDL_STATIC)
message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
endif()
if(APPLE)
message(STATUS " Build libraries as Apple Framework: ${SDL_FRAMEWORK}")
endif()
message(STATUS "")
if(UNIX)
message(STATUS "If something was not detected, although the libraries")
message(STATUS "were installed, then make sure you have set the")
message(STATUS "CMAKE_C_FLAGS and CMAKE_PREFIX_PATH CMake variables correctly.")
message(STATUS "")
endif()
if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
message(STATUS "SDL is being built with ARM SIMD optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMSIMD=OFF")
message(STATUS "")
endif()
if(WARN_ABOUT_ARM_NEON_ASM_MIT)
message(STATUS "SDL is being built with ARM NEON optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMNEON=OFF")
message(STATUS "")
endif()
if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN))
if(NOT (HAVE_X11 OR HAVE_WAYLAND))
message(STATUS "SDL is being built without a X11 or wayland video driver.")
message(STATUS "The library will not be able to create windows on most unix environments.")
message(STATUS "")
endif()
endif()
endfunction()
function(SDL_install_pdb TARGET DIRECTORY)
get_property(type TARGET ${TARGET} PROPERTY TYPE)
if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$")
install(FILES $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL)
elseif(type STREQUAL "STATIC_LIBRARY")
# FIXME: Use $<TARGET_COMPILE_PDB_FILE:${TARGET} once it becomes available (https://gitlab.kitware.com/cmake/cmake/-/issues/25244)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${TARGET}.pdb\")")
else()
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${TARGET}.pdb\")")
endif()
endif()
endfunction()

13
external/SDL/cmake/sdl3.pc.in vendored Normal file
View File

@@ -0,0 +1,13 @@
prefix=@SDL_PKGCONFIG_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: sdl3
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
URL: https://www.libsdl.org/
Version: @PROJECT_VERSION@
Requires.private: @SDL_PC_PRIVATE_REQUIRES@
Conflicts:
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_PC_LIBS@ @SDL_PC_SECTION_LIBS_PRIVATE@ @SDL_PC_STATIC_LIBS@
Cflags: -I${includedir} @SDL_PC_CFLAGS@

1242
external/SDL/cmake/sdlchecks.cmake vendored Normal file

File diff suppressed because it is too large Load Diff

162
external/SDL/cmake/sdlcompilers.cmake vendored Normal file
View File

@@ -0,0 +1,162 @@
macro(SDL_DetectCompiler)
set(USE_CLANG FALSE)
set(USE_GCC FALSE)
set(USE_INTELCC FALSE)
set(USE_QCC FALSE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang|IntelLLVM")
set(USE_CLANG TRUE)
# Visual Studio 2019 v16.2 added support for Clang/LLVM.
# Check if a Visual Studio project is being generated with the Clang toolset.
if(MSVC)
set(MSVC_CLANG TRUE)
endif()
elseif(CMAKE_COMPILER_IS_GNUCC)
set(USE_GCC TRUE)
elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
set(USE_INTELCC TRUE)
elseif(CMAKE_C_COMPILER_ID MATCHES "QCC")
set(USE_QCC TRUE)
endif()
endmacro()
function(sdl_target_compile_option_all_languages TARGET OPTION)
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:${OPTION}>")
if(CMAKE_OBJC_COMPILER)
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:OBJC>:${OPTION}>")
endif()
endfunction()
function(SDL_AddCommonCompilerFlags TARGET)
option(SDL_WERROR "Enable -Werror" OFF)
get_property(TARGET_TYPE TARGET "${TARGET}" PROPERTY TYPE)
if(MSVC)
cmake_push_check_state()
check_c_compiler_flag("/W3" COMPILER_SUPPORTS_W3)
if(COMPILER_SUPPORTS_W3)
target_compile_options(${TARGET} PRIVATE "/W3")
endif()
cmake_pop_check_state()
endif()
if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC)
if(MINGW)
# See if GCC's -gdwarf-4 is supported
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377 for why this is needed on Windows
cmake_push_check_state()
check_c_compiler_flag("-gdwarf-4" HAVE_GDWARF_4)
if(HAVE_GDWARF_4)
target_compile_options(${TARGET} PRIVATE "-gdwarf-4")
endif()
cmake_pop_check_state()
endif()
# Check for -Wall first, so later things can override pieces of it.
# Note: clang-cl treats -Wall as -Weverything (which is very loud),
# /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough.
check_c_compiler_flag(-Wall HAVE_GCC_WALL)
if(MSVC_CLANG)
target_compile_options(${TARGET} PRIVATE "/W3")
elseif(HAVE_GCC_WALL)
sdl_target_compile_option_all_languages(${TARGET} "-Wall")
if(HAIKU)
sdl_target_compile_option_all_languages(${TARGET} "-Wno-multichar")
endif()
endif()
check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF)
if(HAVE_GCC_WUNDEF)
sdl_target_compile_option_all_languages(${TARGET} "-Wundef")
endif()
check_c_compiler_flag(-Wfloat-conversion HAVE_GCC_WFLOAT_CONVERSION)
if(HAVE_GCC_WFLOAT_CONVERSION)
sdl_target_compile_option_all_languages(${TARGET} "-Wfloat-conversion")
endif()
check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING)
if(HAVE_GCC_NO_STRICT_ALIASING)
sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing")
endif()
check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)
if(HAVE_GCC_WDOCUMENTATION)
if(SDL_WERROR)
check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION)
if(HAVE_GCC_WERROR_DOCUMENTATION)
sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation")
endif()
endif()
sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation")
endif()
check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
if(SDL_WERROR)
check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation-unknown-command")
endif()
endif()
sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation-unknown-command")
endif()
check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS)
if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
sdl_target_compile_option_all_languages(${TARGET} "-fcomment-block-commands=threadsafety")
else()
check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
sdl_target_compile_option_all_languages(${TARGET} "/clang:-fcomment-block-commands=threadsafety")
endif()
endif()
check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
if(HAVE_GCC_WSHADOW)
sdl_target_compile_option_all_languages(${TARGET} "-Wshadow")
endif()
check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
sdl_target_compile_option_all_languages(${TARGET} "-Wno-unused-local-typedefs")
endif()
check_c_compiler_flag(-Wimplicit-fallthrough HAVE_GCC_WIMPLICIT_FALLTHROUGH)
if(HAVE_GCC_WIMPLICIT_FALLTHROUGH)
sdl_target_compile_option_all_languages(${TARGET} "-Wimplicit-fallthrough")
endif()
endif()
if(SDL_WERROR)
if(MSVC)
check_c_compiler_flag(/WX HAVE_WX)
if(HAVE_WX)
target_compile_options(${TARGET} PRIVATE "/WX")
endif()
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QNX)
check_c_compiler_flag(-Werror HAVE_WERROR)
if(HAVE_WERROR)
sdl_target_compile_option_all_languages(${TARGET} "-Werror")
endif()
if(TARGET_TYPE STREQUAL "SHARED_LIBRARY")
check_linker_flag(C "-Wl,--no-undefined-version" LINKER_SUPPORTS_NO_UNDEFINED_VERSION)
if(LINKER_SUPPORTS_NO_UNDEFINED_VERSION)
target_link_options(${TARGET} PRIVATE "-Wl,--no-undefined-version")
endif()
endif()
endif()
endif()
if(USE_CLANG)
check_c_compiler_flag("-fcolor-diagnostics" COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
if(COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
sdl_target_compile_option_all_languages(${TARGET} "-fcolor-diagnostics")
endif()
else()
check_c_compiler_flag("-fdiagnostics-color=always" COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
if(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
sdl_target_compile_option_all_languages(${TARGET} "-fdiagnostics-color=always")
endif()
endif()
endfunction()

148
external/SDL/cmake/sdlcpu.cmake vendored Normal file
View File

@@ -0,0 +1,148 @@
function(SDL_DetectTargetCPUArchitectures DETECTED_ARCHS)
set(known_archs EMSCRIPTEN ARM32 ARM64 ARM64EC LOONGARCH64 POWERPC32 POWERPC64 X86 X64)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
foreach(known_arch IN LISTS known_archs)
set(SDL_CPU_${known_arch} "0")
endforeach()
set(detected_archs)
foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES)
if(osx_arch STREQUAL "x86_64")
set(SDL_CPU_X64 "1")
list(APPEND detected_archs "X64")
elseif(osx_arch STREQUAL "arm64")
set(SDL_CPU_ARM64 "1")
list(APPEND detected_archs "ARM64")
endif()
endforeach()
set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE)
return()
endif()
set(detected_archs)
foreach(known_arch IN LISTS known_archs)
if(SDL_CPU_${known_arch})
list(APPEND detected_archs "${known_arch}")
endif()
endforeach()
if(detected_archs)
set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE)
return()
endif()
set(arch_check_ARM32 "defined(__arm__) || defined(_M_ARM)")
set(arch_check_ARM64 "defined(__aarch64__) || defined(_M_ARM64)")
set(arch_check_ARM64EC "defined(_M_ARM64EC)")
set(arch_check_EMSCRIPTEN "defined(__EMSCRIPTEN__)")
set(arch_check_LOONGARCH64 "defined(__loongarch64)")
set(arch_check_POWERPC32 "(defined(__PPC__) || defined(__powerpc__)) && !defined(__powerpc64__)")
set(arch_check_POWERPC64 "defined(__PPC64__) || defined(__powerpc64__)")
set(arch_check_X86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)")
set(arch_check_X64 "(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)")
set(src_vars "")
set(src_main "")
foreach(known_arch IN LISTS known_archs)
set(detected_${known_arch} "0")
string(APPEND src_vars "
#if ${arch_check_${known_arch}}
#define ARCH_${known_arch} \"1\"
#else
#define ARCH_${known_arch} \"0\"
#endif
const char *arch_${known_arch} = \"INFO<${known_arch}=\" ARCH_${known_arch} \">\";
")
string(APPEND src_main "
result += arch_${known_arch}[argc];")
endforeach()
set(src_arch_detect "${src_vars}
int main(int argc, char *argv[]) {
(void)argv;
int result = 0;
${src_main}
return result;
}")
set(path_src_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch.c")
file(WRITE "${path_src_arch_detect}" "${src_arch_detect}")
set(path_dir_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch")
set(path_bin_arch_detect "${path_dir_arch_detect}/bin")
set(detected_archs)
set(msg "Detecting Target CPU Architecture")
message(STATUS "${msg}")
include(CMakePushCheckState)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
cmake_push_check_state(RESET)
try_compile(SDL_CPU_CHECK_ALL
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch"
SOURCES "${path_src_arch_detect}"
COPY_FILE "${path_bin_arch_detect}"
)
cmake_pop_check_state()
if(NOT SDL_CPU_CHECK_ALL)
message(STATUS "${msg} - <ERROR>")
message(WARNING "Failed to compile source detecting the target CPU architecture")
else()
set(re "INFO<([A-Z0-9]+)=([01])>")
file(STRINGS "${path_bin_arch_detect}" infos REGEX "${re}")
foreach(info_arch_01 IN LISTS infos)
string(REGEX MATCH "${re}" A "${info_arch_01}")
if(NOT "${CMAKE_MATCH_1}" IN_LIST known_archs)
message(WARNING "Unknown architecture: \"${CMAKE_MATCH_1}\"")
continue()
endif()
set(arch "${CMAKE_MATCH_1}")
set(arch_01 "${CMAKE_MATCH_2}")
set(detected_${arch} "${arch_01}")
endforeach()
foreach(known_arch IN LISTS known_archs)
if(detected_${known_arch})
list(APPEND detected_archs ${known_arch})
endif()
endforeach()
endif()
if(detected_archs)
foreach(known_arch IN LISTS known_archs)
set("SDL_CPU_${known_arch}" "${detected_${known_arch}}" CACHE BOOL "Detected architecture ${known_arch}")
endforeach()
message(STATUS "${msg} - ${detected_archs}")
else()
include(CheckCSourceCompiles)
cmake_push_check_state(RESET)
foreach(known_arch IN LISTS known_archs)
if(NOT detected_archs)
set(cache_variable "SDL_CPU_${known_arch}")
set(test_src "
int main(int argc, char *argv[]) {
#if ${arch_check_${known_arch}}
return 0;
#else
choke
#endif
}
")
check_c_source_compiles("${test_src}" "${cache_variable}")
if(${cache_variable})
set(SDL_CPU_${known_arch} "1" CACHE BOOL "Detected architecture ${known_arch}")
set(detected_archs ${known_arch})
else()
set(SDL_CPU_${known_arch} "0" CACHE BOOL "Detected architecture ${known_arch}")
endif()
endif()
endforeach()
cmake_pop_check_state()
endif()
set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE)
endfunction()

68
external/SDL/cmake/sdlmanpages.cmake vendored Normal file
View File

@@ -0,0 +1,68 @@
include(CMakeParseArguments)
include(GNUInstallDirs)
function(SDL_generate_manpages)
cmake_parse_arguments(ARG "" "RESULT_VARIABLE;NAME;BUILD_DOCDIR;HEADERS_DIR;SOURCE_DIR;SYMBOL;OPTION_FILE;WIKIHEADERS_PL_PATH;REVISION" "" ${ARGN})
set(wikiheaders_extra_args)
if(NOT ARG_NAME)
set(ARG_NAME "${PROJECT_NAME}")
endif()
if(NOT ARG_SOURCE_DIR)
set(ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(NOT ARG_OPTION_FILE)
set(ARG_OPTION_FILE "${PROJECT_SOURCE_DIR}/.wikiheaders-options")
endif()
if(NOT ARG_HEADERS_DIR)
message(FATAL_ERROR "Missing required HEADERS_DIR argument")
endif()
# FIXME: get rid of SYMBOL and let the perl script figure out the dependencies
if(NOT ARG_SYMBOL)
message(FATAL_ERROR "Missing required SYMBOL argument")
endif()
if(ARG_REVISION)
list(APPEND wikiheaders_extra_args "--rev=${ARG_REVISION}")
endif()
if(NOT ARG_BUILD_DOCDIR)
set(ARG_BUILD_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/docs")
endif()
set(BUILD_WIKIDIR "${ARG_BUILD_DOCDIR}/wiki")
set(BUILD_MANDIR "${ARG_BUILD_DOCDIR}/man")
find_package(Perl)
file(GLOB HEADER_FILES "${ARG_HEADERS_DIR}/*.h")
set(result FALSE)
if(PERL_FOUND AND EXISTS "${ARG_WIKIHEADERS_PL_PATH}")
add_custom_command(
OUTPUT "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${BUILD_WIKIDIR}"
COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" --copy-to-wiki ${wikiheaders_extra_args}
DEPENDS ${HEADER_FILES} "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}"
COMMENT "Generating ${ARG_NAME} wiki markdown files"
)
add_custom_command(
OUTPUT "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3"
COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" "--manpath=${BUILD_MANDIR}" --copy-to-manpages ${wikiheaders_extra_args}
DEPENDS "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}"
COMMENT "Generating ${ARG_NAME} man pages"
)
add_custom_target(${ARG_NAME}-docs ALL DEPENDS "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3")
install(DIRECTORY "${BUILD_MANDIR}/" DESTINATION "${CMAKE_INSTALL_MANDIR}")
set(result TRUE)
endif()
if(ARG_RESULT_VARIABLE)
set(${ARG_RESULT_VARIABLE} ${result} PARENT_SCOPE)
endif()
endfunction()

70
external/SDL/cmake/sdlplatform.cmake vendored Normal file
View File

@@ -0,0 +1,70 @@
function(SDL_DetectCMakePlatform)
set(sdl_cmake_platform )
if(WIN32)
set(sdl_cmake_platform Windows)
elseif(PSP)
set(sdl_cmake_platform psp)
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*")
set(sdl_cmake_platform macOS)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
set(sdl_cmake_platform tvOS)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
set(sdl_cmake_platform iOS)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*watchOS.*")
set(sdl_cmake_platform watchOS)
elseif (CMAKE_SYSTEM_NAME MATCHES "visionOS")
set(sdl_cmake_platform visionOS)
else()
message(WARNING "Unknown Apple platform: \"${CMAKE_SYSTEM_NAME}\"")
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(sdl_cmake_platform Haiku)
elseif(NINTENDO_3DS)
set(sdl_cmake_platform n3ds)
elseif(PS2)
set(sdl_cmake_platform ps2)
elseif(VITA)
set(sdl_cmake_platform Vita)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(sdl_cmake_platform Linux)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(sdl_cmake_platform FreeBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(sdl_cmake_platform NetBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(sdl_cmake_platform OpenBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(sdl_cmake_platform GNU)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(sdl_cmake_platform BSDi)
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(sdl_cmake_platform FreeBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(sdl_cmake_platform SYSV5)
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
set(sdl_cmake_platform Solaris)
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(sdl_cmake_platform HPUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(sdl_cmake_platform AIX)
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(sdl_cmake_platform Minix)
elseif(CMAKE_SYSTEM_NAME MATCHES "Android.*")
set(sdl_cmake_platform Android)
elseif(CMAKE_SYSTEM_NAME MATCHES "Emscripten.*")
set(sdl_cmake_platform Emscripten)
elseif(CMAKE_SYSTEM_NAME MATCHES "QNX.*")
set(sdl_cmake_platform QNX)
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
message(FATAL_ERROR "BeOS support has been removed as of SDL 2.0.2.")
endif()
if(sdl_cmake_platform)
string(TOUPPER "${sdl_cmake_platform}" _upper_platform)
set("${_upper_platform}" TRUE PARENT_SCOPE)
else()
set(sdl_cmake_platform "unknown")
endif()
set(SDL_CMAKE_PLATFORM "${sdl_cmake_platform}" PARENT_SCOPE)
endfunction()

371
external/SDL/cmake/sdltargets.cmake vendored Normal file
View File

@@ -0,0 +1,371 @@
add_library(SDL3-collector INTERFACE)
add_library(SDL3_test-collector INTERFACE)
# Use sdl_glob_sources to add glob sources to SDL3-shared, to SDL3-static, or to both.
function(sdl_glob_sources)
cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN})
file(GLOB shared_sources ${ARGS_SHARED})
file(GLOB static_sources ${ARGS_STATIC})
file(GLOB both_sources ${ARGS_UNPARSED_ARGUMENTS})
if(TARGET SDL3-shared)
target_sources(SDL3-shared PRIVATE ${shared_sources} ${both_sources})
endif()
if(TARGET SDL3-static)
target_sources(SDL3-static PRIVATE ${static_sources} ${both_sources})
endif()
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${shared_sources} ${static_sources} ${both_sources})
endfunction()
# Use sdl_sources to add sources to SDL3-shared, to SDL3-static, or to both.
function(sdl_sources)
cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN})
if(TARGET SDL3-shared)
target_sources(SDL3-shared PRIVATE ${ARGS_SHARED} ${ARGS_UNPARSED_ARGUMENTS})
endif()
if(TARGET SDL3-static)
target_sources(SDL3-static PRIVATE ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS})
endif()
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${ARGS_SHARED} ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS})
endfunction()
# Use sdl_generic_link_dependency to describe a private dependency. All options are optional.
# Users should use sdl_link_dependency and sdl_test_link_dependency instead
# - SHARED_TARGETS: shared targets to add this dependency to
# - STATIC_TARGETS: static targets to add this dependency to
# - COLLECTOR: target that stores information, for pc and Config.cmake generation.
# - INCLUDES: the include directories of the dependency
# - PKG_CONFIG_PREFIX: name of the prefix, when using the functions of FindPkgConfig
# - PKG_CONFIG_SPECS: pkg-config spec, used as argument for the functions of FindPkgConfig
# - PKG_CONFIG_LIBS: libs that will only end up in the Libs.private of the .pc file
# - PKG_CONFIG_LINK_OPTIONS: ldflags that will only end up in the Libs.private of sdl3.pc
# - CMAKE_MODULE: CMake module name of the dependency, used as argument of find_package
# - LIBS: list of libraries to link to (cmake and pkg-config)
# - LINK_OPTIONS: list of link options (also used in pc file, unless PKG_CONFIG_LINK_OPTION is used)
function(sdl_generic_link_dependency ID)
cmake_parse_arguments(ARGS "" "COLLECTOR" "SHARED_TARGETS;STATIC_TARGETS;INCLUDES;PKG_CONFIG_LINK_OPTIONS;PKG_CONFIG_LIBS;PKG_CONFIG_PREFIX;PKG_CONFIG_SPECS;CMAKE_MODULE;LIBS;LINK_OPTIONS" ${ARGN})
foreach(target IN LISTS ARGS_SHARED_TARGETS)
if(TARGET ${target})
target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES})
target_link_libraries(${target} PRIVATE ${ARGS_LIBS})
target_link_options(${target} PRIVATE ${ARGS_LINK_OPTIONS})
endif()
endforeach()
foreach(target IN LISTS ARGS_STATIC_TARGETS)
if(TARGET ${target})
target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES})
target_link_libraries(${target} PRIVATE ${ARGS_LIBS})
target_link_options(${target} INTERFACE ${ARGS_LINK_OPTIONS})
endif()
endforeach()
get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS)
if(NOT ID IN_LIST ids)
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_IDS ${ID})
endif()
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX ${ARGS_PKG_CONFIG_PREFIX})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS ${ARGS_PKG_CONFIG_SPECS})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS ${ARGS_PKG_CONFIG_LIBS})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS ${ARGS_PKG_CONFIG_LINK_OPTIONS})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS ${ARGS_LIBS})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS ${ARGS_LINK_OPTIONS})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE ${ARGS_CMAKE_MODULE})
set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES ${ARGS_INCLUDES})
endfunction()
function(sdl_link_dependency )
sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3-collector SHARED_TARGETS SDL3-shared STATIC_TARGETS SDL3-static)
endfunction()
function(sdl_test_link_dependency )
sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3_test-collector STATIC_TARGETS SDL3_test)
endfunction()
macro(_get_ARGS_visibility)
set(_conflict FALSE)
set(visibility)
if(ARGS_PRIVATE)
set(visibility PRIVATE)
elseif(ARGS_PUBLIC)
if(visibility)
set(_conflict TRUE)
endif()
set(visibility PUBLIC)
elseif(ARGS_INTERFACE)
if(visibility)
set(_conflict TRUE)
endif()
set(visibility INTERFACE)
endif()
if(_conflict OR NOT visibility)
message(FATAL_ERROR "PRIVATE/PUBLIC/INTERFACE must be used exactly once")
endif()
unset(_conflict)
endmacro()
# Use sdl_link_dependency to add compile definitions to the SDL3 libraries.
function(sdl_compile_definitions)
cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN})
_get_ARGS_visibility()
if(TARGET SDL3-shared)
target_compile_definitions(SDL3-shared ${visibility} ${ARGS_UNPARSED_ARGUMENTS})
endif()
if(TARGET SDL3-static)
target_compile_definitions(SDL3-static ${visibility} ${ARGS_UNPARSED_ARGUMENTS})
endif()
if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE))
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "${ARGS_UNPARSED_ARGUMENTS}")
endif()
endfunction()
# Use sdl_link_dependency to add compile options to the SDL3 libraries.
function(sdl_compile_options)
cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN})
_get_ARGS_visibility()
set(escaped_opts ${ARGS_UNPARSED_ARGUMENTS})
if(ARGS_NO_EXPORT)
set(escaped_opts "$<BUILD_INTERFACE:${ARGS_UNPARSED_ARGUMENTS}>")
endif()
if(TARGET SDL3-shared)
target_compile_options(SDL3-shared ${visibility} ${escaped_opts})
endif()
if(TARGET SDL3-static)
target_compile_options(SDL3-static ${visibility} ${escaped_opts})
endif()
if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE))
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}")
endif()
endfunction()
# Use sdl_link_dependency to add include directories to the SDL3 libraries.
function(sdl_include_directories)
cmake_parse_arguments(ARGS "SYSTEM;BEFORE;AFTER;PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN})
set(system "")
if(ARGS_SYSTEM)
set(system "SYSTEM")
endif()
set(before_after )
if(ARGS_AFTER)
set(before_after "AFTER")
endif()
if(ARGS_BEFORE)
if(before_after)
message(FATAL_ERROR "before and after are exclusive options")
endif()
set(before_after "BEFORE")
endif()
_get_ARGS_visibility()
if(TARGET SDL3-shared)
target_include_directories(SDL3-shared ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS})
endif()
if(TARGET SDL3-static)
target_include_directories(SDL3-static ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS})
endif()
if(NOT NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE))
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ARGS_UNPARSED_ARGUMENTS}")
endif()
endfunction()
# Use sdl_link_dependency to add link directories to the SDL3 libraries.
function(sdl_link_directories)
if(TARGET SDL3-shared)
target_link_directories(SDL3-shared PRIVATE ${ARGN})
endif()
if(TARGET SDL3-static)
target_link_directories(SDL3-static INTERFACE ${ARGN})
endif()
endfunction()
# Use sdl_pc_link_options to add a link option, only visible in sdl3.pc
function(sdl_pc_link_options)
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS "${ARGN}")
endfunction()
# Use sdl_pc_link_options to add a link option only to SDL3-shared
function(sdl_shared_link_options)
if(TARGET SDL3-shared)
target_link_options(SDL3-shared PRIVATE ${ARGN})
endif()
endfunction()
# Return minimum list of custom SDL CMake modules, used for finding dependencies of SDL.
function(sdl_cmake_config_required_modules OUTPUT)
set(cmake_modules)
foreach(collector SDL3-collector SDL3_test-collector)
get_property(ids TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_IDS)
foreach(ID IN LISTS ids)
get_property(CMAKE_MODULE TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE)
if(CMAKE_MODULE)
if(EXISTS "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake")
list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake")
endif()
endif()
endforeach()
if(cmake_modules)
list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/PkgConfigHelper.cmake")
endif()
endforeach()
set(${OUTPUT} "${cmake_modules}" PARENT_SCOPE)
endfunction()
# Generate string for SDL3Config.cmake, finding all pkg-config dependencies of SDL3.
function(sdl_cmake_config_find_pkg_config_commands OUTPUT)
cmake_parse_arguments(ARGS "" "COLLECTOR;CONFIG_COMPONENT_FOUND_NAME" "" ${ARGN})
if(NOT ARGS_COLLECTOR OR NOT ARGS_CONFIG_COMPONENT_FOUND_NAME)
message(FATAL_ERROR "COLLECTOR AND CONFIG_COMPONENT_FOUND_NAME are required arguments")
endif()
get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS)
set(static_pkgconfig_deps_checks)
set(static_module_deps_checks)
set(cmake_modules_seen)
foreach(ID IN LISTS ids)
get_property(PKG_CONFIG_PREFIX TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX)
get_property(PKG_CONFIG_SPECS TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS)
get_property(CMAKE_MODULE TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE)
if(CMAKE_MODULE AND NOT CMAKE_MODULE IN_LIST cmake_modules_seen)
list(APPEND static_module_deps_checks
"find_package(${CMAKE_MODULE})"
"if(NOT ${CMAKE_MODULE}_FOUND)"
" set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)"
"endif()"
)
list(APPEND cmake_modules_seen ${CMAKE_MODULE})
endif()
if(PKG_CONFIG_PREFIX AND PKG_CONFIG_SPECS)
string(JOIN " " pkg_config_specs_str ${PKG_CONFIG_SPECS})
list(APPEND static_pkgconfig_deps_checks
" pkg_check_modules(${PKG_CONFIG_PREFIX} QUIET IMPORTED_TARGET ${pkg_config_specs_str})"
" if(NOT ${PKG_CONFIG_PREFIX}_FOUND)"
" set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)"
" endif()"
)
endif()
endforeach()
set(prefix " ")
set(static_module_deps_texts)
if(static_module_deps_checks)
set(static_module_deps_texts
[[set(_original_module_path "${CMAKE_MODULE_PATH}")]]
[[list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")]]
${static_module_deps_checks}
[[set(CMAKE_MODULE_PATH "${_original_module_path}")]]
[[unset(_original_module_path)]]
)
endif()
set(static_pkgconfig_deps_texts)
if(static_pkgconfig_deps_checks)
string(JOIN "\n${prefix}" static_deps_texts_str ${static_deps_texts})
list(APPEND static_pkgconfig_deps_texts
"find_package(PkgConfig)"
"if(PkgConfig_FOUND)"
${static_pkgconfig_deps_checks}
"else()"
" set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)"
"endif()"
)
endif()
set(text)
string(JOIN "\n${prefix}" text ${static_module_deps_texts} ${static_pkgconfig_deps_texts})
if(text)
set(text "${prefix}${text}")
endif()
set(${OUTPUT} "${text}" PARENT_SCOPE)
endfunction()
# Create sdl3.pc.
function(configure_sdl3_pc)
# Clean up variables for sdl3.pc
if(TARGET SDL3-shared)
set(SDL_PC_SECTION_LIBS_PRIVATE "\nLibs.private:")
else()
set(SDL_PC_SECTION_LIBS_PRIVATE "")
endif()
get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS)
set(private_requires)
set(private_libs)
set(private_ldflags)
foreach(ID IN LISTS ids)
get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE)
get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS)
get_property(PKG_CONFIG_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS)
get_property(PKG_CONFIG_LDFLAGS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS)
get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS)
get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS)
list(APPEND private_requires ${PKG_CONFIG_SPECS})
list(APPEND private_libs ${PKG_CONFIG_LIBS})
if(PKG_CONFIG_SPECS OR PKG_CONFIG_LIBS OR PKG_CONFIG_LDFLAGS)
list(APPEND private_ldflags ${PKG_CONFIG_LDFLAGS})
else()
list(APPEND private_ldflags ${LINK_OPTIONS})
if(NOT CMAKE_MODULE)
list(APPEND private_libs ${LIBS})
endif()
endif()
endforeach()
list(TRANSFORM private_libs PREPEND "-l")
set(SDL_PC_STATIC_LIBS ${private_ldflags} ${private_libs})
list(REMOVE_DUPLICATES SDL_PC_STATIC_LIBS)
string(JOIN " " SDL_PC_STATIC_LIBS ${SDL_PC_STATIC_LIBS})
string(JOIN " " SDL_PC_PRIVATE_REQUIRES ${private_requires})
string(REGEX REPLACE "(>=|>|=|<|<=)" [[ \1 ]] SDL_PC_PRIVATE_REQUIRES "${SDL_PC_PRIVATE_REQUIRES}")
get_property(interface_defines TARGET SDL3-collector PROPERTY INTERFACE_COMPILE_DEFINITIONS)
list(TRANSFORM interface_defines PREPEND "-D")
get_property(interface_includes TARGET SDL3-collector PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
list(TRANSFORM interface_includes PREPEND "-I")
set(SDL_PC_CFLAGS ${interface_defines} ${interface_includes})
string(JOIN " " SDL_PC_CFLAGS ${SDL_PC_CFLAGS})
get_property(SDL_PC_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS)
string(JOIN " " SDL_PC_LIBS ${SDL_PC_LIBS})
string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_STATIC_LIBS "${SDL_PC_STATIC_LIBS}")
if(NOT SDL_SHARED)
string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_LIBS "${SDL_PC_LIBS}")
endif()
if(TARGET SDL3-shared AND TARGET SDL3-static AND NOT sdl_static_libname STREQUAL "SDL3")
message(STATUS "\"pkg-config --static --libs sdl3\" will return invalid information")
endif()
# Calculate prefix relative to location of sdl3.pc
if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif()
file(RELATIVE_PATH SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${CMAKE_INSTALL_PREFIX}/${SDL_PKGCONFIG_INSTALLDIR}" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
configure_file("${SDL3_SOURCE_DIR}/cmake/sdl3.pc.in" "${SDL3_BINARY_DIR}/sdl3.pc" @ONLY)
endfunction()
# Write list of dependencies to output. Only visible when configuring with --log-level=DEBUG.
function(debug_show_sdl_deps)
get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS)
foreach(ID IN LISTS ids)
message(DEBUG "- id: ${ID}")
get_property(INCLUDES TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES)
get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE)
get_property(PKG_CONFIG_PREFIX TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX)
get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS)
get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS)
get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS)
message(DEBUG " INCLUDES: ${INCLUDES}")
message(DEBUG " CMAKE_MODULE: ${CMAKE_MODULE}")
message(DEBUG " PKG_CONFIG_PREFIX: ${PKG_CONFIG_PREFIX}")
message(DEBUG " PKG_CONFIG_SPECS: ${PKG_CONFIG_SPECS}")
message(DEBUG " LIBS: ${LIBS}")
message(DEBUG " LINK_OPTIONS: ${LINK_OPTIONS}")
endforeach()
endfunction()

141
external/SDL/cmake/test/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,141 @@
# This cmake build script is meant for verifying the various CMake configuration scripts.
cmake_minimum_required(VERSION 3.12)
project(SDL_cmake_selftest LANGUAGES C)
include(CheckLanguage)
# FIXME: how to target ios/tvos with Swift?
# https://gitlab.kitware.com/cmake/cmake/-/issues/20104
if(APPLE AND CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*")
# multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift
list(LENGTH CMAKE_OSX_ARCHITECTURES count_osx_archs)
if(count_osx_archs LESS_EQUAL 1)
check_language(Swift)
if(CMAKE_Swift_COMPILER)
enable_language(Swift)
endif()
endif()
endif()
message(STATUS "CMAKE_SYSTEM_NAME= ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR= ${CMAKE_SYSTEM_PROCESSOR}")
if(WINDOWS_STORE)
enable_language(CXX)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/ZW>")
set_source_files_properties(ain_cli.c main_gui.c PROPERTIES LANGUAGE CXX)
endif()
include(GenerateExportHeader)
if(ANDROID)
macro(add_executable NAME)
set(args ${ARGN})
list(REMOVE_ITEM args WIN32)
add_library(${NAME} SHARED ${args})
unset(args)
endmacro()
endif()
cmake_policy(SET CMP0074 NEW)
# Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL3 outside of sysroot
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
include(FeatureSummary)
option(TEST_SHARED "Test linking to shared SDL3 library" ON)
add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library")
option(TEST_STATIC "Test linking to static SDL3 library" ON)
add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
option(TEST_TEST "Test linking to SDL3_test library" ON)
add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
option(TEST_FULL "Run complete SDL test suite" OFF)
add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers)
add_library(headers_test_slash OBJECT inc_sdl_slash.c)
target_link_libraries(headers_test_slash PRIVATE SDL3::Headers)
if(TEST_SHARED)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared)
add_executable(gui-shared WIN32 main_gui.c)
target_link_libraries(gui-shared PRIVATE SDL3::SDL3-shared)
if(WIN32)
add_custom_command(TARGET gui-shared POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3-shared>" "$<TARGET_FILE_DIR:gui-shared>"
)
endif()
add_library(sharedlib-shared SHARED main_lib.c)
target_link_libraries(sharedlib-shared PRIVATE SDL3::SDL3-shared)
generate_export_header(sharedlib-shared EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-shared PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared_export.h\"")
set_target_properties(sharedlib-shared PROPERTIES C_VISIBILITY_PRESET "hidden")
add_executable(cli-shared main_cli.c)
target_link_libraries(cli-shared PRIVATE SDL3::SDL3-shared)
if(WIN32)
add_custom_command(TARGET cli-shared POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3-shared>" "$<TARGET_FILE_DIR:cli-shared>"
)
endif()
if(TEST_TEST)
add_executable(sdltest-shared sdltest.c)
target_link_libraries(sdltest-shared PRIVATE SDL3::SDL3_test SDL3::SDL3-shared)
endif()
if(CMAKE_Swift_COMPILER)
add_executable(swift-shared main.swift)
target_include_directories(swift-shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
target_link_libraries(swift-shared PRIVATE SDL3::SDL3-shared)
endif()
endif()
if(TEST_STATIC)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-static)
add_executable(gui-static WIN32 main_gui.c)
target_link_libraries(gui-static PRIVATE SDL3::SDL3-static)
# Assume SDL library has been built with `set(CMAKE_POSITION_INDEPENDENT_CODE ON)`
add_library(sharedlib-static SHARED main_lib.c)
target_link_libraries(sharedlib-static PRIVATE SDL3::SDL3-static)
generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"")
set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
if(TEST_TEST)
add_executable(sdltest-static sdltest.c)
target_link_libraries(sdltest-static PRIVATE SDL3::SDL3_test SDL3::SDL3-static)
endif()
if(CMAKE_Swift_COMPILER)
add_executable(swift-static main.swift)
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
target_link_libraries(swift-static PRIVATE SDL3::SDL3-static)
endif()
endif()
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3)
add_executable(gui-whatever WIN32 main_gui.c)
target_link_libraries(gui-whatever PRIVATE SDL3::SDL3)
if(TEST_FULL)
enable_testing()
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Test timeout multiplier")
set(SDL_TESTS_LINK_SHARED ${TEST_SHARED})
add_definitions(-DNO_BUILD_CONFIG)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../test" SDL_test)
endif()
if(ANDROID)
find_package(SDL3 REQUIRED CONFIG COMPONENTS Jar)
endif()
feature_summary(WHAT ALL)

View File

@@ -0,0 +1,8 @@
#include "SDL3/SDL.h"
#include "SDL3/SDL_main.h"
void inc_sdl_slash(void) {
SDL_SetMainReady();
SDL_Init(0);
SDL_Quit();
}

13
external/SDL/cmake/test/main.swift vendored Normal file
View File

@@ -0,0 +1,13 @@
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
import SDL3
guard SDL_Init(SDL_INIT_VIDEO) else {
fatalError("SDL_Init error: \(String(cString: SDL_GetError()))")
}
var sdlVersion = SDL_GetVersion()
print("SDL version: \(sdlVersion)")
SDL_Quit()

15
external/SDL/cmake/test/main_cli.c vendored Normal file
View File

@@ -0,0 +1,15 @@
#define SDL_MAIN_HANDLED
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
int main(int argc, char *argv[])
{
SDL_SetMainReady();
if (!SDL_Init(0)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
SDL_Delay(100);
SDL_Quit();
return 0;
}

24
external/SDL/cmake/test/main_gui.c vendored Normal file
View File

@@ -0,0 +1,24 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
int main(int argc, char *argv[])
{
SDL_Window *window = NULL;
SDL_Surface *screenSurface = NULL;
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
window = SDL_CreateWindow("Hello SDL", 640, 480, 0);
if (!window) {
SDL_Log("could not create window: %s\n", SDL_GetError());
return 1;
}
screenSurface = SDL_GetWindowSurface(window);
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
SDL_UpdateWindowSurface(window);
SDL_Delay(100);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}

34
external/SDL/cmake/test/main_lib.c vendored Normal file
View File

@@ -0,0 +1,34 @@
#include <SDL3/SDL.h>
#define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */
#include <SDL3/SDL_main.h>
#include EXPORT_HEADER
#ifdef _WIN32
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
return TRUE;
}
#endif
int MYLIBRARY_EXPORT mylibrary_init(void);
void MYLIBRARY_EXPORT mylibrary_quit(void);
int MYLIBRARY_EXPORT mylibrary_work(void);
int mylibrary_init(void) {
SDL_SetMainReady();
if (!SDL_Init(0)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
return 0;
}
void mylibrary_quit(void) {
SDL_Quit();
}
int mylibrary_work(void) {
SDL_Delay(100);
return 0;
}

9
external/SDL/cmake/test/sdltest.c vendored Normal file
View File

@@ -0,0 +1,9 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_test.h>
int main(int argc, char *argv[]) {
SDLTest_CommonState state;
SDLTest_CommonDefaultArgs(&state, argc, argv);
return 0;
}

View File

@@ -0,0 +1,4 @@
module SDL3 [extern_c] {
header "shim.h"
export *
}

3
external/SDL/cmake/test/swift/shim.h vendored Normal file
View File

@@ -0,0 +1,3 @@
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
#include <SDL3/SDL.h>

51
external/SDL/cmake/test/test_pkgconfig.sh vendored Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
if test "x$CC" = "x"; then
CC=cc
fi
machine="$($CC -dumpmachine)"
case "$machine" in
*mingw* )
EXEPREFIX=""
EXESUFFIX=".exe"
;;
*android* )
EXEPREFIX="lib"
EXESUFFIX=".so"
LDFLAGS="$EXTRA_LDFLAGS -shared"
;;
* )
EXEPREFIX=""
EXESUFFIX=""
;;
esac
set -e
# Get the canonical path of the folder containing this script
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
SDL_CFLAGS="$( pkg-config sdl3 --cflags )"
SDL_LDFLAGS="$( pkg-config sdl3 --libs )"
SDL_STATIC_LDFLAGS="$( pkg-config sdl3 --libs --static )"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $SDL_CFLAGS $CFLAGS"
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS"
echo "-- LDFLASG: $LDFLAGS"
echo "-- SDL_CFLAGS: $SDL_CFLAGS"
echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
echo "-- COMPILE: $compile_cmd"
echo "-- LINK: $link_cmd"
echo "-- STATIC_LINK: $static_link_cmd"
set -x
$compile_cmd
$link_cmd
$static_link_cmd

37
external/SDL/cmake/xxd.py vendored Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python
import argparse
import os
import pathlib
import re
def main():
parser = argparse.ArgumentParser(allow_abbrev=False, description="Convert file into includable C header")
parser.add_argument("--in", "-i", type=pathlib.Path, metavar="INPUT", dest="input", required=True, help="Input file")
parser.add_argument("--out", "-o", type=pathlib.Path, metavar="OUTPUT", dest="output", required=True, help="Output header")
parser.add_argument("--columns", type=int, default=12, help="Column count")
args = parser.parse_args()
t = pathlib.Path()
varname, _ = re.subn("[^a-zA-Z0-9]", "_", str(args.input.name))
binary_data = args.input.open("rb").read()
with args.output.open("w", newline="\n") as fout:
fout.write("unsigned char {}[] = {{\n".format(varname))
bytes_written = 0
while bytes_written < len(binary_data):
col = bytes_written % args.columns
if col == 0:
fout.write(" ")
column_data = binary_data[bytes_written:bytes_written+args.columns]
fout.write(", ".join("0x{:02x}".format(d) for d in column_data))
bytes_written += len(column_data)
if bytes_written < len(binary_data):
fout.write(",\n")
else:
fout.write("\n")
fout.write("}};\nunsigned int {}_len = {:d};\n".format(varname, len(binary_data)))
if __name__ == "__main__":
raise SystemExit(main())