diff options
Diffstat (limited to 'src/contrib/SDL-3.2.20/cmake')
36 files changed, 4818 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/cmake/3rdparty.cmake b/src/contrib/SDL-3.2.20/cmake/3rdparty.cmake new file mode 100644 index 0000000..8b38a5d --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/3rdparty.cmake | |||
@@ -0,0 +1,116 @@ | |||
1 | function(get_clang_tidy_ignored_files OUTVAR) | ||
2 | set(3RD_PARTY_SOURCES | ||
3 | # Public GL headers | ||
4 | "SDL_egl.h" | ||
5 | "SDL_hidapi.h" | ||
6 | "SDL_opengl.h" | ||
7 | "SDL_opengl_glext.h" | ||
8 | "SDL_opengles2_gl2.h" | ||
9 | "SDL_opengles2_gl2ext.h" | ||
10 | "SDL_opengles2_gl2platform.h" | ||
11 | "SDL_opengles2_khrplatform.h" | ||
12 | # stdlib | ||
13 | "SDL_malloc.c" | ||
14 | "SDL_qsort.c" | ||
15 | "SDL_strtokr.c" | ||
16 | # edid | ||
17 | "edid-parse.c" | ||
18 | "edid.h" | ||
19 | # imKStoUCS | ||
20 | "imKStoUCS.c" | ||
21 | "imKStoUCS.h" | ||
22 | # Joystick controller type | ||
23 | "controller_type.h" | ||
24 | "controller_type.c" | ||
25 | # HIDAPI Steam controller | ||
26 | "controller_constants.h" | ||
27 | "controller_structs.h" | ||
28 | # YUV2RGB | ||
29 | "yuv_rgb.c" | ||
30 | "yuv_rgb_lsx_func.h" | ||
31 | "yuv_rgb_sse_func.h" | ||
32 | "yuv_rgb_std_func.h" | ||
33 | # LIBM | ||
34 | "e_atan2.c" | ||
35 | "e_exp.c" | ||
36 | "e_fmod.c" | ||
37 | "e_log10.c" | ||
38 | "e_log.c" | ||
39 | "e_pow.c" | ||
40 | "e_rem_pio2.c" | ||
41 | "e_sqrt.c" | ||
42 | "k_cos.c" | ||
43 | "k_rem_pio2.c" | ||
44 | "k_sin.c" | ||
45 | "k_tan.c" | ||
46 | "s_atan.c" | ||
47 | "s_copysign.c" | ||
48 | "s_cos.c" | ||
49 | "s_fabs.c" | ||
50 | "s_floor.c" | ||
51 | "s_scalbn.c" | ||
52 | "s_sin.c" | ||
53 | "s_tan.c" | ||
54 | "math_private.h" | ||
55 | "math_libm.h" | ||
56 | # EGL | ||
57 | "egl.h" | ||
58 | "eglext.h" | ||
59 | "eglplatform.h" | ||
60 | # GLES2 | ||
61 | "gl2.h" | ||
62 | "gl2ext.h" | ||
63 | "gl2platform.h" | ||
64 | # KHR | ||
65 | "khrplatform.h" | ||
66 | # Vulkan | ||
67 | "vk_icd.h" | ||
68 | "vk_layer.h" | ||
69 | "vk_platform.h" | ||
70 | "vk_sdk_platform.h" | ||
71 | "vulkan_android.h" | ||
72 | "vulkan_beta.h" | ||
73 | "vulkan_core.h" | ||
74 | "vulkan_directfb.h" | ||
75 | "vulkan_fuchsia.h" | ||
76 | "vulkan_ggp.h" | ||
77 | "vulkan_ios.h" | ||
78 | "vulkan_macos.h" | ||
79 | "vulkan_metal.h" | ||
80 | "vulkan_screen.h" | ||
81 | "vulkan_vi.h" | ||
82 | "vulkan_wayland.h" | ||
83 | "vulkan_win32.h" | ||
84 | "vulkan_xcb.h" | ||
85 | "vulkan_xlib_xrandr.h" | ||
86 | "vulkan_xlib.h" | ||
87 | "vulkan.h" | ||
88 | "vulkan_enums.hpp" | ||
89 | "vulkan_format_traits.hpp" | ||
90 | "vulkan_funcs.hpp" | ||
91 | "vulkan_handles.hpp" | ||
92 | "vulkan_hash.hpp" | ||
93 | "vulkan_raii.hpp" | ||
94 | "vulkan_static_assertions.hpp" | ||
95 | "vulkan_structs.hpp" | ||
96 | "vulkan_to_string.hpp" | ||
97 | # HIDAPI | ||
98 | "hid.c" | ||
99 | "hid.cpp" | ||
100 | "hid.m" | ||
101 | "hidraw.cpp" | ||
102 | "hidusb.cpp" | ||
103 | "hidapi.h" | ||
104 | # XSETTINGS | ||
105 | "xsettings-client.c" | ||
106 | "xsettings-client.h") | ||
107 | |||
108 | foreach(SOURCE_FILE ${3RD_PARTY_SOURCES}) | ||
109 | list(APPEND IGNORED_LIST "{\"name\":\"${SOURCE_FILE}\",\"lines\":[[1,1]]}") | ||
110 | endforeach() | ||
111 | |||
112 | string(REPLACE ";" "," IGNORED_FILES "${IGNORED_LIST}") | ||
113 | set(${OUTVAR} | ||
114 | "${IGNORED_FILES}" | ||
115 | PARENT_SCOPE) | ||
116 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/CPackProjectConfig.cmake.in b/src/contrib/SDL-3.2.20/cmake/CPackProjectConfig.cmake.in new file mode 100644 index 0000000..6bfcac3 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/CPackProjectConfig.cmake.in | |||
@@ -0,0 +1,36 @@ | |||
1 | if(CPACK_PACKAGE_FILE_NAME MATCHES ".*-src$") | ||
2 | message(FATAL_ERROR "Creating source archives for SDL @PROJECT_VERSION@ is not supported.") | ||
3 | endif() | ||
4 | |||
5 | set(PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@") | ||
6 | set(SDL_CMAKE_PLATFORM "@SDL_CMAKE_PLATFORM@") | ||
7 | set(SDL_CPU_NAMES "@SDL_CPU_NAMES@") | ||
8 | list(SORT SDL_CPU_NAMES) | ||
9 | |||
10 | string(REPLACE ";" "-" SDL_CPU_NAMES_WITH_DASHES "${SDL_CPU_NAMES}") | ||
11 | if(SDL_CPU_NAMES_WITH_DASHES) | ||
12 | set(SDL_CPU_NAMES_WITH_DASHES "-${SDL_CPU_NAMES_WITH_DASHES}") | ||
13 | endif() | ||
14 | |||
15 | string(TOLOWER "${SDL_CMAKE_PLATFORM}" lower_sdl_cmake_platform) | ||
16 | string(TOLOWER "${SDL_CPU_NAMES}" lower_sdl_cpu_names) | ||
17 | if(lower_sdl_cmake_platform STREQUAL lower_sdl_cpu_names) | ||
18 | set(SDL_CPU_NAMES_WITH_DASHES) | ||
19 | endif() | ||
20 | |||
21 | set(MSVC @MSVC@) | ||
22 | set(MINGW @MINGW@) | ||
23 | if(MSVC) | ||
24 | set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-VC") | ||
25 | elseif(MINGW) | ||
26 | set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-mingw") | ||
27 | endif() | ||
28 | |||
29 | |||
30 | set(CPACK_PACKAGE_FILE_NAME "SDL@PROJECT_VERSION_MAJOR@-@PROJECT_VERSION@-${SDL_CMAKE_PLATFORM}${SDL_CPU_NAMES_WITH_DASHES}") | ||
31 | |||
32 | if(CPACK_GENERATOR STREQUAL "DragNDrop") | ||
33 | set(CPACK_DMG_VOLUME_NAME "SDL@PROJECT_VERSION_MAJOR@ @PROJECT_VERSION@") | ||
34 | # FIXME: use pre-built/create .DS_Store through AppleScript (CPACK_DMG_DS_STORE/CPACK_DMG_DS_STORE_SETUP_SCRIPT) | ||
35 | set(CPACK_DMG_DS_STORE "${PROJECT_SOURCE_DIR}/Xcode/SDL/pkg-support/resources/SDL_DS_Store") | ||
36 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/FindFFmpeg.cmake b/src/contrib/SDL-3.2.20/cmake/FindFFmpeg.cmake new file mode 100644 index 0000000..62950c0 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/FindFFmpeg.cmake | |||
@@ -0,0 +1,138 @@ | |||
1 | # - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) | ||
2 | # | ||
3 | # Once done this will define | ||
4 | # FFMPEG_FOUND - System has the all required components. | ||
5 | # FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. | ||
6 | # | ||
7 | # For each of the components it will additionally set. | ||
8 | # - AVCODEC | ||
9 | # - AVDEVICE | ||
10 | # - AVFORMAT | ||
11 | # - AVFILTER | ||
12 | # - AVUTIL | ||
13 | # - POSTPROC | ||
14 | # - SWSCALE | ||
15 | # the following target will be defined | ||
16 | # FFmpeg::SDL::<component> - link to this target to | ||
17 | # the following variables will be defined | ||
18 | # FFmpeg_<component>_FOUND - System has <component> | ||
19 | # FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers | ||
20 | # FFmpeg_<component>_LIBRARIES - Link these to use <component> | ||
21 | # FFmpeg_<component>_DEFINITIONS - Compiler switches required for using <component> | ||
22 | # FFmpeg_<component>_VERSION - The components version | ||
23 | # | ||
24 | # Copyright (c) 2006, Matthias Kretz, <kretz@kde.org> | ||
25 | # Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org> | ||
26 | # Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz> | ||
27 | # Copyright (c) 2023, Sam lantinga, <slouken@libsdl.org> | ||
28 | # | ||
29 | # Redistribution and use is allowed according to the terms of the BSD license. | ||
30 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
31 | |||
32 | include(FindPackageHandleStandardArgs) | ||
33 | include("${CMAKE_CURRENT_LIST_DIR}/PkgConfigHelper.cmake") | ||
34 | |||
35 | # The default components were taken from a survey over other FindFFMPEG.cmake files | ||
36 | if(NOT FFmpeg_FIND_COMPONENTS) | ||
37 | set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) | ||
38 | foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS) | ||
39 | set(FFmpeg_FIND_REQUIRED_${_component} TRUE) | ||
40 | endforeach() | ||
41 | endif() | ||
42 | |||
43 | find_package(PkgConfig QUIET) | ||
44 | |||
45 | # | ||
46 | ### Macro: find_component | ||
47 | # | ||
48 | # Checks for the given component by invoking pkgconfig and then looking up the libraries and | ||
49 | # include directories. | ||
50 | # | ||
51 | macro(find_component _component _pkgconfig _library _header) | ||
52 | |||
53 | # use pkg-config to get the directories and then use these values | ||
54 | # in the FIND_PATH() and FIND_LIBRARY() calls | ||
55 | if(PKG_CONFIG_FOUND) | ||
56 | pkg_check_modules(PC_${_component} QUIET ${_pkgconfig}) | ||
57 | endif() | ||
58 | |||
59 | find_path(FFmpeg_${_component}_INCLUDE_DIRS | ||
60 | NAMES ${_header} | ||
61 | HINTS | ||
62 | ${PC_${_component}_INCLUDE_DIRS} | ||
63 | PATH_SUFFIXES | ||
64 | ffmpeg | ||
65 | ) | ||
66 | |||
67 | find_library(FFmpeg_${_component}_LIBRARY | ||
68 | NAMES ${_library} | ||
69 | HINTS | ||
70 | ${PC_${_component}_LIBRARY_DIRS} | ||
71 | ) | ||
72 | |||
73 | if(FFmpeg_${_component}_INCLUDE_DIRS AND FFmpeg_${_component}_LIBRARY) | ||
74 | set(FFmpeg_${_component}_FOUND TRUE) | ||
75 | endif() | ||
76 | |||
77 | if(PC_${_component}_FOUND) | ||
78 | get_flags_from_pkg_config("${FFmpeg_${_component}_LIBRARY}" "PC_${_component}" "${_component}") | ||
79 | endif() | ||
80 | |||
81 | set(FFmpeg_${_component}_VERSION "${PC_${_component}_VERSION}") | ||
82 | |||
83 | set(FFmpeg_${_component}_COMPILE_OPTIONS "${${_component}_options}" CACHE STRING "Extra compile options of FFmpeg ${_component}") | ||
84 | |||
85 | set(FFmpeg_${_component}_LIBRARIES "${${_component}_link_libraries}" CACHE STRING "Extra link libraries of FFmpeg ${_component}") | ||
86 | |||
87 | set(FFmpeg_${_component}_LINK_OPTIONS "${${_component}_link_options}" CACHE STRING "Extra link flags of FFmpeg ${_component}") | ||
88 | |||
89 | set(FFmpeg_${_component}_LINK_DIRECTORIES "${${_component}_link_directories}" CACHE PATH "Extra link directories of FFmpeg ${_component}") | ||
90 | |||
91 | mark_as_advanced( | ||
92 | FFmpeg_${_component}_INCLUDE_DIRS | ||
93 | FFmpeg_${_component}_LIBRARY | ||
94 | FFmpeg_${_component}_COMPILE_OPTIONS | ||
95 | FFmpeg_${_component}_LIBRARIES | ||
96 | FFmpeg_${_component}_LINK_OPTIONS | ||
97 | FFmpeg_${_component}_LINK_DIRECTORIES | ||
98 | ) | ||
99 | endmacro() | ||
100 | |||
101 | # Check for all possible component. | ||
102 | find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) | ||
103 | find_component(AVFORMAT libavformat avformat libavformat/avformat.h) | ||
104 | find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) | ||
105 | find_component(AVUTIL libavutil avutil libavutil/avutil.h) | ||
106 | find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) | ||
107 | find_component(SWSCALE libswscale swscale libswscale/swscale.h) | ||
108 | find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) | ||
109 | find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) | ||
110 | |||
111 | # Compile the list of required vars | ||
112 | set(_FFmpeg_REQUIRED_VARS) | ||
113 | foreach(_component ${FFmpeg_FIND_COMPONENTS}) | ||
114 | list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_${_component}_INCLUDE_DIRS FFmpeg_${_component}_LIBRARY) | ||
115 | endforeach () | ||
116 | |||
117 | # Give a nice error message if some of the required vars are missing. | ||
118 | find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS}) | ||
119 | |||
120 | set(FFMPEG_LIBRARIES) | ||
121 | if(FFmpeg_FOUND) | ||
122 | foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS) | ||
123 | if(FFmpeg_${_component}_FOUND) | ||
124 | list(APPEND FFMPEG_LIBRARIES FFmpeg::SDL::${_component}) | ||
125 | if(NOT TARGET FFmpeg::SDL::${_component}) | ||
126 | add_library(FFmpeg::SDL::${_component} UNKNOWN IMPORTED) | ||
127 | set_target_properties(FFmpeg::SDL::${_component} PROPERTIES | ||
128 | IMPORTED_LOCATION "${FFmpeg_${_component}_LIBRARY}" | ||
129 | INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_${_component}_INCLUDE_DIRS}" | ||
130 | INTERFACE_COMPILE_OPTIONS "${FFmpeg_${_component}_COMPILE_OPTIONS}" | ||
131 | INTERFACE_LINK_LIBRARIES "${FFmpeg_${_component}_LIBRARIES}" | ||
132 | INTERFACE_LINK_OPTIONS "${FFmpeg_${_component}_LINK_OPTIONS}" | ||
133 | INTERFACE_LINK_DIRECTORIES "${FFmpeg_${_component}_LINK_DIRECTORIES}" | ||
134 | ) | ||
135 | endif() | ||
136 | endif() | ||
137 | endforeach() | ||
138 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/FindLibUSB.cmake b/src/contrib/SDL-3.2.20/cmake/FindLibUSB.cmake new file mode 100644 index 0000000..2488735 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/FindLibUSB.cmake | |||
@@ -0,0 +1,73 @@ | |||
1 | include(FindPackageHandleStandardArgs) | ||
2 | |||
3 | set(LibUSB_PKG_CONFIG_SPEC libusb-1.0>=1.0.16) | ||
4 | set(LibUSB_MIN_API_VERSION 0x01000102) | ||
5 | |||
6 | find_package(PkgConfig QUIET) | ||
7 | |||
8 | if(PKG_CONFIG_FOUND) | ||
9 | pkg_check_modules(PC_LibUSB ${LibUSB_PKG_CONFIG_SPEC}) | ||
10 | endif() | ||
11 | |||
12 | find_library(LibUSB_LIBRARY | ||
13 | NAMES usb-1.0 libusb-1.0 | ||
14 | HINTS ${PC_LibUSB_LIBRARY_DIRS} | ||
15 | ) | ||
16 | |||
17 | find_path(LibUSB_INCLUDE_PATH | ||
18 | NAMES libusb.h | ||
19 | PATH_SUFFIXES libusb-1.0 | ||
20 | HINTS ${PC_LibUSB_INCLUDE_DIRS} | ||
21 | ) | ||
22 | |||
23 | set(LibUSB_API_VERSION "LibUSB_API_VERSION-NOTFOUND") | ||
24 | if(LibUSB_INCLUDE_PATH AND EXISTS "${LibUSB_INCLUDE_PATH}/libusb.h") | ||
25 | file(READ "${LibUSB_INCLUDE_PATH}/libusb.h" LIBUSB_H_TEXT) | ||
26 | if("${LIBUSB_H_TEXT}" MATCHES "#define[ \t]+LIBUSBX?_API_VERSION[ \t]+(0x[0-9a-fA-F]+)" ) | ||
27 | set(LibUSB_API_VERSION "${CMAKE_MATCH_1}") | ||
28 | endif() | ||
29 | endif() | ||
30 | |||
31 | if(LibUSB_API_VERSION) | ||
32 | math(EXPR LibUSB_MIN_API_VERSION_decimal "${LibUSB_MIN_API_VERSION}") | ||
33 | math(EXPR LibUSB_API_VERSION_decimal "${LibUSB_API_VERSION}") | ||
34 | if(NOT LibUSB_MIN_API_VERSION_decimal LESS_EQUAL LibUSB_API_VERSION_decimal) | ||
35 | set(LibUSB_LIBRARY "LibUSB_LIBRARY-NOTFOUND") | ||
36 | endif() | ||
37 | else() | ||
38 | set(LibUSB_LIBRARY "LibUSB_LIBRARY-NOTFOUND") | ||
39 | endif() | ||
40 | |||
41 | set(LibUSB_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of LibUSB") | ||
42 | |||
43 | set(LibUSB_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of LibUSB") | ||
44 | |||
45 | set(LibUSB_LINK_FLAGS "" CACHE STRING "Extra link flags of LibUSB") | ||
46 | |||
47 | if(LibUSB_LIBRARY AND LibUSB_INCLUDE_PATH) | ||
48 | if(PC_LibUSB_FOUND) | ||
49 | set(LibUSB_VERSION "${PC_LibUSB_VERSION}") | ||
50 | else() | ||
51 | set(LibUSB_VERSION "1.0.16-or-higher") | ||
52 | endif() | ||
53 | else() | ||
54 | set(LibUSB_VERSION "LibUSB_VERSION-NOTFOUND") | ||
55 | endif() | ||
56 | |||
57 | find_package_handle_standard_args(LibUSB | ||
58 | VERSION_VAR LibUSB_VERSION | ||
59 | REQUIRED_VARS LibUSB_LIBRARY LibUSB_INCLUDE_PATH | ||
60 | ) | ||
61 | |||
62 | if(LibUSB_FOUND AND NOT TARGET LibUSB::LibUSB) | ||
63 | add_library(LibUSB::LibUSB IMPORTED UNKNOWN) | ||
64 | set_target_properties(LibUSB::LibUSB | ||
65 | PROPERTIES | ||
66 | IMPORTED_LOCATION "${LibUSB_LIBRARY}" | ||
67 | INTERFACE_INCLUDE_DIRECTORIES "${LibUSB_INCLUDE_PATH}" | ||
68 | INTERFACE_COMPILE_OPTIONS "${LibUSB_COMPILE_OPTIONS}" | ||
69 | INTERFACE_LINK_LIBRARIES "${LibUSB_LINK_LIBRARIES}" | ||
70 | INTERFACE_LINK_OPTIONS "${LibUSB_LINK_OPTIONS}" | ||
71 | ) | ||
72 | endif() | ||
73 | |||
diff --git a/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake b/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..a08895c --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake | |||
@@ -0,0 +1,284 @@ | |||
1 | # - Returns a version string from Git | ||
2 | # | ||
3 | # These functions force a re-configure on each git commit so that you can | ||
4 | # trust the values of the variables in your build system. | ||
5 | # | ||
6 | # get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) | ||
7 | # | ||
8 | # Returns the refspec and sha hash of the current head revision | ||
9 | # | ||
10 | # git_describe(<var> [<additional arguments to git describe> ...]) | ||
11 | # | ||
12 | # Returns the results of git describe on the source tree, and adjusting | ||
13 | # the output so that it tests false if an error occurs. | ||
14 | # | ||
15 | # git_describe_working_tree(<var> [<additional arguments to git describe> ...]) | ||
16 | # | ||
17 | # Returns the results of git describe on the working tree (--dirty option), | ||
18 | # and adjusting the output so that it tests false if an error occurs. | ||
19 | # | ||
20 | # git_get_exact_tag(<var> [<additional arguments to git describe> ...]) | ||
21 | # | ||
22 | # Returns the results of git describe --exact-match on the source tree, | ||
23 | # and adjusting the output so that it tests false if there was no exact | ||
24 | # matching tag. | ||
25 | # | ||
26 | # git_local_changes(<var>) | ||
27 | # | ||
28 | # Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. | ||
29 | # Uses the return code of "git diff-index --quiet HEAD --". | ||
30 | # Does not regard untracked files. | ||
31 | # | ||
32 | # Requires CMake 2.6 or newer (uses the 'function' command) | ||
33 | # | ||
34 | # Original Author: | ||
35 | # 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net> | ||
36 | # http://academic.cleardefinition.com | ||
37 | # | ||
38 | # Copyright 2009-2013, Iowa State University. | ||
39 | # Copyright 2013-2020, Ryan Pavlik | ||
40 | # Copyright 2013-2020, Contributors | ||
41 | # SPDX-License-Identifier: BSL-1.0 | ||
42 | # Distributed under the Boost Software License, Version 1.0. | ||
43 | # (See accompanying file LICENSE_1_0.txt or copy at | ||
44 | # http://www.boost.org/LICENSE_1_0.txt) | ||
45 | |||
46 | if(__get_git_revision_description) | ||
47 | return() | ||
48 | endif() | ||
49 | set(__get_git_revision_description YES) | ||
50 | |||
51 | # We must run the following at "include" time, not at function call time, | ||
52 | # to find the path to this module rather than the path to a calling list file | ||
53 | get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) | ||
54 | |||
55 | # Function _git_find_closest_git_dir finds the next closest .git directory | ||
56 | # that is part of any directory in the path defined by _start_dir. | ||
57 | # The result is returned in the parent scope variable whose name is passed | ||
58 | # as variable _git_dir_var. If no .git directory can be found, the | ||
59 | # function returns an empty string via _git_dir_var. | ||
60 | # | ||
61 | # Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and | ||
62 | # neither foo nor bar contain a file/directory .git. This will return | ||
63 | # C:/bla/.git | ||
64 | # | ||
65 | function(_git_find_closest_git_dir _start_dir _git_dir_var) | ||
66 | set(cur_dir "${_start_dir}") | ||
67 | set(git_dir "${_start_dir}/.git") | ||
68 | while(NOT EXISTS "${git_dir}") | ||
69 | # .git dir not found, search parent directories | ||
70 | set(git_previous_parent "${cur_dir}") | ||
71 | get_filename_component(cur_dir "${cur_dir}" DIRECTORY) | ||
72 | if(cur_dir STREQUAL git_previous_parent) | ||
73 | # We have reached the root directory, we are not in git | ||
74 | set(${_git_dir_var} | ||
75 | "" | ||
76 | PARENT_SCOPE) | ||
77 | return() | ||
78 | endif() | ||
79 | set(git_dir "${cur_dir}/.git") | ||
80 | endwhile() | ||
81 | set(${_git_dir_var} | ||
82 | "${git_dir}" | ||
83 | PARENT_SCOPE) | ||
84 | endfunction() | ||
85 | |||
86 | function(get_git_head_revision _refspecvar _hashvar) | ||
87 | _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) | ||
88 | |||
89 | if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") | ||
90 | set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) | ||
91 | else() | ||
92 | set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) | ||
93 | endif() | ||
94 | if(NOT "${GIT_DIR}" STREQUAL "") | ||
95 | file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" | ||
96 | "${GIT_DIR}") | ||
97 | if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) | ||
98 | # We've gone above the CMake root dir. | ||
99 | set(GIT_DIR "") | ||
100 | endif() | ||
101 | endif() | ||
102 | if("${GIT_DIR}" STREQUAL "") | ||
103 | set(${_refspecvar} | ||
104 | "GITDIR-NOTFOUND" | ||
105 | PARENT_SCOPE) | ||
106 | set(${_hashvar} | ||
107 | "GITDIR-NOTFOUND" | ||
108 | PARENT_SCOPE) | ||
109 | return() | ||
110 | endif() | ||
111 | |||
112 | # Check if the current source dir is a git submodule or a worktree. | ||
113 | # In both cases .git is a file instead of a directory. | ||
114 | # | ||
115 | if(NOT IS_DIRECTORY ${GIT_DIR}) | ||
116 | # The following git command will return a non empty string that | ||
117 | # points to the super project working tree if the current | ||
118 | # source dir is inside a git submodule. | ||
119 | # Otherwise the command will return an empty string. | ||
120 | # | ||
121 | execute_process( | ||
122 | COMMAND "${GIT_EXECUTABLE}" rev-parse | ||
123 | --show-superproject-working-tree | ||
124 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
125 | OUTPUT_VARIABLE out | ||
126 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
127 | if(NOT "${out}" STREQUAL "") | ||
128 | # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule | ||
129 | file(READ ${GIT_DIR} submodule) | ||
130 | string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE | ||
131 | ${submodule}) | ||
132 | string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) | ||
133 | get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) | ||
134 | get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} | ||
135 | ABSOLUTE) | ||
136 | set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") | ||
137 | else() | ||
138 | # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree | ||
139 | file(READ ${GIT_DIR} worktree_ref) | ||
140 | # The .git directory contains a path to the worktree information directory | ||
141 | # inside the parent git repo of the worktree. | ||
142 | # | ||
143 | string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir | ||
144 | ${worktree_ref}) | ||
145 | string(STRIP ${git_worktree_dir} git_worktree_dir) | ||
146 | _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) | ||
147 | set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") | ||
148 | endif() | ||
149 | else() | ||
150 | set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") | ||
151 | endif() | ||
152 | set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") | ||
153 | if(NOT EXISTS "${GIT_DATA}") | ||
154 | file(MAKE_DIRECTORY "${GIT_DATA}") | ||
155 | endif() | ||
156 | |||
157 | if(NOT EXISTS "${HEAD_SOURCE_FILE}") | ||
158 | return() | ||
159 | endif() | ||
160 | set(HEAD_FILE "${GIT_DATA}/HEAD") | ||
161 | configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) | ||
162 | |||
163 | configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" | ||
164 | "${GIT_DATA}/grabRef.cmake" @ONLY) | ||
165 | include("${GIT_DATA}/grabRef.cmake") | ||
166 | |||
167 | set(${_refspecvar} | ||
168 | "${HEAD_REF}" | ||
169 | PARENT_SCOPE) | ||
170 | set(${_hashvar} | ||
171 | "${HEAD_HASH}" | ||
172 | PARENT_SCOPE) | ||
173 | endfunction() | ||
174 | |||
175 | function(git_describe _var) | ||
176 | if(NOT GIT_FOUND) | ||
177 | find_package(Git QUIET) | ||
178 | endif() | ||
179 | get_git_head_revision(refspec hash) | ||
180 | if(NOT GIT_FOUND) | ||
181 | set(${_var} | ||
182 | "GIT-NOTFOUND" | ||
183 | PARENT_SCOPE) | ||
184 | return() | ||
185 | endif() | ||
186 | if(NOT hash) | ||
187 | set(${_var} | ||
188 | "HEAD-HASH-NOTFOUND" | ||
189 | PARENT_SCOPE) | ||
190 | return() | ||
191 | endif() | ||
192 | |||
193 | # TODO sanitize | ||
194 | #if((${ARGN}" MATCHES "&&") OR | ||
195 | # (ARGN MATCHES "||") OR | ||
196 | # (ARGN MATCHES "\\;")) | ||
197 | # message("Please report the following error to the project!") | ||
198 | # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") | ||
199 | #endif() | ||
200 | |||
201 | #message(STATUS "Arguments to execute_process: ${ARGN}") | ||
202 | |||
203 | execute_process( | ||
204 | COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} | ||
205 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
206 | RESULT_VARIABLE res | ||
207 | OUTPUT_VARIABLE out | ||
208 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
209 | if(NOT res EQUAL 0) | ||
210 | set(out "${out}-${res}-NOTFOUND") | ||
211 | endif() | ||
212 | |||
213 | set(${_var} | ||
214 | "${out}" | ||
215 | PARENT_SCOPE) | ||
216 | endfunction() | ||
217 | |||
218 | function(git_describe_working_tree _var) | ||
219 | if(NOT GIT_FOUND) | ||
220 | find_package(Git QUIET) | ||
221 | endif() | ||
222 | if(NOT GIT_FOUND) | ||
223 | set(${_var} | ||
224 | "GIT-NOTFOUND" | ||
225 | PARENT_SCOPE) | ||
226 | return() | ||
227 | endif() | ||
228 | |||
229 | execute_process( | ||
230 | COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} | ||
231 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
232 | RESULT_VARIABLE res | ||
233 | OUTPUT_VARIABLE out | ||
234 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
235 | if(NOT res EQUAL 0) | ||
236 | set(out "${out}-${res}-NOTFOUND") | ||
237 | endif() | ||
238 | |||
239 | set(${_var} | ||
240 | "${out}" | ||
241 | PARENT_SCOPE) | ||
242 | endfunction() | ||
243 | |||
244 | function(git_get_exact_tag _var) | ||
245 | git_describe(out --exact-match ${ARGN}) | ||
246 | set(${_var} | ||
247 | "${out}" | ||
248 | PARENT_SCOPE) | ||
249 | endfunction() | ||
250 | |||
251 | function(git_local_changes _var) | ||
252 | if(NOT GIT_FOUND) | ||
253 | find_package(Git QUIET) | ||
254 | endif() | ||
255 | get_git_head_revision(refspec hash) | ||
256 | if(NOT GIT_FOUND) | ||
257 | set(${_var} | ||
258 | "GIT-NOTFOUND" | ||
259 | PARENT_SCOPE) | ||
260 | return() | ||
261 | endif() | ||
262 | if(NOT hash) | ||
263 | set(${_var} | ||
264 | "HEAD-HASH-NOTFOUND" | ||
265 | PARENT_SCOPE) | ||
266 | return() | ||
267 | endif() | ||
268 | |||
269 | execute_process( | ||
270 | COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- | ||
271 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
272 | RESULT_VARIABLE res | ||
273 | OUTPUT_VARIABLE out | ||
274 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
275 | if(res EQUAL 0) | ||
276 | set(${_var} | ||
277 | "CLEAN" | ||
278 | PARENT_SCOPE) | ||
279 | else() | ||
280 | set(${_var} | ||
281 | "DIRTY" | ||
282 | PARENT_SCOPE) | ||
283 | endif() | ||
284 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake.in b/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..116efc4 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/GetGitRevisionDescription.cmake.in | |||
@@ -0,0 +1,43 @@ | |||
1 | # | ||
2 | # Internal file for GetGitRevisionDescription.cmake | ||
3 | # | ||
4 | # Requires CMake 2.6 or newer (uses the 'function' command) | ||
5 | # | ||
6 | # Original Author: | ||
7 | # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> | ||
8 | # http://academic.cleardefinition.com | ||
9 | # Iowa State University HCI Graduate Program/VRAC | ||
10 | # | ||
11 | # Copyright 2009-2012, Iowa State University | ||
12 | # Copyright 2011-2015, Contributors | ||
13 | # Distributed under the Boost Software License, Version 1.0. | ||
14 | # (See accompanying file LICENSE_1_0.txt or copy at | ||
15 | # http://www.boost.org/LICENSE_1_0.txt) | ||
16 | # SPDX-License-Identifier: BSL-1.0 | ||
17 | |||
18 | set(HEAD_HASH) | ||
19 | |||
20 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) | ||
21 | |||
22 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) | ||
23 | if(HEAD_CONTENTS MATCHES "ref") | ||
24 | # named branch | ||
25 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") | ||
26 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") | ||
27 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) | ||
28 | else() | ||
29 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) | ||
30 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) | ||
31 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") | ||
32 | set(HEAD_HASH "${CMAKE_MATCH_1}") | ||
33 | endif() | ||
34 | endif() | ||
35 | else() | ||
36 | # detached HEAD | ||
37 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) | ||
38 | endif() | ||
39 | |||
40 | if(NOT HEAD_HASH) | ||
41 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) | ||
42 | string(STRIP "${HEAD_HASH}" HEAD_HASH) | ||
43 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/PkgConfigHelper.cmake b/src/contrib/SDL-3.2.20/cmake/PkgConfigHelper.cmake new file mode 100644 index 0000000..7070fac --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/PkgConfigHelper.cmake | |||
@@ -0,0 +1,34 @@ | |||
1 | # Helper for Find modules | ||
2 | |||
3 | function(get_flags_from_pkg_config _library _pc_prefix _out_prefix) | ||
4 | if("${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$") | ||
5 | set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER) | ||
6 | set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES) | ||
7 | set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER) | ||
8 | set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS) | ||
9 | else() | ||
10 | set(_cflags ${_pc_prefix}_CFLAGS_OTHER) | ||
11 | set(_link_libraries ${_pc_prefix}_LIBRARIES) | ||
12 | set(_link_options ${_pc_prefix}_LDFLAGS_OTHER) | ||
13 | set(_library_dirs ${_pc_prefix}_LIBRARY_DIRS) | ||
14 | endif() | ||
15 | |||
16 | # The *_LIBRARIES lists always start with the library itself | ||
17 | list(POP_FRONT "${_link_libraries}") | ||
18 | |||
19 | # Work around CMake's flag deduplication when pc files use `-framework A` instead of `-Wl,-framework,A` | ||
20 | string(REPLACE "-framework;" "-Wl,-framework," "_filtered_link_options" "${${_link_options}}") | ||
21 | |||
22 | set(${_out_prefix}_compile_options | ||
23 | "${${_cflags}}" | ||
24 | PARENT_SCOPE) | ||
25 | set(${_out_prefix}_link_libraries | ||
26 | "${${_link_libraries}}" | ||
27 | PARENT_SCOPE) | ||
28 | set(${_out_prefix}_link_options | ||
29 | "${_filtered_link_options}" | ||
30 | PARENT_SCOPE) | ||
31 | set(${_out_prefix}_link_directories | ||
32 | "${${_library_dirs}}" | ||
33 | PARENT_SCOPE) | ||
34 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/PreseedEmscriptenCache.cmake b/src/contrib/SDL-3.2.20/cmake/PreseedEmscriptenCache.cmake new file mode 100644 index 0000000..5a34ab5 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/PreseedEmscriptenCache.cmake | |||
@@ -0,0 +1,178 @@ | |||
1 | if(EMSCRIPTEN) | ||
2 | function(SDL_Preseed_CMakeCache) | ||
3 | set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS") | ||
4 | set(HAVE_ALLOCA_H "1" CACHE INTERNAL "Have include alloca.h") | ||
5 | set(HAVE_LIBM "1" CACHE INTERNAL "Have library m") | ||
6 | set(HAVE_MALLOC "1" CACHE INTERNAL "Have include malloc.h") | ||
7 | set(LIBC_HAS_ABS "1" CACHE INTERNAL "Have symbol abs") | ||
8 | set(LIBC_HAS_ACOS "1" CACHE INTERNAL "Have symbol acos") | ||
9 | set(LIBC_HAS_ACOSF "1" CACHE INTERNAL "Have symbol acosf") | ||
10 | set(LIBC_HAS_ASIN "1" CACHE INTERNAL "Have symbol asin") | ||
11 | set(LIBC_HAS_ASINF "1" CACHE INTERNAL "Have symbol asinf") | ||
12 | set(LIBC_HAS_ATAN "1" CACHE INTERNAL "Have symbol atan") | ||
13 | set(LIBC_HAS_ATAN2 "1" CACHE INTERNAL "Have symbol atan2") | ||
14 | set(LIBC_HAS_ATAN2F "1" CACHE INTERNAL "Have symbol atan2f") | ||
15 | set(LIBC_HAS_ATANF "1" CACHE INTERNAL "Have symbol atanf") | ||
16 | set(LIBC_HAS_ATOF "1" CACHE INTERNAL "Have symbol atof") | ||
17 | set(LIBC_HAS_ATOI "1" CACHE INTERNAL "Have symbol atoi") | ||
18 | set(LIBC_HAS_BCOPY "1" CACHE INTERNAL "Have symbol bcopy") | ||
19 | set(LIBC_HAS_CALLOC "1" CACHE INTERNAL "Have symbol calloc") | ||
20 | set(LIBC_HAS_CEIL "1" CACHE INTERNAL "Have symbol ceil") | ||
21 | set(LIBC_HAS_CEILF "1" CACHE INTERNAL "Have symbol ceilf") | ||
22 | set(LIBC_HAS_COPYSIGN "1" CACHE INTERNAL "Have symbol copysign") | ||
23 | set(LIBC_HAS_COPYSIGNF "1" CACHE INTERNAL "Have symbol copysignf") | ||
24 | set(LIBC_HAS_COS "1" CACHE INTERNAL "Have symbol cos") | ||
25 | set(LIBC_HAS_COSF "1" CACHE INTERNAL "Have symbol cosf") | ||
26 | set(LIBC_HAS_EXP "1" CACHE INTERNAL "Have symbol exp") | ||
27 | set(LIBC_HAS_EXPF "1" CACHE INTERNAL "Have symbol expf") | ||
28 | set(LIBC_HAS_FABS "1" CACHE INTERNAL "Have symbol fabs") | ||
29 | set(LIBC_HAS_FABSF "1" CACHE INTERNAL "Have symbol fabsf") | ||
30 | set(LIBC_HAS_FLOAT_H "1" CACHE INTERNAL "Have include float.h") | ||
31 | set(LIBC_HAS_FLOOR "1" CACHE INTERNAL "Have symbol floor") | ||
32 | set(LIBC_HAS_FLOORF "1" CACHE INTERNAL "Have symbol floorf") | ||
33 | set(LIBC_HAS_FMOD "1" CACHE INTERNAL "Have symbol fmod") | ||
34 | set(LIBC_HAS_FMODF "1" CACHE INTERNAL "Have symbol fmodf") | ||
35 | set(LIBC_HAS_FOPEN64 "1" CACHE INTERNAL "Have symbol fopen64") | ||
36 | set(LIBC_HAS_FREE "1" CACHE INTERNAL "Have symbol free") | ||
37 | set(LIBC_HAS_FSEEKO "1" CACHE INTERNAL "Have symbol fseeko") | ||
38 | set(LIBC_HAS_FSEEKO64 "1" CACHE INTERNAL "Have symbol fseeko64") | ||
39 | set(LIBC_HAS_GETENV "1" CACHE INTERNAL "Have symbol getenv") | ||
40 | set(LIBC_HAS_ICONV_H "1" CACHE INTERNAL "Have include iconv.h") | ||
41 | set(LIBC_HAS_INDEX "1" CACHE INTERNAL "Have symbol index") | ||
42 | set(LIBC_HAS_INTTYPES_H "1" CACHE INTERNAL "Have include inttypes.h") | ||
43 | set(LIBC_HAS_ISINF "1" CACHE INTERNAL "Have include isinf(double)") | ||
44 | set(LIBC_ISINF_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isinf(float)") | ||
45 | set(LIBC_HAS_ISINFF "1" CACHE INTERNAL "Have include isinff(float)") | ||
46 | set(LIBC_HAS_ISNAN "1" CACHE INTERNAL "Have include isnan(double)") | ||
47 | set(LIBC_ISNAN_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isnan(float)") | ||
48 | set(LIBC_HAS_ISNANF "1" CACHE INTERNAL "Have include isnanf(float)") | ||
49 | set(LIBC_HAS_ITOA "" CACHE INTERNAL "Have symbol itoa") | ||
50 | set(LIBC_HAS_LIMITS_H "1" CACHE INTERNAL "Have include limits.h") | ||
51 | set(LIBC_HAS_LOG "1" CACHE INTERNAL "Have symbol log") | ||
52 | set(LIBC_HAS_LOG10 "1" CACHE INTERNAL "Have symbol log10") | ||
53 | set(LIBC_HAS_LOG10F "1" CACHE INTERNAL "Have symbol log10f") | ||
54 | set(LIBC_HAS_LOGF "1" CACHE INTERNAL "Have symbol logf") | ||
55 | set(LIBC_HAS_LROUND "1" CACHE INTERNAL "Have symbol lround") | ||
56 | set(LIBC_HAS_LROUNDF "1" CACHE INTERNAL "Have symbol lroundf") | ||
57 | set(LIBC_HAS_MALLOC "1" CACHE INTERNAL "Have symbol malloc") | ||
58 | set(LIBC_HAS_MALLOC_H "1" CACHE INTERNAL "Have include malloc.h") | ||
59 | set(LIBC_HAS_MATH_H "1" CACHE INTERNAL "Have include math.h") | ||
60 | set(LIBC_HAS_MEMCMP "1" CACHE INTERNAL "Have symbol memcmp") | ||
61 | set(LIBC_HAS_MEMCPY "1" CACHE INTERNAL "Have symbol memcpy") | ||
62 | set(LIBC_HAS_MEMMOVE "1" CACHE INTERNAL "Have symbol memmove") | ||
63 | set(LIBC_HAS_MEMORY_H "1" CACHE INTERNAL "Have include memory.h") | ||
64 | set(LIBC_HAS_MEMSET "1" CACHE INTERNAL "Have symbol memset") | ||
65 | set(LIBC_HAS_MODF "1" CACHE INTERNAL "Have symbol modf") | ||
66 | set(LIBC_HAS_MODFF "1" CACHE INTERNAL "Have symbol modff") | ||
67 | set(LIBC_HAS_POW "1" CACHE INTERNAL "Have symbol pow") | ||
68 | set(LIBC_HAS_POWF "1" CACHE INTERNAL "Have symbol powf") | ||
69 | set(LIBC_HAS_PUTENV "1" CACHE INTERNAL "Have symbol putenv") | ||
70 | set(LIBC_HAS_REALLOC "1" CACHE INTERNAL "Have symbol realloc") | ||
71 | set(LIBC_HAS_RINDEX "1" CACHE INTERNAL "Have symbol rindex") | ||
72 | set(LIBC_HAS_ROUND "1" CACHE INTERNAL "Have symbol round") | ||
73 | set(LIBC_HAS_ROUNDF "1" CACHE INTERNAL "Have symbol roundf") | ||
74 | set(LIBC_HAS_SCALBN "1" CACHE INTERNAL "Have symbol scalbn") | ||
75 | set(LIBC_HAS_SCALBNF "1" CACHE INTERNAL "Have symbol scalbnf") | ||
76 | set(LIBC_HAS_SETENV "1" CACHE INTERNAL "Have symbol setenv") | ||
77 | set(LIBC_HAS_SIGNAL_H "1" CACHE INTERNAL "Have include signal.h") | ||
78 | set(LIBC_HAS_SIN "1" CACHE INTERNAL "Have symbol sin") | ||
79 | set(LIBC_HAS_SINF "1" CACHE INTERNAL "Have symbol sinf") | ||
80 | set(LIBC_HAS_SQR "" CACHE INTERNAL "Have symbol sqr") | ||
81 | set(LIBC_HAS_SQRT "1" CACHE INTERNAL "Have symbol sqrt") | ||
82 | set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf") | ||
83 | set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf") | ||
84 | set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h") | ||
85 | set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h") | ||
86 | set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h") | ||
87 | set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h") | ||
88 | set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h") | ||
89 | set(LIBC_HAS_STDLIB_H "1" CACHE INTERNAL "Have include stdlib.h") | ||
90 | set(LIBC_HAS_STRCASESTR "1" CACHE INTERNAL "Have symbol strcasestr") | ||
91 | set(LIBC_HAS_STRCHR "1" CACHE INTERNAL "Have symbol strchr") | ||
92 | set(LIBC_HAS_STRCMP "1" CACHE INTERNAL "Have symbol strcmp") | ||
93 | set(LIBC_HAS_STRINGS_H "1" CACHE INTERNAL "Have include strings.h") | ||
94 | set(LIBC_HAS_STRING_H "1" CACHE INTERNAL "Have include string.h") | ||
95 | set(LIBC_HAS_STRLCAT "1" CACHE INTERNAL "Have symbol strlcat") | ||
96 | set(LIBC_HAS_STRLCPY "1" CACHE INTERNAL "Have symbol strlcpy") | ||
97 | set(LIBC_HAS_STRLEN "1" CACHE INTERNAL "Have symbol strlen") | ||
98 | set(LIBC_HAS_STRNCMP "1" CACHE INTERNAL "Have symbol strncmp") | ||
99 | set(LIBC_HAS_STRNLEN "1" CACHE INTERNAL "Have symbol strnlen") | ||
100 | set(LIBC_HAS_STRNSTR "" CACHE INTERNAL "Have symbol strnstr") | ||
101 | set(LIBC_HAS_STRPBRK "1" CACHE INTERNAL "Have symbol strpbrk") | ||
102 | set(LIBC_HAS_STRRCHR "1" CACHE INTERNAL "Have symbol strrchr") | ||
103 | set(LIBC_HAS_STRSTR "1" CACHE INTERNAL "Have symbol strstr") | ||
104 | set(LIBC_HAS_STRTOD "1" CACHE INTERNAL "Have symbol strtod") | ||
105 | set(LIBC_HAS_STRTOK_R "1" CACHE INTERNAL "Have symbol strtok_r") | ||
106 | set(LIBC_HAS_STRTOL "1" CACHE INTERNAL "Have symbol strtol") | ||
107 | set(LIBC_HAS_STRTOLL "1" CACHE INTERNAL "Have symbol strtoll") | ||
108 | set(LIBC_HAS_STRTOUL "1" CACHE INTERNAL "Have symbol strtoul") | ||
109 | set(LIBC_HAS_STRTOULL "1" CACHE INTERNAL "Have symbol strtoull") | ||
110 | set(LIBC_HAS_SYS_TYPES_H "1" CACHE INTERNAL "Have include sys/types.h") | ||
111 | set(LIBC_HAS_TAN "1" CACHE INTERNAL "Have symbol tan") | ||
112 | set(LIBC_HAS_TANF "1" CACHE INTERNAL "Have symbol tanf") | ||
113 | set(LIBC_HAS_TIME_H "1" CACHE INTERNAL "Have include time.h") | ||
114 | set(LIBC_HAS_TRUNC "1" CACHE INTERNAL "Have symbol trunc") | ||
115 | set(LIBC_HAS_TRUNCF "1" CACHE INTERNAL "Have symbol truncf") | ||
116 | set(LIBC_HAS_UNSETENV "1" CACHE INTERNAL "Have symbol unsetenv") | ||
117 | set(LIBC_HAS_VSNPRINTF "1" CACHE INTERNAL "Have symbol vsnprintf") | ||
118 | set(LIBC_HAS_VSSCANF "1" CACHE INTERNAL "Have symbol vsscanf") | ||
119 | set(LIBC_HAS_WCHAR_H "1" CACHE INTERNAL "Have include wchar.h") | ||
120 | set(LIBC_HAS_WCSCMP "1" CACHE INTERNAL "Have symbol wcscmp") | ||
121 | set(LIBC_HAS_WCSDUP "1" CACHE INTERNAL "Have symbol wcsdup") | ||
122 | set(LIBC_HAS_WCSLCAT "" CACHE INTERNAL "Have symbol wcslcat") | ||
123 | set(LIBC_HAS_WCSLCPY "" CACHE INTERNAL "Have symbol wcslcpy") | ||
124 | set(LIBC_HAS_WCSLEN "1" CACHE INTERNAL "Have symbol wcslen") | ||
125 | set(LIBC_HAS_WCSNCMP "1" CACHE INTERNAL "Have symbol wcsncmp") | ||
126 | set(LIBC_HAS_WCSNLEN "1" CACHE INTERNAL "Have symbol wcsnlen") | ||
127 | set(LIBC_HAS_WCSSTR "1" CACHE INTERNAL "Have symbol wcsstr") | ||
128 | set(LIBC_HAS_WCSTOL "1" CACHE INTERNAL "Have symbol wcstol") | ||
129 | set(LIBC_HAS__EXIT "1" CACHE INTERNAL "Have symbol _Exit") | ||
130 | set(LIBC_HAS__I64TOA "" CACHE INTERNAL "Have symbol _i64toa") | ||
131 | set(LIBC_HAS__LTOA "" CACHE INTERNAL "Have symbol _ltoa") | ||
132 | set(LIBC_HAS__STRREV "" CACHE INTERNAL "Have symbol _strrev") | ||
133 | set(LIBC_HAS__UI64TOA "" CACHE INTERNAL "Have symbol _ui64toa") | ||
134 | set(LIBC_HAS__UITOA "" CACHE INTERNAL "Have symbol _uitoa") | ||
135 | set(LIBC_HAS__ULTOA "" CACHE INTERNAL "Have symbol _ultoa") | ||
136 | set(LIBC_HAS__WCSDUP "" CACHE INTERNAL "Have symbol _wcsdup") | ||
137 | set(LIBC_IS_GLIBC "" CACHE INTERNAL "Have symbol __GLIBC__") | ||
138 | set(_ALLOCA_IN_MALLOC_H "" CACHE INTERNAL "Have symbol _alloca") | ||
139 | set(SDL_CPU_EMSCRIPTEN "1" CACHE INTERNAL "Test SDL_CPU_EMSCRIPTEN") | ||
140 | set(HAVE_GCC_WALL "1" CACHE INTERNAL "Test HAVE_GCC_WALL") | ||
141 | set(HAVE_GCC_WUNDEF "1" CACHE INTERNAL "Test HAVE_GCC_WUNDEF") | ||
142 | set(HAVE_GCC_WFLOAT_CONVERSION "1" CACHE INTERNAL "Test HAVE_GCC_WFLOAT_CONVERSION") | ||
143 | set(HAVE_GCC_NO_STRICT_ALIASING "1" CACHE INTERNAL "Test HAVE_GCC_NO_STRICT_ALIASING") | ||
144 | set(HAVE_GCC_WDOCUMENTATION "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION") | ||
145 | set(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND "1" CACHE INTERNAL "Test HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND") | ||
146 | set(HAVE_GCC_COMMENT_BLOCK_COMMANDS "1" CACHE INTERNAL "Test HAVE_GCC_COMMENT_BLOCK_COMMANDS") | ||
147 | set(HAVE_GCC_WSHADOW "1" CACHE INTERNAL "Test HAVE_GCC_WSHADOW") | ||
148 | set(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS "1" CACHE INTERNAL "Test HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS") | ||
149 | set(HAVE_GCC_WIMPLICIT_FALLTHROUGH "1" CACHE INTERNAL "Test HAVE_GCC_WIMPLICIT_FALLTHROUGH") | ||
150 | set(HAVE_GCC_FVISIBILITY "1" CACHE INTERNAL "Test HAVE_GCC_FVISIBILITY") | ||
151 | set(HAVE_ST_MTIM "1" CACHE INTERNAL "Test HAVE_ST_MTIM") | ||
152 | set(HAVE_O_CLOEXEC "1" CACHE INTERNAL "Test HAVE_O_CLOEXEC") | ||
153 | set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR") | ||
154 | set(COMPILER_SUPPORTS_GCC_ATOMICS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_GCC_ATOMICS") | ||
155 | set(LINKER_SUPPORTS_VERSION_SCRIPT "" CACHE INTERNAL "Test LINKER_SUPPORTS_VERSION_SCRIPT") | ||
156 | set(LINKER_SUPPORTS_WL_NO_UNDEFINED "" CACHE INTERNAL "Test LINKER_SUPPORTS_WL_NO_UNDEFINED") | ||
157 | set(ICONV_IN_LIBC "1" CACHE INTERNAL "Test ICONV_IN_LIBC") | ||
158 | set(ICONV_IN_LIBICONV "" CACHE INTERNAL "Test ICONV_IN_LIBICONV") | ||
159 | set(LIBC_HAS_WORKING_LIBUNWIND "" CACHE INTERNAL "Test LIBC_HAS_WORKING_LIBUNWIND") | ||
160 | set(LIBUNWIND_HAS_WORKINGLIBUNWIND "" CACHE INTERNAL "Test LIBUNWIND_HAS_WORKINGLIBUNWIND") | ||
161 | set(HAVE_GETPAGESIZE "1" CACHE INTERNAL "Have symbol getpagesize") | ||
162 | set(HAVE_SIGACTION "1" CACHE INTERNAL "Have symbol sigaction") | ||
163 | set(HAVE_SA_SIGACTION "1" CACHE INTERNAL "Have symbol sa_sigaction") | ||
164 | set(HAVE_SETJMP "1" CACHE INTERNAL "Have symbol setjmp") | ||
165 | set(HAVE_NANOSLEEP "1" CACHE INTERNAL "Have symbol nanosleep") | ||
166 | set(HAVE_GMTIME_R "1" CACHE INTERNAL "Have symbol gmtime_r") | ||
167 | set(HAVE_LOCALTIME_R "1" CACHE INTERNAL "Have symbol localtime_r") | ||
168 | set(HAVE_NL_LANGINFO "1" CACHE INTERNAL "Have symbol nl_langinfo") | ||
169 | set(HAVE_SYSCONF "1" CACHE INTERNAL "Have symbol sysconf") | ||
170 | set(HAVE_SYSCTLBYNAME "" CACHE INTERNAL "Have symbol sysctlbyname") | ||
171 | set(HAVE_GETAUXVAL "" CACHE INTERNAL "Have symbol getauxval") | ||
172 | set(HAVE_ELF_AUX_INFO "" CACHE INTERNAL "Have symbol elf_aux_info") | ||
173 | set(HAVE_POLL "1" CACHE INTERNAL "Have symbol poll") | ||
174 | set(HAVE_MEMFD_CREATE "" CACHE INTERNAL "Have symbol memfd_create") | ||
175 | set(HAVE_POSIX_FALLOCATE "1" CACHE INTERNAL "Have symbol posix_fallocate") | ||
176 | set(HAVE_DLOPEN_IN_LIBC "1" CACHE INTERNAL "Have symbol dlopen") | ||
177 | endfunction() | ||
178 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/PreseedMSVCCache.cmake b/src/contrib/SDL-3.2.20/cmake/PreseedMSVCCache.cmake new file mode 100644 index 0000000..17495aa --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/PreseedMSVCCache.cmake | |||
@@ -0,0 +1,183 @@ | |||
1 | if(MSVC) | ||
2 | function(SDL_Preseed_CMakeCache) | ||
3 | set(COMPILER_SUPPORTS_W3 "1" CACHE INTERNAL "Test /W3") | ||
4 | set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS") | ||
5 | set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h") | ||
6 | set(HAVE_AUDIOCLIENT_H "1" CACHE INTERNAL "Have include audioclient.h") | ||
7 | set(HAVE_D3D11_H "1" CACHE INTERNAL "Have include d3d11_1.h") | ||
8 | set(HAVE_D3D9_H "1" CACHE INTERNAL "Have include d3d9.h") | ||
9 | set(HAVE_DDRAW_H "1" CACHE INTERNAL "Have include ddraw.h") | ||
10 | set(HAVE_DINPUT_H "1" CACHE INTERNAL "Have include dinput.h") | ||
11 | set(HAVE_DSOUND_H "1" CACHE INTERNAL "Have include dsound.h") | ||
12 | set(HAVE_DXGI_H "1" CACHE INTERNAL "Have include dxgi.h") | ||
13 | set(HAVE_LIBM "" CACHE INTERNAL "Have library m") | ||
14 | set(HAVE_MALLOC "1" CACHE INTERNAL "Have include malloc.h") | ||
15 | set(HAVE_MMDEVICEAPI_H "1" CACHE INTERNAL "Have include mmdeviceapi.h") | ||
16 | set(HAVE_SENSORSAPI_H "1" CACHE INTERNAL "Have include sensorsapi.h") | ||
17 | set(HAVE_SHELLSCALINGAPI_H "1" CACHE INTERNAL "Have include shellscalingapi.h") | ||
18 | set(HAVE_TPCSHRD_H "1" CACHE INTERNAL "Have include tpcshrd.h") | ||
19 | set(HAVE_WIN32_CC "1" CACHE INTERNAL "Test HAVE_WIN32_CC") | ||
20 | set(HAVE_XINPUT_H "1" CACHE INTERNAL "Test HAVE_XINPUT_H") | ||
21 | set(LIBC_HAS_ABS "1" CACHE INTERNAL "Have symbol abs") | ||
22 | set(LIBC_HAS_ACOS "1" CACHE INTERNAL "Have symbol acos") | ||
23 | set(LIBC_HAS_ACOSF "1" CACHE INTERNAL "Have symbol acosf") | ||
24 | set(LIBC_HAS_ASIN "1" CACHE INTERNAL "Have symbol asin") | ||
25 | set(LIBC_HAS_ASINF "1" CACHE INTERNAL "Have symbol asinf") | ||
26 | set(LIBC_HAS_ATAN "1" CACHE INTERNAL "Have symbol atan") | ||
27 | set(LIBC_HAS_ATAN2 "1" CACHE INTERNAL "Have symbol atan2") | ||
28 | set(LIBC_HAS_ATAN2F "1" CACHE INTERNAL "Have symbol atan2f") | ||
29 | set(LIBC_HAS_ATANF "1" CACHE INTERNAL "Have symbol atanf") | ||
30 | set(LIBC_HAS_ATOF "1" CACHE INTERNAL "Have symbol atof") | ||
31 | set(LIBC_HAS_ATOI "1" CACHE INTERNAL "Have symbol atoi") | ||
32 | set(LIBC_HAS_BCOPY "" CACHE INTERNAL "Have symbol bcopy") | ||
33 | set(LIBC_HAS_CALLOC "1" CACHE INTERNAL "Have symbol calloc") | ||
34 | set(LIBC_HAS_CEIL "1" CACHE INTERNAL "Have symbol ceil") | ||
35 | set(LIBC_HAS_CEILF "1" CACHE INTERNAL "Have symbol ceilf") | ||
36 | set(LIBC_HAS_COPYSIGN "1" CACHE INTERNAL "Have symbol copysign") | ||
37 | set(LIBC_HAS_COPYSIGNF "1" CACHE INTERNAL "Have symbol copysignf") | ||
38 | set(LIBC_HAS_COS "1" CACHE INTERNAL "Have symbol cos") | ||
39 | set(LIBC_HAS_COSF "1" CACHE INTERNAL "Have symbol cosf") | ||
40 | set(LIBC_HAS_EXP "1" CACHE INTERNAL "Have symbol exp") | ||
41 | set(LIBC_HAS_EXPF "1" CACHE INTERNAL "Have symbol expf") | ||
42 | set(LIBC_HAS_FABS "1" CACHE INTERNAL "Have symbol fabs") | ||
43 | set(LIBC_HAS_FABSF "1" CACHE INTERNAL "Have symbol fabsf") | ||
44 | set(LIBC_HAS_FLOAT_H "1" CACHE INTERNAL "Have include float.h") | ||
45 | set(LIBC_HAS_FLOOR "1" CACHE INTERNAL "Have symbol floor") | ||
46 | set(LIBC_HAS_FLOORF "1" CACHE INTERNAL "Have symbol floorf") | ||
47 | set(LIBC_HAS_FMOD "1" CACHE INTERNAL "Have symbol fmod") | ||
48 | set(LIBC_HAS_FMODF "1" CACHE INTERNAL "Have symbol fmodf") | ||
49 | set(LIBC_HAS_FOPEN64 "" CACHE INTERNAL "Have symbol fopen64") | ||
50 | set(LIBC_HAS_FREE "1" CACHE INTERNAL "Have symbol free") | ||
51 | set(LIBC_HAS_FSEEKO "" CACHE INTERNAL "Have symbol fseeko") | ||
52 | set(LIBC_HAS_FSEEKO64 "" CACHE INTERNAL "Have symbol fseeko64") | ||
53 | set(LIBC_HAS_GETENV "1" CACHE INTERNAL "Have symbol getenv") | ||
54 | set(LIBC_HAS_ICONV_H "" CACHE INTERNAL "Have include iconv.h") | ||
55 | set(LIBC_HAS_INDEX "" CACHE INTERNAL "Have symbol index") | ||
56 | set(LIBC_HAS_INTTYPES_H "1" CACHE INTERNAL "Have include inttypes.h") | ||
57 | set(LIBC_HAS_ISINF "1" CACHE INTERNAL "Have include isinf(double)") | ||
58 | set(LIBC_ISINF_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isinf(float)") | ||
59 | set(LIBC_HAS_ISINFF "" CACHE INTERNAL "Have include isinff(float)") | ||
60 | set(LIBC_HAS_ISNAN "1" CACHE INTERNAL "Have include isnan(double)") | ||
61 | set(LIBC_ISNAN_HANDLES_FLOAT "1" CACHE INTERNAL "Have include isnan(float)") | ||
62 | set(LIBC_HAS_ISNANF "" CACHE INTERNAL "Have include isnanf(float)") | ||
63 | set(LIBC_HAS_ITOA "1" CACHE INTERNAL "Have symbol itoa") | ||
64 | set(LIBC_HAS_LIMITS_H "1" CACHE INTERNAL "Have include limits.h") | ||
65 | set(LIBC_HAS_LOG "1" CACHE INTERNAL "Have symbol log") | ||
66 | set(LIBC_HAS_LOG10 "1" CACHE INTERNAL "Have symbol log10") | ||
67 | set(LIBC_HAS_LOG10F "1" CACHE INTERNAL "Have symbol log10f") | ||
68 | set(LIBC_HAS_LOGF "1" CACHE INTERNAL "Have symbol logf") | ||
69 | set(LIBC_HAS_LROUND "1" CACHE INTERNAL "Have symbol lround") | ||
70 | set(LIBC_HAS_LROUNDF "1" CACHE INTERNAL "Have symbol lroundf") | ||
71 | set(LIBC_HAS_MALLOC "1" CACHE INTERNAL "Have symbol malloc") | ||
72 | set(LIBC_HAS_MALLOC_H "1" CACHE INTERNAL "Have include malloc.h") | ||
73 | set(LIBC_HAS_MATH_H "1" CACHE INTERNAL "Have include math.h") | ||
74 | set(LIBC_HAS_MEMCMP "1" CACHE INTERNAL "Have symbol memcmp") | ||
75 | set(LIBC_HAS_MEMCPY "1" CACHE INTERNAL "Have symbol memcpy") | ||
76 | set(LIBC_HAS_MEMMOVE "1" CACHE INTERNAL "Have symbol memmove") | ||
77 | set(LIBC_HAS_MEMORY_H "1" CACHE INTERNAL "Have include memory.h") | ||
78 | set(LIBC_HAS_MEMSET "1" CACHE INTERNAL "Have symbol memset") | ||
79 | set(LIBC_HAS_MODF "1" CACHE INTERNAL "Have symbol modf") | ||
80 | set(LIBC_HAS_MODFF "1" CACHE INTERNAL "Have symbol modff") | ||
81 | set(LIBC_HAS_POW "1" CACHE INTERNAL "Have symbol pow") | ||
82 | set(LIBC_HAS_POWF "1" CACHE INTERNAL "Have symbol powf") | ||
83 | set(LIBC_HAS_PUTENV "1" CACHE INTERNAL "Have symbol putenv") | ||
84 | set(LIBC_HAS_REALLOC "1" CACHE INTERNAL "Have symbol realloc") | ||
85 | set(LIBC_HAS_RINDEX "" CACHE INTERNAL "Have symbol rindex") | ||
86 | set(LIBC_HAS_ROUND "1" CACHE INTERNAL "Have symbol round") | ||
87 | set(LIBC_HAS_ROUNDF "1" CACHE INTERNAL "Have symbol roundf") | ||
88 | set(LIBC_HAS_SCALBN "1" CACHE INTERNAL "Have symbol scalbn") | ||
89 | set(LIBC_HAS_SCALBNF "1" CACHE INTERNAL "Have symbol scalbnf") | ||
90 | set(LIBC_HAS_SETENV "" CACHE INTERNAL "Have symbol setenv") | ||
91 | set(LIBC_HAS_SIGNAL_H "1" CACHE INTERNAL "Have include signal.h") | ||
92 | set(LIBC_HAS_SIN "1" CACHE INTERNAL "Have symbol sin") | ||
93 | set(LIBC_HAS_SINF "1" CACHE INTERNAL "Have symbol sinf") | ||
94 | set(LIBC_HAS_SQR "" CACHE INTERNAL "Have symbol sqr") | ||
95 | set(LIBC_HAS_SQRT "1" CACHE INTERNAL "Have symbol sqrt") | ||
96 | set(LIBC_HAS_SQRTF "1" CACHE INTERNAL "Have symbol sqrtf") | ||
97 | set(LIBC_HAS_SSCANF "1" CACHE INTERNAL "Have symbol sscanf") | ||
98 | set(LIBC_HAS_STDARG_H "1" CACHE INTERNAL "Have include stdarg.h") | ||
99 | set(LIBC_HAS_STDBOOL_H "1" CACHE INTERNAL "Have include stdbool.h") | ||
100 | set(LIBC_HAS_STDDEF_H "1" CACHE INTERNAL "Have include stddef.h") | ||
101 | set(LIBC_HAS_STDINT_H "1" CACHE INTERNAL "Have include stdint.h") | ||
102 | set(LIBC_HAS_STDIO_H "1" CACHE INTERNAL "Have include stdio.h") | ||
103 | set(LIBC_HAS_STDLIB_H "1" CACHE INTERNAL "Have include stdlib.h") | ||
104 | set(LIBC_HAS_STRCHR "1" CACHE INTERNAL "Have symbol strchr") | ||
105 | set(LIBC_HAS_STRCMP "1" CACHE INTERNAL "Have symbol strcmp") | ||
106 | set(LIBC_HAS_STRINGS_H "" CACHE INTERNAL "Have include strings.h") | ||
107 | set(LIBC_HAS_STRING_H "1" CACHE INTERNAL "Have include string.h") | ||
108 | set(LIBC_HAS_STRLCAT "" CACHE INTERNAL "Have symbol strlcat") | ||
109 | set(LIBC_HAS_STRLCPY "" CACHE INTERNAL "Have symbol strlcpy") | ||
110 | set(LIBC_HAS_STRLEN "1" CACHE INTERNAL "Have symbol strlen") | ||
111 | set(LIBC_HAS_STRNCMP "1" CACHE INTERNAL "Have symbol strncmp") | ||
112 | set(LIBC_HAS_STRNLEN "1" CACHE INTERNAL "Have symbol strnlen") | ||
113 | set(LIBC_HAS_STRNSTR "" CACHE INTERNAL "Have symbol strnstr") | ||
114 | set(LIBC_HAS_STRPBRK "1" CACHE INTERNAL "Have symbol strpbrk") | ||
115 | set(LIBC_HAS_STRRCHR "1" CACHE INTERNAL "Have symbol strrchr") | ||
116 | set(LIBC_HAS_STRSTR "1" CACHE INTERNAL "Have symbol strstr") | ||
117 | set(LIBC_HAS_STRTOD "1" CACHE INTERNAL "Have symbol strtod") | ||
118 | set(LIBC_HAS_STRTOK_R "" CACHE INTERNAL "Have symbol strtok_r") | ||
119 | set(LIBC_HAS_STRTOL "1" CACHE INTERNAL "Have symbol strtol") | ||
120 | set(LIBC_HAS_STRTOLL "1" CACHE INTERNAL "Have symbol strtoll") | ||
121 | set(LIBC_HAS_STRTOUL "1" CACHE INTERNAL "Have symbol strtoul") | ||
122 | set(LIBC_HAS_STRTOULL "1" CACHE INTERNAL "Have symbol strtoull") | ||
123 | set(LIBC_HAS_SYS_TYPES_H "1" CACHE INTERNAL "Have include sys/types.h") | ||
124 | set(LIBC_HAS_TAN "1" CACHE INTERNAL "Have symbol tan") | ||
125 | set(LIBC_HAS_TANF "1" CACHE INTERNAL "Have symbol tanf") | ||
126 | set(LIBC_HAS_TIME_H "1" CACHE INTERNAL "Have include time.h") | ||
127 | set(LIBC_HAS_TRUNC "1" CACHE INTERNAL "Have symbol trunc") | ||
128 | set(LIBC_HAS_TRUNCF "1" CACHE INTERNAL "Have symbol truncf") | ||
129 | set(LIBC_HAS_UNSETENV "" CACHE INTERNAL "Have symbol unsetenv") | ||
130 | set(LIBC_HAS_VSNPRINTF "1" CACHE INTERNAL "Have symbol vsnprintf") | ||
131 | set(LIBC_HAS_VSSCANF "1" CACHE INTERNAL "Have symbol vsscanf") | ||
132 | set(LIBC_HAS_WCHAR_H "1" CACHE INTERNAL "Have include wchar.h") | ||
133 | set(LIBC_HAS_WCSCMP "1" CACHE INTERNAL "Have symbol wcscmp") | ||
134 | set(LIBC_HAS_WCSDUP "1" CACHE INTERNAL "Have symbol wcsdup") | ||
135 | set(LIBC_HAS_WCSLCAT "" CACHE INTERNAL "Have symbol wcslcat") | ||
136 | set(LIBC_HAS_WCSLCPY "" CACHE INTERNAL "Have symbol wcslcpy") | ||
137 | set(LIBC_HAS_WCSLEN "1" CACHE INTERNAL "Have symbol wcslen") | ||
138 | set(LIBC_HAS_WCSNCMP "1" CACHE INTERNAL "Have symbol wcsncmp") | ||
139 | set(LIBC_HAS_WCSNLEN "1" CACHE INTERNAL "Have symbol wcsnlen") | ||
140 | set(LIBC_HAS_WCSSTR "1" CACHE INTERNAL "Have symbol wcsstr") | ||
141 | set(LIBC_HAS_WCSTOL "1" CACHE INTERNAL "Have symbol wcstol") | ||
142 | set(LIBC_HAS__EXIT "1" CACHE INTERNAL "Have symbol _Exit") | ||
143 | set(LIBC_HAS__I64TOA "1" CACHE INTERNAL "Have symbol _i64toa") | ||
144 | set(LIBC_HAS__LTOA "1" CACHE INTERNAL "Have symbol _ltoa") | ||
145 | set(LIBC_HAS__STRREV "1" CACHE INTERNAL "Have symbol _strrev") | ||
146 | set(LIBC_HAS__UI64TOA "1" CACHE INTERNAL "Have symbol _ui64toa") | ||
147 | set(LIBC_HAS__UITOA "" CACHE INTERNAL "Have symbol _uitoa") | ||
148 | set(LIBC_HAS__ULTOA "1" CACHE INTERNAL "Have symbol _ultoa") | ||
149 | set(LIBC_HAS__WCSDUP "1" CACHE INTERNAL "Have symbol _wcsdup") | ||
150 | set(LIBC_IS_GLIBC "" CACHE INTERNAL "Have symbol __GLIBC__") | ||
151 | set(_ALLOCA_IN_MALLOC_H "" CACHE INTERNAL "Have symbol _alloca") | ||
152 | |||
153 | if(CHECK_CPU_ARCHITECTURE_X86) | ||
154 | set(COMPILER_SUPPORTS_AVX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX") | ||
155 | set(COMPILER_SUPPORTS_AVX2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX2") | ||
156 | set(COMPILER_SUPPORTS_MMX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_MMX") | ||
157 | set(COMPILER_SUPPORTS_SSE "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE") | ||
158 | set(COMPILER_SUPPORTS_SSE2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE2") | ||
159 | set(COMPILER_SUPPORTS_SSE3 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE3") | ||
160 | set(COMPILER_SUPPORTS_SSE4_1 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_1") | ||
161 | set(COMPILER_SUPPORTS_SSE4_2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_2") | ||
162 | endif() | ||
163 | |||
164 | if(CHECK_CPU_ARCHITECTURE_X64) | ||
165 | set(COMPILER_SUPPORTS_AVX "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX") | ||
166 | set(COMPILER_SUPPORTS_AVX2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_AVX2") | ||
167 | set(COMPILER_SUPPORTS_MMX "" CACHE INTERNAL "Test COMPILER_SUPPORTS_MMX") | ||
168 | set(COMPILER_SUPPORTS_SSE "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE") | ||
169 | set(COMPILER_SUPPORTS_SSE2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE2") | ||
170 | set(COMPILER_SUPPORTS_SSE3 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE3") | ||
171 | set(COMPILER_SUPPORTS_SSE4_1 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_1") | ||
172 | set(COMPILER_SUPPORTS_SSE4_2 "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_SSE4_2") | ||
173 | endif() | ||
174 | |||
175 | if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.1") | ||
176 | set(HAVE_ROAPI_H "1" CACHE INTERNAL "Have include roapi.h") | ||
177 | set(HAVE_WINDOWS_GAMING_INPUT_H "1" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H") | ||
178 | else() | ||
179 | set(HAVE_ROAPI_H "" CACHE INTERNAL "Have include roapi.h") | ||
180 | set(HAVE_WINDOWS_GAMING_INPUT_H "" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H") | ||
181 | endif() | ||
182 | endfunction() | ||
183 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/SDL3Config.cmake.in b/src/contrib/SDL-3.2.20/cmake/SDL3Config.cmake.in new file mode 100644 index 0000000..4c6f1b6 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/SDL3Config.cmake.in | |||
@@ -0,0 +1,108 @@ | |||
1 | # SDL cmake project-config input for CMakeLists.txt script | ||
2 | |||
3 | include(FeatureSummary) | ||
4 | set_package_properties(SDL3 PROPERTIES | ||
5 | URL "https://www.libsdl.org/" | ||
6 | DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware" | ||
7 | ) | ||
8 | |||
9 | @PACKAGE_INIT@ | ||
10 | |||
11 | set(SDL3_FOUND TRUE) | ||
12 | set(_sdl3_framework @SDL_FRAMEWORK@) | ||
13 | |||
14 | # Find SDL3::Headers | ||
15 | if(NOT TARGET SDL3::Headers) | ||
16 | include("${CMAKE_CURRENT_LIST_DIR}/SDL3headersTargets.cmake") | ||
17 | if(NOT CMAKE_VERSION VERSION_LESS "3.25") | ||
18 | set_property(TARGET SDL3::Headers PROPERTY SYSTEM 0) | ||
19 | endif() | ||
20 | endif() | ||
21 | set(SDL3_Headers_FOUND TRUE) | ||
22 | |||
23 | # Find SDL3::SDL3-shared | ||
24 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3sharedTargets.cmake") | ||
25 | include("${CMAKE_CURRENT_LIST_DIR}/SDL3sharedTargets.cmake") | ||
26 | set(SDL3_SDL3-shared_FOUND TRUE) | ||
27 | endif() | ||
28 | |||
29 | macro(find_sdl3_static_dependencies) | ||
30 | @SDL_FIND_PKG_CONFIG_COMMANDS@ | ||
31 | endmacro() | ||
32 | |||
33 | # Find SDL3::SDL3-static | ||
34 | if(_sdl3_framework) | ||
35 | set(SDL3_SDL3-static_FOUND TRUE) | ||
36 | find_sdl3_static_dependencies() | ||
37 | find_package(SDL3-static CONFIG) | ||
38 | if(SDL3_SDL3-static_FOUND AND SDL3-static_FOUND) | ||
39 | set(SDL3_SDL3-static_FOUND TRUE) | ||
40 | endif() | ||
41 | else() | ||
42 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake") | ||
43 | set(SDL3_SDL3-static_FOUND TRUE) | ||
44 | find_sdl3_static_dependencies() | ||
45 | if(SDL3_SDL3-static_FOUND) | ||
46 | if(ANDROID OR HAIKU) | ||
47 | enable_language(CXX) | ||
48 | endif() | ||
49 | include("${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake") | ||
50 | endif() | ||
51 | endif() | ||
52 | endif() | ||
53 | |||
54 | if(ANDROID AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake") | ||
55 | include("${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake") | ||
56 | set(SDL3_Jar_FOUND TRUE) | ||
57 | endif() | ||
58 | |||
59 | if(SDL3_SDL3-shared_FOUND OR SDL3_SDL3-static_FOUND) | ||
60 | set(SDL3_SDL3_FOUND TRUE) | ||
61 | endif() | ||
62 | |||
63 | # Find SDL3::SDL3_test | ||
64 | if(_sdl3_framework) | ||
65 | find_package(SDL3_test CONFIG) | ||
66 | if(SDL3_test_FOUND) | ||
67 | enable_language(OBJC) | ||
68 | set(SDL3_SDL3_test_FOUND TRUE) | ||
69 | endif() | ||
70 | else() | ||
71 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake") | ||
72 | set(SDL3_SDL3_test_FOUND TRUE) | ||
73 | @SDL_TEST_FIND_PKG_CONFIG_COMMANDS@ | ||
74 | if(SDL3_SDL3_test_FOUND) | ||
75 | include("${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake") | ||
76 | endif() | ||
77 | endif() | ||
78 | endif() | ||
79 | |||
80 | if(NOT SDL3_COMPONENTS AND NOT TARGET SDL3::Headers AND NOT TARGET SDL3::SDL3-shared AND NOT TARGET SDL3::SDL3-static) | ||
81 | set(SDL3_FOUND FALSE) | ||
82 | endif() | ||
83 | check_required_components(SDL3) | ||
84 | |||
85 | function(_sdl_create_target_alias_compat NEW_TARGET TARGET) | ||
86 | if(CMAKE_VERSION VERSION_LESS "3.18") | ||
87 | # Aliasing local targets is not supported on CMake < 3.18, so make it global. | ||
88 | add_library(${NEW_TARGET} INTERFACE IMPORTED) | ||
89 | set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}") | ||
90 | else() | ||
91 | add_library(${NEW_TARGET} ALIAS ${TARGET}) | ||
92 | endif() | ||
93 | endfunction() | ||
94 | |||
95 | # Make sure SDL3::SDL3 always exists | ||
96 | if(NOT TARGET SDL3::SDL3) | ||
97 | if(TARGET SDL3::SDL3-shared) | ||
98 | _sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-shared) | ||
99 | elseif(TARGET SDL3::SDL3-static) | ||
100 | _sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-static) | ||
101 | endif() | ||
102 | endif() | ||
103 | |||
104 | set(SDL3_LIBRARIES SDL3::SDL3) | ||
105 | set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static) | ||
106 | set(SDL3_STATIC_PRIVATE_LIBS) | ||
107 | |||
108 | set(SDL3TEST_LIBRARY SDL3::SDL3_test) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/SDL3jarTargets.cmake.in b/src/contrib/SDL-3.2.20/cmake/SDL3jarTargets.cmake.in new file mode 100644 index 0000000..732d293 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/SDL3jarTargets.cmake.in | |||
@@ -0,0 +1,10 @@ | |||
1 | @PACKAGE_INIT@ | ||
2 | |||
3 | set_and_check(SDL3_JAR "@PACKAGE_SDL_INSTALL_JAVADIR@/SDL3/SDL3-@SDL3_VERSION@.jar") | ||
4 | |||
5 | if(NOT TARGET SDL3::Jar) | ||
6 | add_library(SDL3::Jar INTERFACE IMPORTED) | ||
7 | set_property(TARGET SDL3::Jar PROPERTY JAR_FILE "${SDL3_JAR}") | ||
8 | endif() | ||
9 | |||
10 | unset(SDL3_JAR) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroid.cmake b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroid.cmake new file mode 100644 index 0000000..851848f --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroid.cmake | |||
@@ -0,0 +1,103 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | FindSdlAndroid | ||
4 | ---------------------- | ||
5 | |||
6 | Locate various executables that are essential to creating an Android APK archive. | ||
7 | This find module uses the FindSdlAndroidBuildTools module to locate some Android utils. | ||
8 | |||
9 | |||
10 | Imported targets | ||
11 | ^^^^^^^^^^^^^^^^ | ||
12 | |||
13 | This module defines the following :prop_tgt:`IMPORTED` target(s): | ||
14 | |||
15 | `` SdlAndroid::aapt2 `` | ||
16 | Imported executable for the "android package tool" v2 | ||
17 | |||
18 | `` SdlAndroid::apksigner`` | ||
19 | Imported executable for the APK signer tool | ||
20 | |||
21 | `` SdlAndroid::d8 `` | ||
22 | Imported executable for the dex compiler | ||
23 | |||
24 | `` SdlAndroid::zipalign `` | ||
25 | Imported executable for the zipalign util | ||
26 | |||
27 | `` SdlAndroid::adb `` | ||
28 | Imported executable for the "android debug bridge" tool | ||
29 | |||
30 | `` SdlAndroid::keytool `` | ||
31 | Imported executable for the keytool, a key and certificate management utility | ||
32 | |||
33 | `` SdlAndroid::zip `` | ||
34 | Imported executable for the zip, for packaging and compressing files | ||
35 | |||
36 | Result variables | ||
37 | ^^^^^^^^^^^^^^^^ | ||
38 | |||
39 | This module will set the following variables in your project: | ||
40 | |||
41 | `` AAPT2_BIN `` | ||
42 | Path of aapt2 | ||
43 | |||
44 | `` APKSIGNER_BIN `` | ||
45 | Path of apksigner | ||
46 | |||
47 | `` D8_BIN `` | ||
48 | Path of d8 | ||
49 | |||
50 | `` ZIPALIGN_BIN `` | ||
51 | Path of zipalign | ||
52 | |||
53 | `` ADB_BIN `` | ||
54 | Path of adb | ||
55 | |||
56 | `` KEYTOOL_BIN `` | ||
57 | Path of keytool | ||
58 | |||
59 | `` ZIP_BIN `` | ||
60 | Path of zip | ||
61 | |||
62 | #]=======================================================================] | ||
63 | |||
64 | cmake_minimum_required(VERSION 3.7...3.28) | ||
65 | |||
66 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
67 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
68 | endif() | ||
69 | |||
70 | find_package(SdlAndroidBuildTools MODULE) | ||
71 | |||
72 | function(_sdl_android_find_create_imported_executable NAME) | ||
73 | string(TOUPPER "${NAME}" NAME_UPPER) | ||
74 | set(varname "${NAME_UPPER}_BIN") | ||
75 | find_program("${varname}" NAMES "${NAME}" PATHS ${SDL_ANDROID_BUILD_TOOLS_ROOT}) | ||
76 | if(EXISTS "${${varname}}" AND NOT TARGET SdlAndroid::${NAME}) | ||
77 | add_executable(SdlAndroid::${NAME} IMPORTED) | ||
78 | set_property(TARGET SdlAndroid::${NAME} PROPERTY IMPORTED_LOCATION "${${varname}}") | ||
79 | endif() | ||
80 | endfunction() | ||
81 | |||
82 | if(SdlAndroidBuildTools_FOUND) | ||
83 | _sdl_android_find_create_imported_executable(aapt2) | ||
84 | _sdl_android_find_create_imported_executable(apksigner) | ||
85 | _sdl_android_find_create_imported_executable(d8) | ||
86 | _sdl_android_find_create_imported_executable(zipalign) | ||
87 | endif() | ||
88 | |||
89 | _sdl_android_find_create_imported_executable(adb) | ||
90 | _sdl_android_find_create_imported_executable(keytool) | ||
91 | _sdl_android_find_create_imported_executable(zip) | ||
92 | include(FindPackageHandleStandardArgs) | ||
93 | |||
94 | find_package_handle_standard_args(SdlAndroid | ||
95 | VERSION_VAR | ||
96 | REQUIRED_VARS | ||
97 | AAPT2_BIN | ||
98 | APKSIGNER_BIN | ||
99 | D8_BIN | ||
100 | ZIPALIGN_BIN | ||
101 | KEYTOOL_BIN | ||
102 | ZIP_BIN | ||
103 | ) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidBuildTools.cmake b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidBuildTools.cmake new file mode 100644 index 0000000..999a268 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidBuildTools.cmake | |||
@@ -0,0 +1,115 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | FindSdlAndroidBuildTools | ||
4 | ---------------------- | ||
5 | |||
6 | Locate the Android build tools directory. | ||
7 | |||
8 | |||
9 | Imported targets | ||
10 | ^^^^^^^^^^^^^^^^ | ||
11 | |||
12 | This find module defines the following :prop_tgt:`IMPORTED` target(s): | ||
13 | |||
14 | <none> | ||
15 | |||
16 | Result variables | ||
17 | ^^^^^^^^^^^^^^^^ | ||
18 | |||
19 | This module will set the following variables in your project: | ||
20 | |||
21 | `` SdlAndroidBuildTools_FOUND | ||
22 | if false, no Android build tools have been found | ||
23 | |||
24 | `` SDL_ANDROID_BUILD_TOOLS_ROOT | ||
25 | path of the Android build tools root directory if found | ||
26 | |||
27 | `` SDL_ANDROID_BUILD_TOOLS_VERSION | ||
28 | the human-readable string containing the android build tools version if found | ||
29 | |||
30 | Cache variables | ||
31 | ^^^^^^^^^^^^^^^ | ||
32 | |||
33 | These variables may optionally be set to help this module find the correct files: | ||
34 | |||
35 | ``SDL_ANDROID_BUILD_TOOLS_ROOT`` | ||
36 | path of the Android build tools root directory | ||
37 | |||
38 | |||
39 | Variables for locating Android platform | ||
40 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
41 | |||
42 | This module responds to the flags: | ||
43 | |||
44 | ``SDL_ANDROID_HOME | ||
45 | First, this module will look for platforms in this CMake variable. | ||
46 | |||
47 | ``ANDROID_HOME | ||
48 | If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`. | ||
49 | |||
50 | ``$ENV{ANDROID_HOME} | ||
51 | If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}` | ||
52 | |||
53 | #]=======================================================================] | ||
54 | |||
55 | cmake_minimum_required(VERSION 3.7...3.28) | ||
56 | |||
57 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
58 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
59 | endif() | ||
60 | |||
61 | function(_sdl_is_valid_android_build_tools_root RESULT VERSION BUILD_TOOLS_ROOT) | ||
62 | set(result TRUE) | ||
63 | set(version -1) | ||
64 | |||
65 | string(REGEX MATCH "/([0-9.]+)$" root_match "${BUILD_TOOLS_ROOT}") | ||
66 | if(root_match | ||
67 | AND EXISTS "${BUILD_TOOLS_ROOT}/aapt2" | ||
68 | AND EXISTS "${BUILD_TOOLS_ROOT}/apksigner" | ||
69 | AND EXISTS "${BUILD_TOOLS_ROOT}/d8" | ||
70 | AND EXISTS "${BUILD_TOOLS_ROOT}/zipalign") | ||
71 | set(result "${BUILD_TOOLS_ROOT}") | ||
72 | set(version "${CMAKE_MATCH_1}") | ||
73 | endif() | ||
74 | |||
75 | set(${RESULT} ${result} PARENT_SCOPE) | ||
76 | set(${VERSION} ${version} PARENT_SCOPE) | ||
77 | endfunction() | ||
78 | |||
79 | function(_find_sdl_android_build_tools_root ROOT) | ||
80 | cmake_parse_arguments(fsabtr "" "" "" ${ARGN}) | ||
81 | set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME}) | ||
82 | set(root ${ROOT}-NOTFOUND) | ||
83 | foreach(home IN LISTS homes) | ||
84 | if(NOT IS_DIRECTORY "${home}") | ||
85 | continue() | ||
86 | endif() | ||
87 | file(GLOB build_tools_roots LIST_DIRECTORIES true "${home}/build-tools/*") | ||
88 | set(max_build_tools_version -1) | ||
89 | set(max_build_tools_root "") | ||
90 | foreach(build_tools_root IN LISTS build_tools_roots) | ||
91 | _sdl_is_valid_android_build_tools_root(is_valid build_tools_version "${build_tools_root}") | ||
92 | if(is_valid AND build_tools_version GREATER max_build_tools_version) | ||
93 | set(max_build_tools_version "${build_tools_version}") | ||
94 | set(max_build_tools_root "${build_tools_root}") | ||
95 | endif() | ||
96 | endforeach() | ||
97 | if(max_build_tools_version GREATER -1) | ||
98 | set(root ${max_build_tools_root}) | ||
99 | break() | ||
100 | endif() | ||
101 | endforeach() | ||
102 | set(${ROOT} ${root} PARENT_SCOPE) | ||
103 | endfunction() | ||
104 | |||
105 | if(NOT DEFINED SDL_ANDROID_BUILD_TOOLS_ROOT) | ||
106 | _find_sdl_android_build_tools_root(SDL_ANDROID_BUILD_TOOLS_ROOT) | ||
107 | set(SDL_ANDROID_BUILD_TOOLS_ROOT "${SDL_ANDROID_BUILD_TOOLS_ROOT}" CACHE PATH "Path of Android build tools") | ||
108 | endif() | ||
109 | |||
110 | include(FindPackageHandleStandardArgs) | ||
111 | |||
112 | find_package_handle_standard_args(SdlAndroidBuildTools | ||
113 | VERSION_VAR SDL_ANDROID_BUILD_TOOLS_VERSION | ||
114 | REQUIRED_VARS SDL_ANDROID_BUILD_TOOLS_ROOT | ||
115 | ) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake new file mode 100644 index 0000000..fbe53c3 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/FindSdlAndroidPlatform.cmake | |||
@@ -0,0 +1,124 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | FindSdlAndroidPlatform | ||
4 | ---------------------- | ||
5 | |||
6 | Locate the Android SDK platform. | ||
7 | |||
8 | |||
9 | Imported targets | ||
10 | ^^^^^^^^^^^^^^^^ | ||
11 | |||
12 | This module defines the following :prop_tgt:`IMPORTED` target(s): | ||
13 | |||
14 | <none> | ||
15 | |||
16 | Result variables | ||
17 | ^^^^^^^^^^^^^^^^ | ||
18 | |||
19 | This find module will set the following variables in your project: | ||
20 | |||
21 | `` SdlAndroidPlatform_FOUND | ||
22 | if false, no Android platform has been found | ||
23 | |||
24 | `` SDL_ANDROID_PLATFORM_ROOT | ||
25 | path of the Android SDK platform root directory if found | ||
26 | |||
27 | `` SDL_ANDROID_PLATFORM_ANDROID_JAR | ||
28 | path of the Android SDK platform jar file if found | ||
29 | |||
30 | `` SDL_ANDROID_PLATFORM_VERSION | ||
31 | the human-readable string containing the android platform version if found | ||
32 | |||
33 | Cache variables | ||
34 | ^^^^^^^^^^^^^^^ | ||
35 | |||
36 | These variables may optionally be set to help this module find the correct files: | ||
37 | |||
38 | ``SDL_ANDROID_PLATFORM_ROOT`` | ||
39 | path of the Android SDK platform root directory | ||
40 | |||
41 | |||
42 | Variables for locating Android platform | ||
43 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
44 | |||
45 | This module responds to the flags: | ||
46 | |||
47 | ``SDL_ANDROID_HOME | ||
48 | First, this module will look for platforms in this CMake variable. | ||
49 | |||
50 | ``ANDROID_HOME | ||
51 | If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`. | ||
52 | |||
53 | ``$ENV{ANDROID_HOME} | ||
54 | If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}` | ||
55 | |||
56 | #]=======================================================================] | ||
57 | |||
58 | cmake_minimum_required(VERSION 3.7...3.28) | ||
59 | |||
60 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
61 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
62 | endif() | ||
63 | |||
64 | function(_sdl_is_valid_android_platform_root RESULT VERSION PLATFORM_ROOT) | ||
65 | set(result FALSE) | ||
66 | set(version -1) | ||
67 | |||
68 | string(REGEX MATCH "/android-([0-9]+)$" root_match "${PLATFORM_ROOT}") | ||
69 | if(root_match AND EXISTS "${PLATFORM_ROOT}/android.jar") | ||
70 | set(result TRUE) | ||
71 | set(version "${CMAKE_MATCH_1}") | ||
72 | endif() | ||
73 | |||
74 | set(${RESULT} ${result} PARENT_SCOPE) | ||
75 | set(${VERSION} ${version} PARENT_SCOPE) | ||
76 | endfunction() | ||
77 | |||
78 | function(_sdl_find_android_platform_root ROOT) | ||
79 | cmake_parse_arguments(sfapr "" "" "" ${ARGN}) | ||
80 | set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME}) | ||
81 | set(root ${ROOT}-NOTFOUND) | ||
82 | foreach(home IN LISTS homes) | ||
83 | if(NOT IS_DIRECTORY "${home}") | ||
84 | continue() | ||
85 | endif() | ||
86 | file(GLOB platform_roots LIST_DIRECTORIES true "${home}/platforms/*") | ||
87 | set(max_platform_version -1) | ||
88 | set(max_platform_root "") | ||
89 | foreach(platform_root IN LISTS platform_roots) | ||
90 | _sdl_is_valid_android_platform_root(is_valid platform_version "${platform_root}") | ||
91 | if(is_valid AND platform_version GREATER max_platform_version) | ||
92 | set(max_platform_version "${platform_version}") | ||
93 | set(max_platform_root "${platform_root}") | ||
94 | endif() | ||
95 | endforeach() | ||
96 | if(max_platform_version GREATER -1) | ||
97 | set(root ${max_platform_root}) | ||
98 | break() | ||
99 | endif() | ||
100 | endforeach() | ||
101 | set(${ROOT} ${root} PARENT_SCOPE) | ||
102 | endfunction() | ||
103 | |||
104 | set(SDL_ANDROID_PLATFORM_ANDROID_JAR "SDL_ANDROID_PLATFORM_ANDROID_JAR-NOTFOUND") | ||
105 | |||
106 | if(NOT DEFINED SDL_ANDROID_PLATFORM_ROOT) | ||
107 | _sdl_find_android_platform_root(_new_sdl_android_platform_root) | ||
108 | set(SDL_ANDROID_PLATFORM_ROOT "${_new_sdl_android_platform_root}" CACHE PATH "Path of Android platform") | ||
109 | unset(_new_sdl_android_platform_root) | ||
110 | endif() | ||
111 | if(SDL_ANDROID_PLATFORM_ROOT) | ||
112 | _sdl_is_valid_android_platform_root(_valid SDL_ANDROID_PLATFORM_VERSION "${SDL_ANDROID_PLATFORM_ROOT}") | ||
113 | if(_valid) | ||
114 | set(SDL_ANDROID_PLATFORM_ANDROID_JAR "${SDL_ANDROID_PLATFORM_ROOT}/android.jar") | ||
115 | endif() | ||
116 | unset(_valid) | ||
117 | endif() | ||
118 | |||
119 | include(FindPackageHandleStandardArgs) | ||
120 | |||
121 | find_package_handle_standard_args(SdlAndroidPlatform | ||
122 | VERSION_VAR SDL_ANDROID_PLATFORM_VERSION | ||
123 | REQUIRED_VARS SDL_ANDROID_PLATFORM_ROOT SDL_ANDROID_PLATFORM_ANDROID_JAR | ||
124 | ) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidFunctions.cmake b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidFunctions.cmake new file mode 100644 index 0000000..4acce47 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidFunctions.cmake | |||
@@ -0,0 +1,276 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | This CMake script contains functions to build an Android APK. | ||
4 | It is (currently) limited to packaging binaries for a single architecture. | ||
5 | |||
6 | #]=======================================================================] | ||
7 | |||
8 | cmake_minimum_required(VERSION 3.7...3.28) | ||
9 | |||
10 | if(NOT PROJECT_NAME MATCHES "^SDL.*") | ||
11 | message(WARNING "This module is internal to SDL and is currently not supported.") | ||
12 | endif() | ||
13 | |||
14 | function(_sdl_create_outdir_for_target OUTDIRECTORY TARGET) | ||
15 | set(outdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir") | ||
16 | # Some CMake versions have a slow `cmake -E make_directory` implementation | ||
17 | if(NOT IS_DIRECTORY "${outdir}") | ||
18 | execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${outdir}") | ||
19 | endif() | ||
20 | set("${OUTDIRECTORY}" "${outdir}" PARENT_SCOPE) | ||
21 | endfunction() | ||
22 | |||
23 | function(sdl_create_android_debug_keystore TARGET) | ||
24 | set(output "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_debug.keystore") | ||
25 | add_custom_command(OUTPUT ${output} | ||
26 | COMMAND ${CMAKE_COMMAND} -E rm -f "${output}" | ||
27 | 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" | ||
28 | ) | ||
29 | add_custom_target(${TARGET} DEPENDS "${output}") | ||
30 | set_property(TARGET ${TARGET} PROPERTY OUTPUT "${output}") | ||
31 | endfunction() | ||
32 | |||
33 | function(sdl_android_compile_resources TARGET) | ||
34 | cmake_parse_arguments(arg "" "RESFOLDER" "RESOURCES" ${ARGN}) | ||
35 | |||
36 | if(NOT arg_RESFOLDER AND NOT arg_RESOURCES) | ||
37 | message(FATAL_ERROR "Missing RESFOLDER or RESOURCES argument (need one or both)") | ||
38 | endif() | ||
39 | _sdl_create_outdir_for_target(outdir "${TARGET}") | ||
40 | set(out_files "") | ||
41 | |||
42 | set(res_files "") | ||
43 | if(arg_RESFOLDER) | ||
44 | get_filename_component(arg_RESFOLDER "${arg_RESFOLDER}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
45 | file(GLOB_RECURSE res_folder_files "${arg_RESFOLDER}/*") | ||
46 | list(APPEND res_files ${res_folder_files}) | ||
47 | |||
48 | foreach(res_file IN LISTS res_files) | ||
49 | file(RELATIVE_PATH rel_res_file "${arg_RESFOLDER}" "${res_file}") | ||
50 | string(REPLACE "/" "_" rel_comp_path "${rel_res_file}") | ||
51 | if(res_file MATCHES ".*res/values.*\\.xml$") | ||
52 | string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}") | ||
53 | endif() | ||
54 | set(comp_path "${outdir}/${rel_comp_path}.flat") | ||
55 | add_custom_command( | ||
56 | OUTPUT "${comp_path}" | ||
57 | COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}" | ||
58 | DEPENDS ${res_file} | ||
59 | ) | ||
60 | list(APPEND out_files "${comp_path}") | ||
61 | endforeach() | ||
62 | endif() | ||
63 | |||
64 | if(arg_RESOURCES) | ||
65 | list(APPEND res_files ${arg_RESOURCES}) | ||
66 | foreach(res_file IN LISTS arg_RESOURCES) | ||
67 | string(REGEX REPLACE ".*/res/" "" rel_res_file ${res_file}) | ||
68 | string(REPLACE "/" "_" rel_comp_path "${rel_res_file}") | ||
69 | if(res_file MATCHES ".*res/values.*\\.xml$") | ||
70 | string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}") | ||
71 | endif() | ||
72 | set(comp_path "${outdir}/${rel_comp_path}.flat") | ||
73 | add_custom_command( | ||
74 | OUTPUT "${comp_path}" | ||
75 | COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}" | ||
76 | DEPENDS ${res_file} | ||
77 | ) | ||
78 | list(APPEND out_files "${comp_path}") | ||
79 | endforeach() | ||
80 | endif() | ||
81 | |||
82 | add_custom_target(${TARGET} DEPENDS ${out_files}) | ||
83 | set_property(TARGET "${TARGET}" PROPERTY OUTPUTS "${out_files}") | ||
84 | set_property(TARGET "${TARGET}" PROPERTY SOURCES "${res_files}") | ||
85 | endfunction() | ||
86 | |||
87 | function(sdl_android_link_resources TARGET) | ||
88 | cmake_parse_arguments(arg "NO_DEBUG" "MIN_SDK_VERSION;TARGET_SDK_VERSION;ANDROID_JAR;OUTPUT_APK;MANIFEST;PACKAGE" "RES_TARGETS" ${ARGN}) | ||
89 | |||
90 | if(arg_MANIFEST) | ||
91 | get_filename_component(arg_MANIFEST "${arg_MANIFEST}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
92 | else() | ||
93 | message(FATAL_ERROR "sdl_add_android_link_resources_target requires a Android MANIFEST path (${arg_MANIFEST})") | ||
94 | endif() | ||
95 | if(NOT arg_PACKAGE) | ||
96 | file(READ "${arg_MANIFEST}" manifest_contents) | ||
97 | string(REGEX MATCH "package=\"([a-zA-Z0-9_.]+)\"" package_match "${manifest_contents}") | ||
98 | if(NOT package_match) | ||
99 | message(FATAL_ERROR "Could not extract package from Android manifest (${arg_MANIFEST})") | ||
100 | endif() | ||
101 | set(arg_PACKAGE "${CMAKE_MATCH_1}") | ||
102 | endif() | ||
103 | |||
104 | set(depends "") | ||
105 | |||
106 | _sdl_create_outdir_for_target(outdir "${TARGET}") | ||
107 | string(REPLACE "." "/" java_r_path "${arg_PACKAGE}") | ||
108 | get_filename_component(java_r_path "${java_r_path}" ABSOLUTE BASE_DIR "${outdir}") | ||
109 | set(java_r_path "${java_r_path}/R.java") | ||
110 | |||
111 | set(command SdlAndroid::aapt2 link) | ||
112 | if(NOT arg_NO_DEBUG) | ||
113 | list(APPEND command --debug-mode) | ||
114 | endif() | ||
115 | if(arg_MIN_SDK_VERSION) | ||
116 | list(APPEND command --min-sdk-version ${arg_MIN_SDK_VERSION}) | ||
117 | endif() | ||
118 | if(arg_TARGET_SDK_VERSION) | ||
119 | list(APPEND command --target-sdk-version ${arg_TARGET_SDK_VERSION}) | ||
120 | endif() | ||
121 | if(arg_ANDROID_JAR) | ||
122 | list(APPEND command -I "${arg_ANDROID_JAR}") | ||
123 | else() | ||
124 | list(APPEND command -I "${SDL_ANDROID_PLATFORM_ANDROID_JAR}") | ||
125 | endif() | ||
126 | if(NOT arg_OUTPUT_APK) | ||
127 | set(arg_OUTPUT_APK "${TARGET}.apk") | ||
128 | endif() | ||
129 | get_filename_component(arg_OUTPUT_APK "${arg_OUTPUT_APK}" ABSOLUTE BASE_DIR "${outdir}") | ||
130 | list(APPEND command -o "${arg_OUTPUT_APK}") | ||
131 | list(APPEND command --java "${outdir}") | ||
132 | list(APPEND command --manifest "${arg_MANIFEST}") | ||
133 | foreach(res_target IN LISTS arg_RES_TARGETS) | ||
134 | list(APPEND command $<TARGET_PROPERTY:${res_target},OUTPUTS>) | ||
135 | list(APPEND depends $<TARGET_PROPERTY:${res_target},OUTPUTS>) | ||
136 | endforeach() | ||
137 | add_custom_command( | ||
138 | OUTPUT "${arg_OUTPUT_APK}" "${java_r_path}" | ||
139 | COMMAND ${command} | ||
140 | DEPENDS ${depends} ${arg_MANIFEST} | ||
141 | COMMAND_EXPAND_LISTS | ||
142 | VERBATIM | ||
143 | ) | ||
144 | add_custom_target(${TARGET} DEPENDS "${arg_OUTPUT_APK}" "${java_r_path}") | ||
145 | set_property(TARGET ${TARGET} PROPERTY OUTPUT "${arg_OUTPUT_APK}") | ||
146 | set_property(TARGET ${TARGET} PROPERTY JAVA_R "${java_r_path}") | ||
147 | set_property(TARGET ${TARGET} PROPERTY OUTPUTS "${${arg_OUTPUT_APK}};${java_r_path}") | ||
148 | endfunction() | ||
149 | |||
150 | function(sdl_add_to_apk_unaligned TARGET) | ||
151 | cmake_parse_arguments(arg "" "APK_IN;NAME;OUTDIR" "ASSETS;NATIVE_LIBS;DEX" ${ARGN}) | ||
152 | |||
153 | if(NOT arg_APK_IN) | ||
154 | message(FATAL_ERROR "Missing APK_IN argument") | ||
155 | endif() | ||
156 | |||
157 | if(NOT TARGET ${arg_APK_IN}) | ||
158 | message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk") | ||
159 | endif() | ||
160 | |||
161 | _sdl_create_outdir_for_target(workdir ${TARGET}) | ||
162 | |||
163 | if(NOT arg_OUTDIR) | ||
164 | set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
165 | endif() | ||
166 | |||
167 | if(NOT arg_NAME) | ||
168 | string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}") | ||
169 | if(NOT arg_NAME MATCHES "\\.apk") | ||
170 | set(arg_NAME "${arg_NAME}.apk") | ||
171 | endif() | ||
172 | endif() | ||
173 | get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}") | ||
174 | |||
175 | set(apk_libdir "lib/${ANDROID_ABI}") | ||
176 | |||
177 | set(depends "") | ||
178 | |||
179 | set(commands | ||
180 | COMMAND "${CMAKE_COMMAND}" -E remove_directory -rf "${apk_libdir}" "assets" | ||
181 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${apk_libdir}" "assets" | ||
182 | COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>" "${apk_file}" | ||
183 | ) | ||
184 | |||
185 | set(dex_i "1") | ||
186 | foreach(dex IN LISTS arg_DEX) | ||
187 | set(suffix "${dex_i}") | ||
188 | if(suffix STREQUAL "1") | ||
189 | set(suffix "") | ||
190 | endif() | ||
191 | list(APPEND commands | ||
192 | COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${dex},OUTPUT>" "classes${suffix}.dex" | ||
193 | COMMAND SdlAndroid::zip -u -q -j "${apk_file}" "classes${suffix}.dex" | ||
194 | ) | ||
195 | math(EXPR dex_i "${dex_i}+1") | ||
196 | list(APPEND depends "$<TARGET_PROPERTY:${dex},OUTPUT>") | ||
197 | endforeach() | ||
198 | |||
199 | foreach(native_lib IN LISTS arg_NATIVE_LIBS) | ||
200 | list(APPEND commands | ||
201 | COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${native_lib}> "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>" | ||
202 | COMMAND SdlAndroid::zip -u -q "${apk_file}" "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>" | ||
203 | ) | ||
204 | endforeach() | ||
205 | if(arg_ASSETS) | ||
206 | list(APPEND commands | ||
207 | COMMAND "${CMAKE_COMMAND}" -E copy ${arg_ASSETS} "assets" | ||
208 | COMMAND SdlAndroid::zip -u -r -q "${apk_file}" "assets" | ||
209 | ) | ||
210 | endif() | ||
211 | |||
212 | add_custom_command(OUTPUT "${apk_file}" | ||
213 | ${commands} | ||
214 | DEPENDS ${arg_NATIVE_LIBS} ${depends} "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>" | ||
215 | WORKING_DIRECTORY "${workdir}" | ||
216 | ) | ||
217 | add_custom_target(${TARGET} DEPENDS "${apk_file}") | ||
218 | set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}") | ||
219 | endfunction() | ||
220 | |||
221 | function(sdl_apk_align TARGET APK_IN) | ||
222 | cmake_parse_arguments(arg "" "NAME;OUTDIR" "" ${ARGN}) | ||
223 | |||
224 | if(NOT TARGET ${arg_APK_IN}) | ||
225 | message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk") | ||
226 | endif() | ||
227 | |||
228 | if(NOT arg_OUTDIR) | ||
229 | set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
230 | endif() | ||
231 | |||
232 | if(NOT arg_NAME) | ||
233 | string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}") | ||
234 | if(NOT arg_NAME MATCHES "\\.apk") | ||
235 | set(arg_NAME "${arg_NAME}.apk") | ||
236 | endif() | ||
237 | endif() | ||
238 | get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}") | ||
239 | |||
240 | add_custom_command(OUTPUT "${apk_file}" | ||
241 | COMMAND SdlAndroid::zipalign -f 4 "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "${apk_file}" | ||
242 | DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" | ||
243 | ) | ||
244 | add_custom_target(${TARGET} DEPENDS "${apk_file}") | ||
245 | set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}") | ||
246 | endfunction() | ||
247 | |||
248 | function(sdl_apk_sign TARGET APK_IN) | ||
249 | cmake_parse_arguments(arg "" "OUTPUT;KEYSTORE" "" ${ARGN}) | ||
250 | |||
251 | if(NOT TARGET ${arg_APK_IN}) | ||
252 | message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk") | ||
253 | endif() | ||
254 | |||
255 | if(NOT TARGET ${arg_KEYSTORE}) | ||
256 | message(FATAL_ERROR "APK_KEYSTORE (${APK_KEYSTORE}) must be a target providing a keystore") | ||
257 | endif() | ||
258 | |||
259 | if(NOT arg_OUTPUT) | ||
260 | string(REGEX REPLACE "[:-]+" "." arg_OUTPUT "${TARGET}") | ||
261 | if(NOT arg_OUTPUT MATCHES "\\.apk") | ||
262 | set(arg_OUTPUT "${arg_OUTPUT}.apk") | ||
263 | endif() | ||
264 | endif() | ||
265 | get_filename_component(apk_file "${arg_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
266 | |||
267 | add_custom_command(OUTPUT "${apk_file}" | ||
268 | COMMAND SdlAndroid::apksigner sign | ||
269 | --ks "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>" | ||
270 | --ks-pass pass:android --in "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" --out "${apk_file}" | ||
271 | DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>" | ||
272 | BYPRODUCTS "${apk_file}.idsig" | ||
273 | ) | ||
274 | add_custom_target(${TARGET} DEPENDS "${apk_file}") | ||
275 | set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}") | ||
276 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake new file mode 100644 index 0000000..15dea2d --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake | |||
@@ -0,0 +1,74 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | This CMake script is meant to be used in CMake script mode (cmake -P). | ||
4 | It wraps commands that communicate with an actual Android device. | ||
5 | Because | ||
6 | |||
7 | #]=======================================================================] | ||
8 | |||
9 | cmake_minimum_required(VERSION 3.16...3.28) | ||
10 | |||
11 | if(NOT CMAKE_SCRIPT_MODE_FILE) | ||
12 | message(FATAL_ERROR "This file can only be used in CMake script mode") | ||
13 | endif() | ||
14 | if(NOT ADB) | ||
15 | set(ADB "adb") | ||
16 | endif() | ||
17 | |||
18 | if(NOT ACTION) | ||
19 | message(FATAL_ERROR "Missing ACTION argument") | ||
20 | endif() | ||
21 | |||
22 | if(ACTION STREQUAL "uninstall") | ||
23 | # The uninstall action attempts to uninstall all packages. All failures are ignored. | ||
24 | foreach(package IN LISTS PACKAGES) | ||
25 | message("Uninstalling ${package} ...") | ||
26 | execute_process( | ||
27 | COMMAND ${ADB} uninstall ${package} | ||
28 | RESULT_VARIABLE res | ||
29 | ) | ||
30 | message("... result=${res}") | ||
31 | endforeach() | ||
32 | elseif(ACTION STREQUAL "install") | ||
33 | # The install actions attempts to install APK's to an Android device using adb. Failures are ignored. | ||
34 | set(failed_apks "") | ||
35 | foreach(apk IN LISTS APKS) | ||
36 | message("Installing ${apk} ...") | ||
37 | execute_process( | ||
38 | COMMAND ${ADB} install -d -r --streaming ${apk} | ||
39 | RESULT_VARIABLE res | ||
40 | ) | ||
41 | message("... result=${res}") | ||
42 | if(NOT res EQUAL 0) | ||
43 | list(APPEND failed_apks ${apk}) | ||
44 | endif() | ||
45 | endforeach() | ||
46 | if(failed_apks) | ||
47 | message(FATAL_ERROR "Failed to install ${failed_apks}") | ||
48 | endif() | ||
49 | elseif(ACTION STREQUAL "build-install-run") | ||
50 | if(NOT EXECUTABLES) | ||
51 | message(FATAL_ERROR "Missing EXECUTABLES (don't know what executables to build/install and start") | ||
52 | endif() | ||
53 | if(NOT BUILD_FOLDER) | ||
54 | message(FATAL_ERROR "Missing BUILD_FOLDER (don't know where to build the APK's") | ||
55 | endif() | ||
56 | set(install_targets "") | ||
57 | foreach(executable IN LISTS EXECUTABLES) | ||
58 | list(APPEND install_targets "install-${executable}") | ||
59 | endforeach() | ||
60 | execute_process( | ||
61 | COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target ${install_targets} | ||
62 | RESULT_VARIABLE res | ||
63 | ) | ||
64 | if(NOT res EQUAL 0) | ||
65 | message(FATAL_ERROR "Failed to install APK(s) for ${EXECUTABLES}") | ||
66 | endif() | ||
67 | list(GET EXECUTABLES 0 start_executable) | ||
68 | execute_process( | ||
69 | COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target start-${start_executable} | ||
70 | RESULT_VARIABLE res | ||
71 | ) | ||
72 | else() | ||
73 | message(FATAL_ERROR "Unknown ACTION=${ACTION}") | ||
74 | endif() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/cmake_uninstall.cmake.in b/src/contrib/SDL-3.2.20/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000..9a59b4f --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/cmake_uninstall.cmake.in | |||
@@ -0,0 +1,17 @@ | |||
1 | if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") | ||
2 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"") | ||
3 | endif() | ||
4 | |||
5 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) | ||
6 | string(REGEX REPLACE "\n" ";" files "${files}") | ||
7 | foreach(file ${files}) | ||
8 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") | ||
9 | execute_process( | ||
10 | COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" | ||
11 | OUTPUT_VARIABLE rm_out | ||
12 | RESULT_VARIABLE rm_retval | ||
13 | ) | ||
14 | if(NOT ${rm_retval} EQUAL 0) | ||
15 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") | ||
16 | endif (NOT ${rm_retval} EQUAL 0) | ||
17 | endforeach() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/macros.cmake b/src/contrib/SDL-3.2.20/cmake/macros.cmake new file mode 100644 index 0000000..3885aba --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/macros.cmake | |||
@@ -0,0 +1,410 @@ | |||
1 | macro(add_to_alloptions _NEWNAME) | ||
2 | list(APPEND ALLOPTIONS ${_NEWNAME}) | ||
3 | endmacro() | ||
4 | |||
5 | macro(set_option _NAME _DESC) | ||
6 | add_to_alloptions(${_NAME}) | ||
7 | if(${ARGC} EQUAL 3) | ||
8 | set(_DEFLT ${ARGV2}) | ||
9 | else() | ||
10 | set(_DEFLT OFF) | ||
11 | endif() | ||
12 | option(${_NAME} ${_DESC} ${_DEFLT}) | ||
13 | endmacro() | ||
14 | |||
15 | macro(dep_option _NAME _DESC _DEFLT _DEPTEST _FAILDFLT) | ||
16 | add_to_alloptions("${_NAME}") | ||
17 | cmake_dependent_option("${_NAME}" "${_DESC}" "${_DEFLT}" "${_DEPTEST}" "${_FAILDFLT}") | ||
18 | endmacro() | ||
19 | |||
20 | macro(option_string _NAME _DESC _VALUE) | ||
21 | add_to_alloptions(${_NAME}) | ||
22 | set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}") | ||
23 | set(HAVE_${_NAME} ${_VALUE}) | ||
24 | ENDMACRO() | ||
25 | |||
26 | macro(message_bool_option _NAME _VALUE) | ||
27 | set(_PAD "\t") | ||
28 | if(${ARGC} EQUAL 3) | ||
29 | set(_PAD ${ARGV2}) | ||
30 | endif() | ||
31 | if(${_VALUE}) | ||
32 | message(STATUS " ${_NAME}:${_PAD}ON") | ||
33 | else() | ||
34 | message(STATUS " ${_NAME}:${_PAD}OFF") | ||
35 | endif() | ||
36 | endmacro() | ||
37 | |||
38 | macro(message_tested_option _NAME) | ||
39 | set(_REQVALUE ${${_NAME}}) | ||
40 | set(_PAD " ") | ||
41 | if(${ARGC} EQUAL 2) | ||
42 | set(_PAD ${ARGV1}) | ||
43 | endif() | ||
44 | string(SUBSTRING "${_NAME}" 0 4 _NAMESTART) | ||
45 | if(_NAMESTART STREQUAL "SDL_") | ||
46 | string(SUBSTRING "${_NAME}" 4 -1 _STRIPPEDNAME) | ||
47 | else() | ||
48 | set(_STRIPPEDNAME "${_NAME}") | ||
49 | endif() | ||
50 | if(NOT HAVE_${_STRIPPEDNAME}) | ||
51 | set(HAVE_${_STRIPPEDNAME} OFF) | ||
52 | elseif("${HAVE_${_STRIPPEDNAME}}" MATCHES "1|TRUE|YES|Y") | ||
53 | set(HAVE_${_STRIPPEDNAME} ON) | ||
54 | endif() | ||
55 | message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}") | ||
56 | endmacro() | ||
57 | |||
58 | function(find_stringlength_longest_item inList outLength) | ||
59 | set(maxLength 0) | ||
60 | foreach(item IN LISTS ${inList}) | ||
61 | string(LENGTH "${item}" slen) | ||
62 | if(slen GREATER maxLength) | ||
63 | set(maxLength ${slen}) | ||
64 | endif() | ||
65 | endforeach() | ||
66 | set("${outLength}" ${maxLength} PARENT_SCOPE) | ||
67 | endfunction() | ||
68 | |||
69 | function(message_dictlist inList) | ||
70 | find_stringlength_longest_item(${inList} maxLength) | ||
71 | foreach(name IN LISTS ${inList}) | ||
72 | # Get the padding | ||
73 | string(LENGTH ${name} nameLength) | ||
74 | math(EXPR padLength "(${maxLength} + 1) - ${nameLength}") | ||
75 | string(RANDOM LENGTH ${padLength} ALPHABET " " padding) | ||
76 | message_tested_option(${name} ${padding}) | ||
77 | endforeach() | ||
78 | endfunction() | ||
79 | |||
80 | if(APPLE) | ||
81 | include(CheckOBJCSourceCompiles) | ||
82 | enable_language(OBJC) | ||
83 | endif() | ||
84 | |||
85 | function(SDL_detect_linker) | ||
86 | if(CMAKE_VERSION VERSION_LESS 3.29) | ||
87 | if(NOT DEFINED SDL_CMAKE_C_COMPILER_LINKER_ID) | ||
88 | execute_process(COMMAND ${CMAKE_LINKER} -v OUTPUT_VARIABLE LINKER_OUTPUT ERROR_VARIABLE LINKER_OUTPUT) | ||
89 | string(REGEX REPLACE "[\r\n]" " " LINKER_OUTPUT "${LINKER_OUTPUT}") | ||
90 | if(LINKER_OUTPUT MATCHES ".*Microsoft.*") | ||
91 | set(linker MSVC) | ||
92 | else() | ||
93 | set(linker GNUlike) | ||
94 | endif() | ||
95 | message(STATUS "Linker identification: ${linker}") | ||
96 | set(SDL_CMAKE_C_COMPILER_LINKER_ID "${linker}" CACHE STRING "Linker identification") | ||
97 | mark_as_advanced(SDL_CMAKE_C_COMPILER_LINKER_ID) | ||
98 | endif() | ||
99 | set(CMAKE_C_COMPILER_LINKER_ID "${SDL_CMAKE_C_COMPILER_LINKER_ID}" PARENT_SCOPE) | ||
100 | endif() | ||
101 | endfunction() | ||
102 | |||
103 | function(read_absolute_symlink DEST PATH) | ||
104 | file(READ_SYMLINK "${PATH}" p) | ||
105 | if(NOT IS_ABSOLUTE "${p}") | ||
106 | get_filename_component(pdir "${PATH}" DIRECTORY) | ||
107 | set(p "${pdir}/${p}") | ||
108 | endif() | ||
109 | get_filename_component(p "${p}" ABSOLUTE) | ||
110 | set("${DEST}" "${p}" PARENT_SCOPE) | ||
111 | endfunction() | ||
112 | |||
113 | function(win32_implib_identify_dll DEST IMPLIB) | ||
114 | cmake_parse_arguments(ARGS "NOTFATAL" "" "" ${ARGN}) | ||
115 | if(CMAKE_DLLTOOL) | ||
116 | execute_process( | ||
117 | COMMAND "${CMAKE_DLLTOOL}" --identify "${IMPLIB}" | ||
118 | RESULT_VARIABLE retcode | ||
119 | OUTPUT_VARIABLE stdout | ||
120 | ERROR_VARIABLE stderr) | ||
121 | if(NOT retcode EQUAL 0) | ||
122 | if(NOT ARGS_NOTFATAL) | ||
123 | message(FATAL_ERROR "${CMAKE_DLLTOOL} failed.") | ||
124 | else() | ||
125 | set("${DEST}" "${DEST}-NOTFOUND" PARENT_SCOPE) | ||
126 | return() | ||
127 | endif() | ||
128 | endif() | ||
129 | string(STRIP "${stdout}" result) | ||
130 | set(${DEST} "${result}" PARENT_SCOPE) | ||
131 | elseif(MSVC) | ||
132 | get_filename_component(CMAKE_C_COMPILER_DIRECTORY "${CMAKE_C_COMPILER}" DIRECTORY CACHE) | ||
133 | find_program(CMAKE_DUMPBIN NAMES dumpbin PATHS "${CMAKE_C_COMPILER_DIRECTORY}") | ||
134 | if(CMAKE_DUMPBIN) | ||
135 | execute_process( | ||
136 | COMMAND "${CMAKE_DUMPBIN}" "-headers" "${IMPLIB}" | ||
137 | RESULT_VARIABLE retcode | ||
138 | OUTPUT_VARIABLE stdout | ||
139 | ERROR_VARIABLE stderr) | ||
140 | if(NOT retcode EQUAL 0) | ||
141 | if(NOT ARGS_NOTFATAL) | ||
142 | message(FATAL_ERROR "dumpbin failed.") | ||
143 | else() | ||
144 | set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) | ||
145 | return() | ||
146 | endif() | ||
147 | endif() | ||
148 | string(REGEX MATCH "DLL name[ ]+:[ ]+([^\n]+)\n" match "${stdout}") | ||
149 | if(NOT match) | ||
150 | if(NOT ARGS_NOTFATAL) | ||
151 | message(FATAL_ERROR "dumpbin did not find any associated dll for ${IMPLIB}.") | ||
152 | else() | ||
153 | set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) | ||
154 | return() | ||
155 | endif() | ||
156 | endif() | ||
157 | set(result "${CMAKE_MATCH_1}") | ||
158 | set(${DEST} "${result}" PARENT_SCOPE) | ||
159 | else() | ||
160 | message(FATAL_ERROR "Cannot find dumpbin, please set CMAKE_DUMPBIN cmake variable") | ||
161 | endif() | ||
162 | else() | ||
163 | if(NOT ARGS_NOTFATAL) | ||
164 | message(FATAL_ERROR "Don't know how to identify dll from import library. Set CMAKE_DLLTOOL (for mingw) or CMAKE_DUMPBIN (for MSVC)") | ||
165 | else() | ||
166 | set(${DEST} "${DEST}-NOTFOUND") | ||
167 | endif() | ||
168 | endif() | ||
169 | endfunction() | ||
170 | |||
171 | function(get_actual_target) | ||
172 | set(dst "${ARGV0}") | ||
173 | set(target "${${dst}}") | ||
174 | set(input "${target}") | ||
175 | get_target_property(alias "${target}" ALIASED_TARGET) | ||
176 | while(alias) | ||
177 | set(target "${alias}") | ||
178 | get_target_property(alias "${target}" ALIASED_TARGET) | ||
179 | endwhile() | ||
180 | message(DEBUG "get_actual_target(\"${input}\") -> \"${target}\"") | ||
181 | set("${dst}" "${target}" PARENT_SCOPE) | ||
182 | endfunction() | ||
183 | |||
184 | function(target_get_dynamic_library DEST TARGET) | ||
185 | set(result) | ||
186 | get_actual_target(TARGET) | ||
187 | if(WIN32) | ||
188 | # Use the target dll of the import library | ||
189 | set(props_to_check IMPORTED_IMPLIB) | ||
190 | if(CMAKE_BUILD_TYPE) | ||
191 | list(APPEND props_to_check IMPORTED_IMPLIB_${CMAKE_BUILD_TYPE}) | ||
192 | endif() | ||
193 | list(APPEND props_to_check IMPORTED_LOCATION) | ||
194 | if(CMAKE_BUILD_TYPE) | ||
195 | list(APPEND props_to_check IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) | ||
196 | endif() | ||
197 | foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) | ||
198 | list(APPEND props_to_check IMPORTED_IMPLIB_${config_type}) | ||
199 | list(APPEND props_to_check IMPORTED_LOCATION_${config_type}) | ||
200 | endforeach() | ||
201 | |||
202 | foreach(prop_to_check ${props_to_check}) | ||
203 | if(NOT result) | ||
204 | get_target_property(propvalue "${TARGET}" ${prop_to_check}) | ||
205 | if(propvalue AND EXISTS "${propvalue}") | ||
206 | win32_implib_identify_dll(result "${propvalue}" NOTFATAL) | ||
207 | endif() | ||
208 | endif() | ||
209 | endforeach() | ||
210 | else() | ||
211 | # 1. find the target library a file might be symbolic linking to | ||
212 | # 2. find all other files in the same folder that symbolic link to it | ||
213 | # 3. sort all these files, and select the 1st item on Linux, and last on macOS | ||
214 | set(location_properties IMPORTED_LOCATION) | ||
215 | if(CMAKE_BUILD_TYPE) | ||
216 | list(APPEND location_properties IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) | ||
217 | endif() | ||
218 | foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) | ||
219 | list(APPEND location_properties IMPORTED_LOCATION_${config_type}) | ||
220 | endforeach() | ||
221 | if(APPLE) | ||
222 | set(valid_shared_library_regex "\\.[0-9]+\\.dylib$") | ||
223 | else() | ||
224 | set(valid_shared_library_regex "\\.so\\.([0-9.]+)?[0-9]") | ||
225 | endif() | ||
226 | foreach(location_property ${location_properties}) | ||
227 | if(NOT result) | ||
228 | get_target_property(library_path "${TARGET}" ${location_property}) | ||
229 | message(DEBUG "get_target_property(${TARGET} ${location_property}) -> ${library_path}") | ||
230 | if(EXISTS "${library_path}") | ||
231 | get_filename_component(library_path "${library_path}" ABSOLUTE) | ||
232 | while (IS_SYMLINK "${library_path}") | ||
233 | read_absolute_symlink(library_path "${library_path}") | ||
234 | endwhile() | ||
235 | message(DEBUG "${TARGET} -> ${library_path}") | ||
236 | get_filename_component(libdir "${library_path}" DIRECTORY) | ||
237 | file(GLOB subfiles "${libdir}/*") | ||
238 | set(similar_files "${library_path}") | ||
239 | foreach(subfile ${subfiles}) | ||
240 | if(IS_SYMLINK "${subfile}") | ||
241 | read_absolute_symlink(subfile_target "${subfile}") | ||
242 | while(IS_SYMLINK "${subfile_target}") | ||
243 | read_absolute_symlink(subfile_target "${subfile_target}") | ||
244 | endwhile() | ||
245 | get_filename_component(subfile_target "${subfile_target}" ABSOLUTE) | ||
246 | if(subfile_target STREQUAL library_path AND subfile MATCHES "${valid_shared_library_regex}") | ||
247 | list(APPEND similar_files "${subfile}") | ||
248 | endif() | ||
249 | endif() | ||
250 | endforeach() | ||
251 | list(SORT similar_files) | ||
252 | message(DEBUG "files that are similar to \"${library_path}\"=${similar_files}") | ||
253 | if(APPLE) | ||
254 | list(REVERSE similar_files) | ||
255 | endif() | ||
256 | list(GET similar_files 0 item) | ||
257 | get_filename_component(result "${item}" NAME) | ||
258 | endif() | ||
259 | endif() | ||
260 | endforeach() | ||
261 | endif() | ||
262 | if(result) | ||
263 | string(TOLOWER "${result}" result_lower) | ||
264 | if(WIN32 OR OS2) | ||
265 | if(NOT result_lower MATCHES ".*dll") | ||
266 | message(FATAL_ERROR "\"${result}\" is not a .dll library") | ||
267 | endif() | ||
268 | elseif(APPLE) | ||
269 | if(NOT result_lower MATCHES ".*dylib.*") | ||
270 | message(FATAL_ERROR "\"${result}\" is not a .dylib shared library") | ||
271 | endif() | ||
272 | else() | ||
273 | if(NOT result_lower MATCHES ".*so.*") | ||
274 | message(FATAL_ERROR "\"${result}\" is not a .so shared library") | ||
275 | endif() | ||
276 | endif() | ||
277 | else() | ||
278 | get_target_property(target_type ${TARGET} TYPE) | ||
279 | if(target_type MATCHES "SHARED_LIBRARY|MODULE_LIBRARY") | ||
280 | # OK | ||
281 | elseif(target_type MATCHES "STATIC_LIBRARY|OBJECT_LIBRARY|INTERFACE_LIBRARY|EXECUTABLE") | ||
282 | message(SEND_ERROR "${TARGET} is not a shared library, but has type=${target_type}") | ||
283 | else() | ||
284 | message(WARNING "Unable to extract dynamic library from target=${TARGET}, type=${target_type}.") | ||
285 | endif() | ||
286 | # TARGET_SONAME_FILE is not allowed for DLL target platforms. | ||
287 | if(WIN32) | ||
288 | set(result "$<TARGET_FILE_NAME:${TARGET}>") | ||
289 | else() | ||
290 | set(result "$<TARGET_SONAME_FILE_NAME:${TARGET}>") | ||
291 | endif() | ||
292 | endif() | ||
293 | set(${DEST} ${result} PARENT_SCOPE) | ||
294 | endfunction() | ||
295 | |||
296 | function(check_linker_supports_version_file VAR) | ||
297 | SDL_detect_linker() | ||
298 | if(CMAKE_C_COMPILER_LINKER_ID MATCHES "^(MSVC)$") | ||
299 | set(LINKER_SUPPORTS_VERSION_SCRIPT FALSE) | ||
300 | else() | ||
301 | cmake_push_check_state(RESET) | ||
302 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/dummy.sym" "n_0 {\n global:\n func;\n local: *;\n};\n") | ||
303 | list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/dummy.sym") | ||
304 | 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)") | ||
305 | cmake_pop_check_state() | ||
306 | endif() | ||
307 | set(${VAR} "${LINKER_SUPPORTS_VERSION_SCRIPT}" PARENT_SCOPE) | ||
308 | endfunction() | ||
309 | |||
310 | if(CMAKE_VERSION VERSION_LESS 3.18) | ||
311 | function(check_linker_flag LANG FLAG VAR) | ||
312 | cmake_push_check_state(RESET) | ||
313 | list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${FLAG}) | ||
314 | if(LANG STREQUAL "C") | ||
315 | include(CheckCSourceCompiles) | ||
316 | check_c_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)") | ||
317 | elseif(LANG STREQUAL "CXX") | ||
318 | include(CheckCXXSourceCompiles) | ||
319 | check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)") | ||
320 | else() | ||
321 | message(FATAL_ERROR "Unsupported language: ${LANG}") | ||
322 | endif() | ||
323 | cmake_pop_check_state() | ||
324 | endfunction() | ||
325 | else() | ||
326 | cmake_policy(SET CMP0057 NEW) # Support new if() IN_LIST operator. (used inside check_linker_flag, used in CMake 3.18) | ||
327 | include(CheckLinkerFlag) | ||
328 | endif() | ||
329 | |||
330 | if(APPLE) | ||
331 | check_language(OBJC) | ||
332 | if(NOT CMAKE_OBJC_COMPILER) | ||
333 | message(WARNING "Cannot find working OBJC compiler.") | ||
334 | endif() | ||
335 | endif() | ||
336 | |||
337 | function(SDL_PrintSummary) | ||
338 | ##### Info output ##### | ||
339 | message(STATUS "") | ||
340 | message(STATUS "SDL3 was configured with the following options:") | ||
341 | message(STATUS "") | ||
342 | message(STATUS "Platform: ${CMAKE_SYSTEM}") | ||
343 | message(STATUS "64-bit: ${ARCH_64}") | ||
344 | message(STATUS "Compiler: ${CMAKE_C_COMPILER}") | ||
345 | message(STATUS "Revision: ${SDL_REVISION}") | ||
346 | message(STATUS "Vendor: ${SDL_VENDOR_INFO}") | ||
347 | message(STATUS "") | ||
348 | message(STATUS "Subsystems:") | ||
349 | |||
350 | find_stringlength_longest_item(SDL_SUBSYSTEMS maxLength) | ||
351 | foreach(_SUB IN LISTS SDL_SUBSYSTEMS) | ||
352 | string(LENGTH ${_SUB} _SUBLEN) | ||
353 | math(EXPR _PADLEN "(${maxLength} + 1) - ${_SUBLEN}") | ||
354 | string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING) | ||
355 | string(TOUPPER ${_SUB} _OPT) | ||
356 | message_bool_option(${_SUB} SDL_${_OPT} ${_PADDING}) | ||
357 | endforeach() | ||
358 | message(STATUS "") | ||
359 | message(STATUS "Options:") | ||
360 | list(SORT ALLOPTIONS) | ||
361 | message_dictlist(ALLOPTIONS) | ||
362 | message(STATUS "") | ||
363 | message(STATUS " Build Shared Library: ${SDL_SHARED}") | ||
364 | message(STATUS " Build Static Library: ${SDL_STATIC}") | ||
365 | if(SDL_STATIC) | ||
366 | message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}") | ||
367 | endif() | ||
368 | if(APPLE) | ||
369 | message(STATUS " Build libraries as Apple Framework: ${SDL_FRAMEWORK}") | ||
370 | endif() | ||
371 | message(STATUS "") | ||
372 | if(UNIX) | ||
373 | message(STATUS "If something was not detected, although the libraries") | ||
374 | message(STATUS "were installed, then make sure you have set the") | ||
375 | message(STATUS "CMAKE_C_FLAGS and CMAKE_PREFIX_PATH CMake variables correctly.") | ||
376 | message(STATUS "") | ||
377 | endif() | ||
378 | |||
379 | if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN OR HAIKU OR RISCOS)) | ||
380 | if(NOT (HAVE_X11 OR HAVE_WAYLAND)) | ||
381 | if(NOT SDL_UNIX_CONSOLE_BUILD) | ||
382 | message(FATAL_ERROR | ||
383 | "SDL could not find X11 or Wayland development libraries on your system. " | ||
384 | "This means SDL will not be able to create windows on a typical unix operating system. " | ||
385 | "Most likely, this is not wanted." | ||
386 | "\n" | ||
387 | "On Linux, install the packages listed at " | ||
388 | "https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies " | ||
389 | "\n" | ||
390 | "If you really don't need desktop windows, the documentation tells you how to skip this check. " | ||
391 | "https://github.com/libsdl-org/SDL/blob/main/docs/README-cmake.md#cmake-fails-to-build-without-x11-or-wayland-support\n" | ||
392 | ) | ||
393 | endif() | ||
394 | endif() | ||
395 | endif() | ||
396 | endfunction() | ||
397 | |||
398 | function(SDL_install_pdb TARGET DIRECTORY) | ||
399 | get_property(type TARGET ${TARGET} PROPERTY TYPE) | ||
400 | if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$") | ||
401 | install(FILES $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL) | ||
402 | elseif(type STREQUAL "STATIC_LIBRARY") | ||
403 | # FIXME: Use $<TARGET_COMPILE_PDB_FILE:${TARGET} once it becomes available (https://gitlab.kitware.com/cmake/cmake/-/issues/25244) | ||
404 | if(CMAKE_GENERATOR MATCHES "^Visual Studio.*") | ||
405 | install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${TARGET}.pdb\")") | ||
406 | else() | ||
407 | install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${TARGET}.pdb\")") | ||
408 | endif() | ||
409 | endif() | ||
410 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdl3.pc.in b/src/contrib/SDL-3.2.20/cmake/sdl3.pc.in new file mode 100644 index 0000000..38566f5 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdl3.pc.in | |||
@@ -0,0 +1,13 @@ | |||
1 | prefix=@SDL_PKGCONFIG_PREFIX@ | ||
2 | exec_prefix=${prefix} | ||
3 | libdir=@LIBDIR_FOR_PKG_CONFIG@ | ||
4 | includedir=@INCLUDEDIR_FOR_PKG_CONFIG@ | ||
5 | |||
6 | Name: sdl3 | ||
7 | 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. | ||
8 | URL: https://www.libsdl.org/ | ||
9 | Version: @PROJECT_VERSION@ | ||
10 | Requires.private: @SDL_PC_PRIVATE_REQUIRES@ | ||
11 | Conflicts: | ||
12 | Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_PC_LIBS@ @SDL_PC_SECTION_LIBS_PRIVATE@ @SDL_PC_STATIC_LIBS@ | ||
13 | Cflags: -I${includedir} @SDL_PC_CFLAGS@ | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdlchecks.cmake b/src/contrib/SDL-3.2.20/cmake/sdlchecks.cmake new file mode 100644 index 0000000..d321e71 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdlchecks.cmake | |||
@@ -0,0 +1,1308 @@ | |||
1 | macro(FindLibraryAndSONAME _LIB) | ||
2 | cmake_parse_arguments(_FLAS "" "" "LIBDIRS" ${ARGN}) | ||
3 | |||
4 | string(TOUPPER ${_LIB} _UPPERLNAME) | ||
5 | string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}") | ||
6 | |||
7 | find_library(${_LNAME}_LIB ${_LIB} PATHS ${_FLAS_LIBDIRS}) | ||
8 | |||
9 | # FIXME: fail FindLibraryAndSONAME when library is not shared. | ||
10 | if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*") | ||
11 | set(${_LNAME}_SHARED TRUE) | ||
12 | else() | ||
13 | set(${_LNAME}_SHARED FALSE) | ||
14 | endif() | ||
15 | |||
16 | if(${_LNAME}_LIB) | ||
17 | # reduce the library name for shared linking | ||
18 | |||
19 | get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH) # resolves symlinks | ||
20 | get_filename_component(_LIB_LIBDIR ${_LIB_REALPATH} DIRECTORY) | ||
21 | get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME) | ||
22 | |||
23 | if(APPLE) | ||
24 | string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}") | ||
25 | else() | ||
26 | string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}") | ||
27 | endif() | ||
28 | |||
29 | if(NOT EXISTS "${_LIB_LIBDIR}/${_LIB_REGEXD}") | ||
30 | set(_LIB_REGEXD "${_LIB_JUSTNAME}") | ||
31 | endif() | ||
32 | set(${_LNAME}_LIBDIR "${_LIB_LIBDIR}") | ||
33 | |||
34 | message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}") | ||
35 | set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD}) | ||
36 | endif() | ||
37 | |||
38 | message(DEBUG "DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB") | ||
39 | message(DEBUG "DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}") | ||
40 | message(DEBUG "DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}") | ||
41 | message(DEBUG "DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}") | ||
42 | message(DEBUG "DYNLIB SONAME LIB: ${_LIB} ... ${_LIB_REGEXD}") | ||
43 | endmacro() | ||
44 | |||
45 | macro(CheckDLOPEN) | ||
46 | check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC) | ||
47 | if(NOT HAVE_DLOPEN_IN_LIBC) | ||
48 | cmake_push_check_state() | ||
49 | list(APPEND CMAKE_REQUIRED_LIBRARIES dl) | ||
50 | check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL) | ||
51 | cmake_pop_check_state() | ||
52 | if(HAVE_DLOPEN_IN_LIBDL) | ||
53 | sdl_link_dependency(dl LIBS dl) | ||
54 | endif() | ||
55 | endif() | ||
56 | if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL) | ||
57 | set(HAVE_DLOPEN TRUE) | ||
58 | endif() | ||
59 | endmacro() | ||
60 | |||
61 | macro(CheckO_CLOEXEC) | ||
62 | check_c_source_compiles(" | ||
63 | #include <fcntl.h> | ||
64 | int flag = O_CLOEXEC; | ||
65 | int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC) | ||
66 | endmacro() | ||
67 | |||
68 | # Requires: | ||
69 | # - n/a | ||
70 | macro(CheckOSS) | ||
71 | if(SDL_OSS) | ||
72 | check_c_source_compiles(" | ||
73 | #include <sys/soundcard.h> | ||
74 | int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" HAVE_OSS_SYS_SOUNDCARD_H) | ||
75 | |||
76 | if(HAVE_OSS_SYS_SOUNDCARD_H) | ||
77 | set(HAVE_OSS TRUE) | ||
78 | sdl_glob_sources(${SDL3_SOURCE_DIR}/src/audio/dsp/*.c) | ||
79 | set(SDL_AUDIO_DRIVER_OSS 1) | ||
80 | if(NETBSD) | ||
81 | sdl_link_dependency(oss LIBS ossaudio) | ||
82 | endif() | ||
83 | set(HAVE_SDL_AUDIO TRUE) | ||
84 | endif() | ||
85 | endif() | ||
86 | endmacro() | ||
87 | |||
88 | # Requires: | ||
89 | # - n/a | ||
90 | # Optional: | ||
91 | # - SDL_ALSA_SHARED opt | ||
92 | # - HAVE_SDL_LOADSO opt | ||
93 | macro(CheckALSA) | ||
94 | if(SDL_ALSA) | ||
95 | set(ALSA_PKG_CONFIG_SPEC "alsa") | ||
96 | find_package(ALSA MODULE) | ||
97 | if(ALSA_FOUND) | ||
98 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/alsa/*.c") | ||
99 | set(SDL_AUDIO_DRIVER_ALSA 1) | ||
100 | set(HAVE_ALSA TRUE) | ||
101 | set(HAVE_ALSA_SHARED FALSE) | ||
102 | if(SDL_ALSA_SHARED) | ||
103 | if(HAVE_SDL_LOADSO) | ||
104 | FindLibraryAndSONAME("asound") | ||
105 | if(ASOUND_LIB AND ASOUND_SHARED) | ||
106 | sdl_link_dependency(alsa INCLUDES $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>) | ||
107 | set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"") | ||
108 | set(HAVE_ALSA_SHARED TRUE) | ||
109 | else() | ||
110 | message(WARNING "Unable to find asound shared object") | ||
111 | endif() | ||
112 | else() | ||
113 | message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading") | ||
114 | endif() | ||
115 | endif() | ||
116 | if(NOT HAVE_ALSA_SHARED) | ||
117 | #FIXME: remove this line and property generate sdl3.pc | ||
118 | list(APPEND SDL_PC_PRIVATE_REQUIRES alsa) | ||
119 | sdl_link_dependency(alsa LIBS ALSA::ALSA CMAKE_MODULE ALSA PKG_CONFIG_SPECS "${ALSA_PKG_CONFIG_SPEC}") | ||
120 | endif() | ||
121 | set(HAVE_SDL_AUDIO TRUE) | ||
122 | else() | ||
123 | message(WARNING "Unable to find the alsa development library") | ||
124 | endif() | ||
125 | else() | ||
126 | set(HAVE_ALSA FALSE) | ||
127 | endif() | ||
128 | endmacro() | ||
129 | |||
130 | # Requires: | ||
131 | # - PkgCheckModules | ||
132 | # Optional: | ||
133 | # - SDL_PIPEWIRE_SHARED opt | ||
134 | # - HAVE_SDL_LOADSO opt | ||
135 | macro(CheckPipewire) | ||
136 | if(SDL_PIPEWIRE) | ||
137 | set(PipeWire_PKG_CONFIG_SPEC libpipewire-0.3>=0.3.44) | ||
138 | set(PC_PIPEWIRE_FOUND FALSE) | ||
139 | if(PKG_CONFIG_FOUND) | ||
140 | pkg_check_modules(PC_PIPEWIRE IMPORTED_TARGET ${PipeWire_PKG_CONFIG_SPEC}) | ||
141 | endif() | ||
142 | if(PC_PIPEWIRE_FOUND) | ||
143 | set(HAVE_PIPEWIRE TRUE) | ||
144 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pipewire/*.c") | ||
145 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/pipewire/*.c") | ||
146 | set(SDL_AUDIO_DRIVER_PIPEWIRE 1) | ||
147 | set(SDL_CAMERA_DRIVER_PIPEWIRE 1) | ||
148 | if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO) | ||
149 | message(WARNING "You must have SDL_LoadObject() support for dynamic PipeWire loading") | ||
150 | endif() | ||
151 | FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PC_PIPEWIRE_LIBRARY_DIRS}) | ||
152 | if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO) | ||
153 | set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"") | ||
154 | set(SDL_CAMERA_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"") | ||
155 | set(HAVE_PIPEWIRE_SHARED TRUE) | ||
156 | sdl_link_dependency(pipewire INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_PIPEWIRE,INTERFACE_INCLUDE_DIRECTORIES>) | ||
157 | else() | ||
158 | sdl_link_dependency(pipewire LIBS PkgConfig::PC_PIPEWIRE PKG_CONFIG_PREFIX PC_PIPEWIRE PKG_CONFIG_SPECS ${PipeWire_PKG_CONFIG_SPEC}) | ||
159 | endif() | ||
160 | set(HAVE_SDL_AUDIO TRUE) | ||
161 | endif() | ||
162 | endif() | ||
163 | endmacro() | ||
164 | |||
165 | # Requires: | ||
166 | # - PkgCheckModules | ||
167 | # Optional: | ||
168 | # - SDL_PULSEAUDIO_SHARED opt | ||
169 | # - HAVE_SDL_LOADSO opt | ||
170 | macro(CheckPulseAudio) | ||
171 | if(SDL_PULSEAUDIO) | ||
172 | set(PulseAudio_PKG_CONFIG_SPEC "libpulse>=0.9.15") | ||
173 | set(PC_PULSEAUDIO_FOUND FALSE) | ||
174 | if(PKG_CONFIG_FOUND) | ||
175 | pkg_check_modules(PC_PULSEAUDIO IMPORTED_TARGET ${PulseAudio_PKG_CONFIG_SPEC}) | ||
176 | endif() | ||
177 | if(PC_PULSEAUDIO_FOUND) | ||
178 | set(HAVE_PULSEAUDIO TRUE) | ||
179 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pulseaudio/*.c") | ||
180 | set(SDL_AUDIO_DRIVER_PULSEAUDIO 1) | ||
181 | if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO) | ||
182 | message(WARNING "You must have SDL_LoadObject() support for dynamic PulseAudio loading") | ||
183 | endif() | ||
184 | FindLibraryAndSONAME("pulse" LIBDIRS ${PC_PULSEAUDIO_LIBRARY_DIRS}) | ||
185 | if(SDL_PULSEAUDIO_SHARED AND PULSE_LIB AND HAVE_SDL_LOADSO) | ||
186 | set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_LIB_SONAME}\"") | ||
187 | set(HAVE_PULSEAUDIO_SHARED TRUE) | ||
188 | sdl_link_dependency(pulseaudio INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_PULSEAUDIO,INTERFACE_INCLUDE_DIRECTORIES>) | ||
189 | else() | ||
190 | sdl_link_dependency(pulseaudio LIBS PkgConfig::PC_PULSEAUDIO PKG_CONFIG_PREFIX PC_PULSEAUDIO PKG_CONFIG_SPECS "${PulseAudio_PKG_CONFIG_SPEC}") | ||
191 | endif() | ||
192 | set(HAVE_SDL_AUDIO TRUE) | ||
193 | endif() | ||
194 | endif() | ||
195 | endmacro() | ||
196 | |||
197 | # Requires: | ||
198 | # - PkgCheckModules | ||
199 | # Optional: | ||
200 | # - SDL_JACK_SHARED opt | ||
201 | # - HAVE_SDL_LOADSO opt | ||
202 | macro(CheckJACK) | ||
203 | if(SDL_JACK) | ||
204 | set(Jack_PKG_CONFIG_SPEC jack) | ||
205 | set(PC_JACK_FOUND FALSE) | ||
206 | if(PKG_CONFIG_FOUND) | ||
207 | pkg_check_modules(PC_JACK IMPORTED_TARGET ${Jack_PKG_CONFIG_SPEC}) | ||
208 | endif() | ||
209 | if(PC_JACK_FOUND) | ||
210 | set(HAVE_JACK TRUE) | ||
211 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/jack/*.c") | ||
212 | set(SDL_AUDIO_DRIVER_JACK 1) | ||
213 | if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO) | ||
214 | message(WARNING "You must have SDL_LoadObject() support for dynamic JACK audio loading") | ||
215 | endif() | ||
216 | FindLibraryAndSONAME("jack" LIBDIRS ${PC_JACK_LIBRARY_DIRS}) | ||
217 | if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO) | ||
218 | set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"") | ||
219 | set(HAVE_JACK_SHARED TRUE) | ||
220 | sdl_link_dependency(jack INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_JACK,INTERFACE_INCLUDE_DIRECTORIES>) | ||
221 | else() | ||
222 | sdl_link_dependency(jack LIBS PkgConfig::PC_JACK PKG_CONFIG_PREFIX PC_JACK PKG_CONFIG_SPECS ${Jack_PKG_CONFIG_SPEC}) | ||
223 | endif() | ||
224 | set(HAVE_SDL_AUDIO TRUE) | ||
225 | endif() | ||
226 | endif() | ||
227 | endmacro() | ||
228 | |||
229 | # Requires: | ||
230 | # - PkgCheckModules | ||
231 | # Optional: | ||
232 | # - SDL_SNDIO_SHARED opt | ||
233 | # - HAVE_SDL_LOADSO opt | ||
234 | macro(CheckSNDIO) | ||
235 | if(SDL_SNDIO) | ||
236 | set(SndIO_PKG_CONFIG_SPEC sndio) | ||
237 | set(PC_SNDIO_FOUND FALSE) | ||
238 | if(PKG_CONFIG_FOUND) | ||
239 | pkg_check_modules(PC_SNDIO IMPORTED_TARGET ${SndIO_PKG_CONFIG_SPEC}) | ||
240 | endif() | ||
241 | if(PC_SNDIO_FOUND) | ||
242 | set(HAVE_SNDIO TRUE) | ||
243 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/sndio/*.c") | ||
244 | set(SDL_AUDIO_DRIVER_SNDIO 1) | ||
245 | if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO) | ||
246 | message(WARNING "You must have SDL_LoadObject() support for dynamic sndio loading") | ||
247 | endif() | ||
248 | FindLibraryAndSONAME("sndio" LIBDIRS ${PC_SNDIO_LIBRARY_DIRS}) | ||
249 | if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO) | ||
250 | set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"") | ||
251 | set(HAVE_SNDIO_SHARED TRUE) | ||
252 | sdl_include_directories(PRIVATE SYSTEM $<TARGET_PROPERTY:PkgConfig::PC_SNDIO,INTERFACE_INCLUDE_DIRECTORIES>) | ||
253 | else() | ||
254 | sdl_link_dependency(sndio LIBS PkgConfig::PC_SNDIO PKG_CONFIG_PREFIX PC_SNDIO PKG_CONFIG_SPECS ${SndIO_PKG_CONFIG_SPEC}) | ||
255 | endif() | ||
256 | set(HAVE_SDL_AUDIO TRUE) | ||
257 | endif() | ||
258 | endif() | ||
259 | endmacro() | ||
260 | |||
261 | # Requires: | ||
262 | # - n/a | ||
263 | # Optional: | ||
264 | # - SDL_X11_SHARED opt | ||
265 | # - HAVE_SDL_LOADSO opt | ||
266 | macro(CheckX11) | ||
267 | cmake_push_check_state() | ||
268 | if(SDL_X11) | ||
269 | set(X11_PKG_CONFIG_SPEC x11) | ||
270 | set(Xext_PKG_CONFIG_SPEC xext) | ||
271 | set(Xcursor_PKG_CONFIG_SPEC xcursor) | ||
272 | set(Xi_PKG_CONFIG_SPEC xi) | ||
273 | set(Xfixes_PKG_CONFIG_SPEC xfixes) | ||
274 | set(Xrandr_PKG_CONFIG_SPEC xrandr) | ||
275 | set(Xrender_PKG_CONFIG_SPEC xrender) | ||
276 | set(Xss_PKG_CONFIG_SPEC xscrnsaver) | ||
277 | |||
278 | find_package(X11) | ||
279 | |||
280 | foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss) | ||
281 | get_filename_component(_libdir "${X11_${_LIB}_LIB}" DIRECTORY) | ||
282 | FindLibraryAndSONAME("${_LIB}" LIBDIRS ${_libdir}) | ||
283 | endforeach() | ||
284 | |||
285 | find_path(X11_INCLUDEDIR | ||
286 | NAMES X11/Xlib.h | ||
287 | PATHS | ||
288 | ${X11_INCLUDE_DIR} | ||
289 | /usr/pkg/xorg/include | ||
290 | /usr/X11R6/include | ||
291 | /usr/X11R7/include | ||
292 | /usr/local/include/X11 | ||
293 | /usr/include/X11 | ||
294 | /usr/openwin/include | ||
295 | /usr/openwin/share/include | ||
296 | /opt/graphics/OpenGL/include | ||
297 | /opt/X11/include | ||
298 | ) | ||
299 | |||
300 | if(X11_INCLUDEDIR) | ||
301 | sdl_include_directories(PRIVATE SYSTEM "${X11_INCLUDEDIR}") | ||
302 | list(APPEND CMAKE_REQUIRED_INCLUDES ${X11_INCLUDEDIR}) | ||
303 | endif() | ||
304 | |||
305 | find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X11_INCLUDEDIR}") | ||
306 | find_file(HAVE_XINPUT2_H NAMES "X11/extensions/XInput2.h" HINTS "${X11_INCLUDEDIR}") | ||
307 | find_file(HAVE_XRANDR_H NAMES "X11/extensions/Xrandr.h" HINTS "${X11_INCLUDEDIR}") | ||
308 | find_file(HAVE_XFIXES_H_ NAMES "X11/extensions/Xfixes.h" HINTS "${X11_INCLUDEDIR}") | ||
309 | find_file(HAVE_XRENDER_H NAMES "X11/extensions/Xrender.h" HINTS "${X11_INCLUDEDIR}") | ||
310 | find_file(HAVE_XSYNC_H NAMES "X11/extensions/sync.h" HINTS "${X11_INCLUDEDIR}") | ||
311 | find_file(HAVE_XSS_H NAMES "X11/extensions/scrnsaver.h" HINTS "${X11_INCLUDEDIR}") | ||
312 | find_file(HAVE_XSHAPE_H NAMES "X11/extensions/shape.h" HINTS "${X11_INCLUDEDIR}") | ||
313 | find_file(HAVE_XDBE_H NAMES "X11/extensions/Xdbe.h" HINTS "${X11_INCLUDEDIR}") | ||
314 | find_file(HAVE_XEXT_H NAMES "X11/extensions/Xext.h" HINTS "${X11_INCLUDEDIR}") | ||
315 | |||
316 | if(X11_LIB AND HAVE_XEXT_H) | ||
317 | |||
318 | set(HAVE_X11 TRUE) | ||
319 | set(HAVE_SDL_VIDEO TRUE) | ||
320 | |||
321 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/x11/*.c") | ||
322 | set(SDL_VIDEO_DRIVER_X11 1) | ||
323 | |||
324 | # Note: Disabled on Apple because the dynamic mode backend for X11 doesn't | ||
325 | # work properly on Apple during several issues like inconsistent paths | ||
326 | # among platforms. See #6778 (https://github.com/libsdl-org/SDL/issues/6778) | ||
327 | if(APPLE) | ||
328 | set(SDL_X11_SHARED OFF) | ||
329 | endif() | ||
330 | |||
331 | check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT_IN_LIBC) | ||
332 | if(NOT HAVE_SHMAT_IN_LIBC) | ||
333 | check_library_exists(ipc shmat "" HAVE_SHMAT_IN_LIBIPC) | ||
334 | if(HAVE_SHMAT_IN_LIBIPC) | ||
335 | sdl_link_dependency(x11_ipc LIBS ipc) | ||
336 | endif() | ||
337 | if(NOT HAVE_SHMAT_IN_LIBIPC) | ||
338 | sdl_compile_definitions(PRIVATE "NO_SHARED_MEMORY") | ||
339 | endif() | ||
340 | endif() | ||
341 | |||
342 | if(SDL_X11_SHARED) | ||
343 | if(NOT HAVE_SDL_LOADSO) | ||
344 | message(WARNING "You must have SDL_LoadObject() support for dynamic X11 loading") | ||
345 | set(HAVE_X11_SHARED FALSE) | ||
346 | else() | ||
347 | set(HAVE_X11_SHARED TRUE) | ||
348 | endif() | ||
349 | if(X11_LIB) | ||
350 | if(HAVE_X11_SHARED) | ||
351 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"") | ||
352 | else() | ||
353 | sdl_link_dependency(x11 LIBS X11::X11 CMAKE_MODULE X11 PKG_CONFIG_SPECS ${X11_PKG_CONFIG_SPEC}) | ||
354 | endif() | ||
355 | endif() | ||
356 | if(XEXT_LIB) | ||
357 | if(HAVE_X11_SHARED) | ||
358 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"") | ||
359 | else() | ||
360 | sdl_link_dependency(xext LIBS X11::Xext CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xext_PKG_CONFIG_SPEC}) | ||
361 | endif() | ||
362 | endif() | ||
363 | else() | ||
364 | sdl_link_dependency(x11 LIBS X11::X11 CMAKE_MODULE X11 PKG_CONFIG_SPECS ${X11_PKG_CONFIG_SPEC}) | ||
365 | sdl_link_dependency(xext LIBS X11::Xext CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xext_PKG_CONFIG_SPEC}) | ||
366 | endif() | ||
367 | |||
368 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${X11_LIB}) | ||
369 | |||
370 | check_c_source_compiles(" | ||
371 | #include <X11/Xlib.h> | ||
372 | int main(int argc, char **argv) { | ||
373 | Display *display; | ||
374 | XEvent event; | ||
375 | XGenericEventCookie *cookie = &event.xcookie; | ||
376 | XNextEvent(display, &event); | ||
377 | XGetEventData(display, cookie); | ||
378 | XFreeEventData(display, cookie); | ||
379 | return 0; }" HAVE_XGENERICEVENT) | ||
380 | if(HAVE_XGENERICEVENT) | ||
381 | set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1) | ||
382 | endif() | ||
383 | |||
384 | check_symbol_exists(XkbLookupKeySym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM) | ||
385 | |||
386 | if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB) | ||
387 | set(HAVE_X11_XCURSOR TRUE) | ||
388 | if(HAVE_X11_SHARED) | ||
389 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"") | ||
390 | else() | ||
391 | sdl_link_dependency(xcursor LIBS X11::Xcursor CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xcursor_PKG_CONFIG_SPEC}) | ||
392 | endif() | ||
393 | set(SDL_VIDEO_DRIVER_X11_XCURSOR 1) | ||
394 | endif() | ||
395 | |||
396 | if(SDL_X11_XDBE AND HAVE_XDBE_H) | ||
397 | set(HAVE_X11_XDBE TRUE) | ||
398 | set(SDL_VIDEO_DRIVER_X11_XDBE 1) | ||
399 | endif() | ||
400 | |||
401 | if(SDL_X11_XINPUT AND HAVE_XINPUT2_H AND XI_LIB) | ||
402 | set(HAVE_X11_XINPUT TRUE) | ||
403 | if(HAVE_X11_SHARED) | ||
404 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"") | ||
405 | else() | ||
406 | sdl_link_dependency(xi LIBS X11::Xi CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xi_PKG_CONFIG_SPEC}) | ||
407 | endif() | ||
408 | set(SDL_VIDEO_DRIVER_X11_XINPUT2 1) | ||
409 | |||
410 | # Check for multitouch | ||
411 | check_c_source_compiles(" | ||
412 | #include <X11/Xlib.h> | ||
413 | #include <X11/Xproto.h> | ||
414 | #include <X11/extensions/XInput2.h> | ||
415 | int event_type = XI_TouchBegin; | ||
416 | XITouchClassInfo *t; | ||
417 | Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) { | ||
418 | return (Status)0; | ||
419 | } | ||
420 | int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH) | ||
421 | if(HAVE_XINPUT2_MULTITOUCH) | ||
422 | set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1) | ||
423 | endif() | ||
424 | endif() | ||
425 | |||
426 | # check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer | ||
427 | if(SDL_X11_XFIXES AND HAVE_XFIXES_H_ AND HAVE_XINPUT2_H) | ||
428 | check_c_source_compiles(" | ||
429 | #include <X11/Xlib.h> | ||
430 | #include <X11/Xproto.h> | ||
431 | #include <X11/extensions/XInput2.h> | ||
432 | #include <X11/extensions/Xfixes.h> | ||
433 | BarrierEventID b; | ||
434 | int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H) | ||
435 | endif() | ||
436 | if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H AND XFIXES_LIB) | ||
437 | if(HAVE_X11_SHARED) | ||
438 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"") | ||
439 | else() | ||
440 | sdl_link_dependency(xfixes LIBS X11::Xfixes CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xfixes_PKG_CONFIG_SPEC}) | ||
441 | endif() | ||
442 | set(SDL_VIDEO_DRIVER_X11_XFIXES 1) | ||
443 | set(HAVE_X11_XFIXES TRUE) | ||
444 | endif() | ||
445 | |||
446 | if(SDL_X11_XSYNC AND HAVE_XSYNC_H AND XEXT_LIB) | ||
447 | set(SDL_VIDEO_DRIVER_X11_XSYNC 1) | ||
448 | set(HAVE_X11_XSYNC TRUE) | ||
449 | endif() | ||
450 | |||
451 | if(SDL_X11_XRANDR AND HAVE_XRANDR_H AND XRANDR_LIB) | ||
452 | if(HAVE_X11_SHARED) | ||
453 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"") | ||
454 | else() | ||
455 | sdl_link_dependency(xrandr LIBS X11::Xrandr CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xrandr_PKG_CONFIG_SPEC}) | ||
456 | endif() | ||
457 | set(SDL_VIDEO_DRIVER_X11_XRANDR 1) | ||
458 | set(HAVE_X11_XRANDR TRUE) | ||
459 | endif() | ||
460 | |||
461 | if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H AND XSS_LIB) | ||
462 | if(HAVE_X11_SHARED) | ||
463 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"") | ||
464 | else() | ||
465 | sdl_link_dependency(xss LIBS X11::Xss CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xss_PKG_CONFIG_SPEC}) | ||
466 | endif() | ||
467 | set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1) | ||
468 | set(HAVE_X11_XSCRNSAVER TRUE) | ||
469 | endif() | ||
470 | |||
471 | if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H) | ||
472 | set(SDL_VIDEO_DRIVER_X11_XSHAPE 1) | ||
473 | set(HAVE_X11_XSHAPE TRUE) | ||
474 | endif() | ||
475 | endif() | ||
476 | endif() | ||
477 | if(NOT HAVE_X11) | ||
478 | # Prevent Mesa from including X11 headers | ||
479 | sdl_compile_definitions(PRIVATE "MESA_EGL_NO_X11_HEADERS" "EGL_NO_X11") | ||
480 | endif() | ||
481 | cmake_pop_check_state() | ||
482 | endmacro() | ||
483 | |||
484 | macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL) | ||
485 | set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c") | ||
486 | set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h") | ||
487 | |||
488 | add_custom_command( | ||
489 | OUTPUT "${_WAYLAND_PROT_H_CODE}" | ||
490 | DEPENDS "${_XML}" | ||
491 | COMMAND "${_SCANNER}" | ||
492 | ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}" | ||
493 | ) | ||
494 | |||
495 | add_custom_command( | ||
496 | OUTPUT "${_WAYLAND_PROT_C_CODE}" | ||
497 | DEPENDS "${_WAYLAND_PROT_H_CODE}" | ||
498 | COMMAND "${_SCANNER}" | ||
499 | ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}" | ||
500 | ) | ||
501 | |||
502 | sdl_sources("${_WAYLAND_PROT_C_CODE}") | ||
503 | endmacro() | ||
504 | |||
505 | # Requires: | ||
506 | # - EGL | ||
507 | # - PkgCheckModules | ||
508 | # Optional: | ||
509 | # - SDL_WAYLAND_SHARED opt | ||
510 | # - HAVE_SDL_LOADSO opt | ||
511 | macro(CheckWayland) | ||
512 | if(SDL_WAYLAND) | ||
513 | set(WAYLAND_PKG_CONFIG_SPEC "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0") | ||
514 | set(PC_WAYLAND_FOUND FALSE) | ||
515 | if(PKG_CONFIG_FOUND) | ||
516 | pkg_check_modules(PC_WAYLAND IMPORTED_TARGET ${WAYLAND_PKG_CONFIG_SPEC}) | ||
517 | endif() | ||
518 | find_program(WAYLAND_SCANNER NAMES wayland-scanner) | ||
519 | |||
520 | set(WAYLAND_FOUND FALSE) | ||
521 | if(PC_WAYLAND_FOUND AND WAYLAND_SCANNER) | ||
522 | execute_process( | ||
523 | COMMAND ${WAYLAND_SCANNER} --version | ||
524 | RESULT_VARIABLE WAYLAND_SCANNER_VERSION_RC | ||
525 | ERROR_VARIABLE WAYLAND_SCANNER_VERSION_STDERR | ||
526 | ERROR_STRIP_TRAILING_WHITESPACE | ||
527 | ) | ||
528 | if(NOT WAYLAND_SCANNER_VERSION_RC EQUAL 0) | ||
529 | message(WARNING "Failed to get wayland-scanner version") | ||
530 | else() | ||
531 | if(WAYLAND_SCANNER_VERSION_STDERR MATCHES [[([0-9.]+)$]]) | ||
532 | set(WAYLAND_FOUND TRUE) | ||
533 | set(WAYLAND_SCANNER_VERSION ${CMAKE_MATCH_1}) | ||
534 | if(WAYLAND_SCANNER_VERSION VERSION_LESS "1.15.0") | ||
535 | set(WAYLAND_SCANNER_CODE_MODE "code") | ||
536 | else() | ||
537 | set(WAYLAND_SCANNER_CODE_MODE "private-code") | ||
538 | endif() | ||
539 | endif() | ||
540 | endif() | ||
541 | endif() | ||
542 | |||
543 | if(WAYLAND_FOUND) | ||
544 | set(HAVE_WAYLAND TRUE) | ||
545 | set(HAVE_SDL_VIDEO TRUE) | ||
546 | |||
547 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/wayland/*.c") | ||
548 | |||
549 | # We have to generate some protocol interface code for some unstable Wayland features. | ||
550 | file(MAKE_DIRECTORY "${SDL3_BINARY_DIR}/wayland-generated-protocols") | ||
551 | # Prepend to include path to make sure they override installed protocol headers | ||
552 | sdl_include_directories(PRIVATE SYSTEM BEFORE "${SDL3_BINARY_DIR}/wayland-generated-protocols") | ||
553 | |||
554 | file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL3_SOURCE_DIR}/wayland-protocols/" "${SDL3_SOURCE_DIR}/wayland-protocols/*.xml") | ||
555 | foreach(_XML IN LISTS WAYLAND_PROTOCOLS_XML) | ||
556 | string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}") | ||
557 | WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL3_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}") | ||
558 | endforeach() | ||
559 | |||
560 | if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO) | ||
561 | message(WARNING "You must have SDL_LoadObject() support for dynamic Wayland loading") | ||
562 | endif() | ||
563 | FindLibraryAndSONAME(wayland-client LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS}) | ||
564 | FindLibraryAndSONAME(wayland-egl LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS}) | ||
565 | FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS}) | ||
566 | FindLibraryAndSONAME(xkbcommon LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS}) | ||
567 | if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO) | ||
568 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"") | ||
569 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"") | ||
570 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"") | ||
571 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"") | ||
572 | set(HAVE_WAYLAND_SHARED TRUE) | ||
573 | sdl_link_dependency(wayland INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_WAYLAND,INTERFACE_INCLUDE_DIRECTORIES>) | ||
574 | else() | ||
575 | sdl_link_dependency(wayland LIBS PkgConfig::PC_WAYLAND PKG_CONFIG_PREFIX PC_WAYLAND PKG_CONFIG_SPECS ${WAYLAND_PKG_CONFIG_SPEC}) | ||
576 | endif() | ||
577 | |||
578 | if(SDL_WAYLAND_LIBDECOR) | ||
579 | set(LibDecor_PKG_CONFIG_SPEC libdecor-0) | ||
580 | pkg_check_modules(PC_LIBDECOR IMPORTED_TARGET ${LibDecor_PKG_CONFIG_SPEC}) | ||
581 | if(PC_LIBDECOR_FOUND) | ||
582 | |||
583 | # Libdecor doesn't provide internal version defines, so generate them here. | ||
584 | if (PC_LIBDECOR_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") | ||
585 | set(SDL_LIBDECOR_VERSION_MAJOR ${CMAKE_MATCH_1}) | ||
586 | set(SDL_LIBDECOR_VERSION_MINOR ${CMAKE_MATCH_2}) | ||
587 | set(SDL_LIBDECOR_VERSION_PATCH ${CMAKE_MATCH_3}) | ||
588 | else() | ||
589 | message(WARNING "Failed to parse libdecor version; defaulting to lowest supported (0.1.0)") | ||
590 | set(SDL_LIBDECOR_VERSION_MAJOR 0) | ||
591 | set(SDL_LIBDECOR_VERSION_MINOR 1) | ||
592 | set(SDL_LIBDECOR_VERSION_PATCH 0) | ||
593 | endif() | ||
594 | |||
595 | if(PC_LIBDECOR_VERSION VERSION_GREATER_EQUAL "0.2.0") | ||
596 | set(LibDecor_PKG_CONFIG_SPEC "libdecor-0>=0.2.0") | ||
597 | endif() | ||
598 | set(HAVE_WAYLAND_LIBDECOR TRUE) | ||
599 | set(HAVE_LIBDECOR_H 1) | ||
600 | if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO) | ||
601 | message(WARNING "You must have SDL_LoadObject() support for dynamic libdecor loading") | ||
602 | endif() | ||
603 | FindLibraryAndSONAME(decor-0 LIBDIRS ${PC_LIBDECOR_LIBRARY_DIRS}) | ||
604 | if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO) | ||
605 | set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE) | ||
606 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"") | ||
607 | sdl_link_dependency(libdecor INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBDECOR,INTERFACE_INCLUDE_DIRECTORIES>) | ||
608 | else() | ||
609 | sdl_link_dependency(libdecor LIBS PkgConfig::PC_LIBDECOR PKG_CONFIG_PREFIX PC_LIBDECOR PKG_CONFIG_SPECS ${LibDecor_PKG_CONFIG_SPEC}) | ||
610 | endif() | ||
611 | endif() | ||
612 | endif() | ||
613 | |||
614 | set(SDL_VIDEO_DRIVER_WAYLAND 1) | ||
615 | endif() | ||
616 | endif() | ||
617 | endmacro() | ||
618 | |||
619 | # Requires: | ||
620 | # - n/a | ||
621 | # | ||
622 | macro(CheckCOCOA) | ||
623 | if(SDL_COCOA) | ||
624 | if(APPLE) # Apple always has Cocoa. | ||
625 | set(HAVE_COCOA TRUE) | ||
626 | endif() | ||
627 | if(HAVE_COCOA) | ||
628 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/cocoa/*.m") | ||
629 | set(SDL_FRAMEWORK_IOKIT 1) | ||
630 | set(SDL_VIDEO_DRIVER_COCOA 1) | ||
631 | set(HAVE_SDL_VIDEO TRUE) | ||
632 | endif() | ||
633 | endif() | ||
634 | endmacro() | ||
635 | |||
636 | # Requires: | ||
637 | # - n/a | ||
638 | macro(CheckVivante) | ||
639 | if(SDL_VIVANTE) | ||
640 | check_c_source_compiles(" | ||
641 | #include <gc_vdk.h> | ||
642 | int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK) | ||
643 | check_c_source_compiles(" | ||
644 | #define LINUX | ||
645 | #define EGL_API_FB | ||
646 | #include <EGL/eglvivante.h> | ||
647 | int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB) | ||
648 | if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB) | ||
649 | set(HAVE_VIVANTE TRUE) | ||
650 | set(HAVE_SDL_VIDEO TRUE) | ||
651 | |||
652 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/vivante/*.c") | ||
653 | set(SDL_VIDEO_DRIVER_VIVANTE 1) | ||
654 | # FIXME: Use Find module | ||
655 | if(HAVE_VIVANTE_VDK) | ||
656 | set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1) | ||
657 | find_library(VIVANTE_LIBRARY REQUIRED NAMES VIVANTE vivante drm_vivante) | ||
658 | find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED) | ||
659 | sdl_link_dependency(vivante LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY}) | ||
660 | else() | ||
661 | # these defines are needed when including the system EGL headers, which SDL does | ||
662 | sdl_compile_definitions(PUBLIC "LINUX" "EGL_API_FB") | ||
663 | sdl_link_dependency(vivante LIBS EGL) | ||
664 | endif(HAVE_VIVANTE_VDK) | ||
665 | endif() | ||
666 | endif() | ||
667 | endmacro() | ||
668 | |||
669 | # Requires: | ||
670 | # - n/a | ||
671 | macro(CheckOpenVR) | ||
672 | if(SDL_OPENVR) | ||
673 | set(HAVE_OPENVR TRUE) | ||
674 | set(HAVE_OPENVR_VIDEO TRUE) | ||
675 | |||
676 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/openvr/*.c") | ||
677 | set(SDL_VIDEO_DRIVER_OPENVR 1) | ||
678 | if(NOT WINDOWS) | ||
679 | sdl_link_dependency(egl LIBS EGL) | ||
680 | endif() | ||
681 | endif() | ||
682 | endmacro() | ||
683 | |||
684 | # Requires: | ||
685 | # - nada | ||
686 | macro(CheckGLX) | ||
687 | if(SDL_OPENGL) | ||
688 | check_c_source_compiles(" | ||
689 | #include <GL/glx.h> | ||
690 | int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX) | ||
691 | if(HAVE_OPENGL_GLX AND NOT HAVE_ROCKCHIP) | ||
692 | set(SDL_VIDEO_OPENGL_GLX 1) | ||
693 | endif() | ||
694 | endif() | ||
695 | endmacro() | ||
696 | |||
697 | # Requires: | ||
698 | # - PkgCheckModules | ||
699 | macro(CheckEGL) | ||
700 | if(SDL_OPENGL OR SDL_OPENGLES) | ||
701 | cmake_push_check_state() | ||
702 | find_package(OpenGL MODULE) | ||
703 | list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENGL_EGL_INCLUDE_DIRS}) | ||
704 | list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos") | ||
705 | check_c_source_compiles(" | ||
706 | #define EGL_API_FB | ||
707 | #define MESA_EGL_NO_X11_HEADERS | ||
708 | #define EGL_NO_X11 | ||
709 | #include <EGL/egl.h> | ||
710 | #include <EGL/eglext.h> | ||
711 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL) | ||
712 | cmake_pop_check_state() | ||
713 | if(HAVE_OPENGL_EGL) | ||
714 | set(SDL_VIDEO_OPENGL_EGL 1) | ||
715 | sdl_link_dependency(egl INCLUDES ${OPENGL_EGL_INCLUDE_DIRS}) | ||
716 | endif() | ||
717 | endif() | ||
718 | endmacro() | ||
719 | |||
720 | # Requires: | ||
721 | # - nada | ||
722 | macro(CheckOpenGL) | ||
723 | if(SDL_OPENGL) | ||
724 | check_c_source_compiles(" | ||
725 | #include <GL/gl.h> | ||
726 | #include <GL/glext.h> | ||
727 | int main(int argc, char** argv) { return 0; }" HAVE_OPENGL) | ||
728 | if(HAVE_OPENGL) | ||
729 | set(SDL_VIDEO_OPENGL 1) | ||
730 | set(SDL_VIDEO_RENDER_OGL 1) | ||
731 | endif() | ||
732 | endif() | ||
733 | endmacro() | ||
734 | |||
735 | # Requires: | ||
736 | # - nada | ||
737 | macro(CheckOpenGLES) | ||
738 | if(SDL_OPENGLES) | ||
739 | cmake_push_check_state() | ||
740 | list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos") | ||
741 | check_c_source_compiles(" | ||
742 | #include <GLES/gl.h> | ||
743 | #include <GLES/glext.h> | ||
744 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1) | ||
745 | check_c_source_compiles(" | ||
746 | #include <GLES2/gl2.h> | ||
747 | #include <GLES2/gl2ext.h> | ||
748 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2) | ||
749 | cmake_pop_check_state() | ||
750 | if(HAVE_OPENGLES_V1) | ||
751 | set(HAVE_OPENGLES TRUE) | ||
752 | set(SDL_VIDEO_OPENGL_ES 1) | ||
753 | endif() | ||
754 | if(HAVE_OPENGLES_V2) | ||
755 | set(HAVE_OPENGLES TRUE) | ||
756 | set(SDL_VIDEO_OPENGL_ES2 1) | ||
757 | set(SDL_VIDEO_RENDER_OGL_ES2 1) | ||
758 | endif() | ||
759 | endif() | ||
760 | endmacro() | ||
761 | |||
762 | macro(CheckVulkan) | ||
763 | if(SDL_VULKAN) | ||
764 | set(SDL_VIDEO_VULKAN 1) | ||
765 | set(HAVE_VULKAN TRUE) | ||
766 | if(SDL_RENDER_VULKAN) | ||
767 | set(SDL_VIDEO_RENDER_VULKAN 1) | ||
768 | set(HAVE_RENDER_VULKAN TRUE) | ||
769 | endif() | ||
770 | endif() | ||
771 | endmacro() | ||
772 | |||
773 | # Requires: | ||
774 | # - EGL | ||
775 | macro(CheckQNXScreen) | ||
776 | if(QNX AND HAVE_OPENGL_EGL) | ||
777 | check_c_source_compiles(" | ||
778 | #include <screen/screen.h> | ||
779 | int main (int argc, char** argv) { return 0; }" HAVE_QNX_SCREEN) | ||
780 | if(HAVE_QNX_SCREEN) | ||
781 | set(SDL_VIDEO_DRIVER_QNX 1) | ||
782 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/qnx/*.c") | ||
783 | sdl_link_dependency(qnxscreen LIBS screen EGL) | ||
784 | endif() | ||
785 | endif() | ||
786 | endmacro() | ||
787 | |||
788 | # Requires: | ||
789 | # - nada | ||
790 | # Optional: | ||
791 | # - THREADS opt | ||
792 | # Sets: | ||
793 | # PTHREAD_CFLAGS | ||
794 | # PTHREAD_LIBS | ||
795 | macro(CheckPTHREAD) | ||
796 | cmake_push_check_state() | ||
797 | if(SDL_PTHREADS) | ||
798 | if(ANDROID) | ||
799 | # the android libc provides built-in support for pthreads, so no | ||
800 | # additional linking or compile flags are necessary | ||
801 | elseif(LINUX) | ||
802 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
803 | set(PTHREAD_LDFLAGS "-pthread") | ||
804 | elseif(BSDI) | ||
805 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
806 | set(PTHREAD_LDFLAGS "") | ||
807 | elseif(DARWIN) | ||
808 | set(PTHREAD_CFLAGS "-D_THREAD_SAFE") | ||
809 | # causes Carbon.p complaints? | ||
810 | # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
811 | set(PTHREAD_LDFLAGS "") | ||
812 | elseif(FREEBSD) | ||
813 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
814 | set(PTHREAD_LDFLAGS "-pthread") | ||
815 | elseif(NETBSD) | ||
816 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
817 | set(PTHREAD_LDFLAGS "-lpthread") | ||
818 | elseif(OPENBSD) | ||
819 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
820 | set(PTHREAD_LDFLAGS "-lpthread") | ||
821 | elseif(SOLARIS) | ||
822 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
823 | if(CMAKE_C_COMPILER_ID MATCHES "SunPro") | ||
824 | set(PTHREAD_LDFLAGS "-mt -lpthread") | ||
825 | else() | ||
826 | set(PTHREAD_LDFLAGS "-pthread") | ||
827 | endif() | ||
828 | elseif(SYSV5) | ||
829 | set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread") | ||
830 | set(PTHREAD_LDFLAGS "") | ||
831 | elseif(AIX) | ||
832 | set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads") | ||
833 | set(PTHREAD_LDFLAGS "-pthread") | ||
834 | elseif(HPUX) | ||
835 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
836 | set(PTHREAD_LDFLAGS "-L/usr/lib -pthread") | ||
837 | elseif(HAIKU) | ||
838 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
839 | set(PTHREAD_LDFLAGS "") | ||
840 | elseif(EMSCRIPTEN) | ||
841 | set(PTHREAD_CFLAGS "-D_REENTRANT -pthread") | ||
842 | set(PTHREAD_LDFLAGS "-pthread") | ||
843 | elseif(QNX) | ||
844 | # pthread support is baked in | ||
845 | else() | ||
846 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
847 | set(PTHREAD_LDFLAGS "-lpthread") | ||
848 | endif() | ||
849 | |||
850 | # Run some tests | ||
851 | string(APPEND CMAKE_REQUIRED_FLAGS " ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}") | ||
852 | check_c_source_compiles(" | ||
853 | #include <pthread.h> | ||
854 | int main(int argc, char** argv) { | ||
855 | pthread_attr_t type; | ||
856 | pthread_attr_init(&type); | ||
857 | return 0; | ||
858 | }" HAVE_PTHREADS) | ||
859 | if(HAVE_PTHREADS) | ||
860 | set(SDL_THREAD_PTHREAD 1) | ||
861 | separate_arguments(PTHREAD_CFLAGS) | ||
862 | sdl_compile_options(PRIVATE ${PTHREAD_CFLAGS}) | ||
863 | sdl_link_dependency(pthread LINK_OPTIONS ${PTHREAD_LDFLAGS}) | ||
864 | |||
865 | check_c_source_compiles(" | ||
866 | #include <pthread.h> | ||
867 | int main(int argc, char **argv) { | ||
868 | pthread_mutexattr_t attr; | ||
869 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); | ||
870 | return 0; | ||
871 | }" HAVE_RECURSIVE_MUTEXES) | ||
872 | if(HAVE_RECURSIVE_MUTEXES) | ||
873 | set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1) | ||
874 | else() | ||
875 | check_c_source_compiles(" | ||
876 | #include <pthread.h> | ||
877 | int main(int argc, char **argv) { | ||
878 | pthread_mutexattr_t attr; | ||
879 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); | ||
880 | return 0; | ||
881 | }" HAVE_RECURSIVE_MUTEXES_NP) | ||
882 | if(HAVE_RECURSIVE_MUTEXES_NP) | ||
883 | set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1) | ||
884 | endif() | ||
885 | endif() | ||
886 | |||
887 | if(SDL_PTHREADS_SEM) | ||
888 | check_c_source_compiles("#include <pthread.h> | ||
889 | #include <semaphore.h> | ||
890 | int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM) | ||
891 | if(HAVE_PTHREADS_SEM) | ||
892 | check_c_source_compiles(" | ||
893 | #include <pthread.h> | ||
894 | #include <semaphore.h> | ||
895 | int main(int argc, char **argv) { | ||
896 | sem_timedwait(NULL, NULL); | ||
897 | return 0; | ||
898 | }" COMPILER_HAS_SEM_TIMEDWAIT) | ||
899 | set(HAVE_SEM_TIMEDWAIT ${COMPILER_HAS_SEM_TIMEDWAIT}) | ||
900 | endif() | ||
901 | endif() | ||
902 | |||
903 | check_include_file(pthread.h HAVE_PTHREAD_H) | ||
904 | check_include_file(pthread_np.h HAVE_PTHREAD_NP_H) | ||
905 | if (HAVE_PTHREAD_H) | ||
906 | check_c_source_compiles(" | ||
907 | #include <pthread.h> | ||
908 | int main(int argc, char **argv) { | ||
909 | #ifdef __APPLE__ | ||
910 | pthread_setname_np(\"\"); | ||
911 | #else | ||
912 | pthread_setname_np(pthread_self(),\"\"); | ||
913 | #endif | ||
914 | return 0; | ||
915 | }" HAVE_PTHREAD_SETNAME_NP) | ||
916 | if (HAVE_PTHREAD_NP_H) | ||
917 | check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP) | ||
918 | endif() | ||
919 | endif() | ||
920 | |||
921 | sdl_sources( | ||
922 | "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c" | ||
923 | "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c" # Can be faked, if necessary | ||
924 | "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c" # Can be faked, if necessary | ||
925 | "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysrwlock.c" # Can be faked, if necessary | ||
926 | "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systls.c" | ||
927 | ) | ||
928 | if(HAVE_PTHREADS_SEM) | ||
929 | sdl_sources("${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c") | ||
930 | else() | ||
931 | sdl_sources("${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c") | ||
932 | endif() | ||
933 | set(HAVE_SDL_THREADS TRUE) | ||
934 | endif() | ||
935 | endif() | ||
936 | cmake_pop_check_state() | ||
937 | endmacro() | ||
938 | |||
939 | # Requires | ||
940 | # - nada | ||
941 | # Optional: | ||
942 | # Sets: | ||
943 | # USB_LIBS | ||
944 | # USB_CFLAGS | ||
945 | macro(CheckUSBHID) | ||
946 | cmake_push_check_state() | ||
947 | check_library_exists(usbhid hid_init "" LIBUSBHID) | ||
948 | if(LIBUSBHID) | ||
949 | check_include_file(usbhid.h HAVE_USBHID_H) | ||
950 | if(HAVE_USBHID_H) | ||
951 | set(USB_CFLAGS "-DHAVE_USBHID_H") | ||
952 | endif() | ||
953 | |||
954 | check_include_file(libusbhid.h HAVE_LIBUSBHID_H) | ||
955 | if(HAVE_LIBUSBHID_H) | ||
956 | string(APPEND USB_CFLAGS " -DHAVE_LIBUSBHID_H") | ||
957 | endif() | ||
958 | set(USB_LIBS ${USB_LIBS} usbhid) | ||
959 | else() | ||
960 | check_include_file(usb.h HAVE_USB_H) | ||
961 | if(HAVE_USB_H) | ||
962 | set(USB_CFLAGS "-DHAVE_USB_H") | ||
963 | endif() | ||
964 | check_include_file(libusb.h HAVE_LIBUSB_H) | ||
965 | if(HAVE_LIBUSB_H) | ||
966 | string(APPEND USB_CFLAGS " -DHAVE_LIBUSB_H") | ||
967 | endif() | ||
968 | check_library_exists(usb hid_init "" LIBUSB) | ||
969 | if(LIBUSB) | ||
970 | list(APPEND USB_LIBS usb) | ||
971 | endif() | ||
972 | endif() | ||
973 | |||
974 | string(APPEND CMAKE_REQUIRED_FLAGS " ${USB_CFLAGS}") | ||
975 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${USB_LIBS}) | ||
976 | check_c_source_compiles(" | ||
977 | #include <sys/types.h> | ||
978 | #if defined(HAVE_USB_H) | ||
979 | #include <usb.h> | ||
980 | #endif | ||
981 | #ifdef __DragonFly__ | ||
982 | # include <bus/u4b/usb.h> | ||
983 | # include <bus/u4b/usbhid.h> | ||
984 | #else | ||
985 | # include <dev/usb/usb.h> | ||
986 | # include <dev/usb/usbhid.h> | ||
987 | #endif | ||
988 | #if defined(HAVE_USBHID_H) | ||
989 | #include <usbhid.h> | ||
990 | #elif defined(HAVE_LIBUSB_H) | ||
991 | #include <libusb.h> | ||
992 | #elif defined(HAVE_LIBUSBHID_H) | ||
993 | #include <libusbhid.h> | ||
994 | #endif | ||
995 | int main(int argc, char **argv) { | ||
996 | struct report_desc *repdesc; | ||
997 | struct usb_ctl_report *repbuf; | ||
998 | hid_kind_t hidkind; | ||
999 | return 0; | ||
1000 | }" HAVE_USBHID) | ||
1001 | if(HAVE_USBHID) | ||
1002 | check_c_source_compiles(" | ||
1003 | #include <sys/types.h> | ||
1004 | #if defined(HAVE_USB_H) | ||
1005 | #include <usb.h> | ||
1006 | #endif | ||
1007 | #ifdef __DragonFly__ | ||
1008 | # include <bus/u4b/usb.h> | ||
1009 | # include <bus/u4b/usbhid.h> | ||
1010 | #else | ||
1011 | # include <dev/usb/usb.h> | ||
1012 | # include <dev/usb/usbhid.h> | ||
1013 | #endif | ||
1014 | #if defined(HAVE_USBHID_H) | ||
1015 | #include <usbhid.h> | ||
1016 | #elif defined(HAVE_LIBUSB_H) | ||
1017 | #include <libusb.h> | ||
1018 | #elif defined(HAVE_LIBUSBHID_H) | ||
1019 | #include <libusbhid.h> | ||
1020 | #endif | ||
1021 | int main(int argc, char** argv) { | ||
1022 | struct usb_ctl_report buf; | ||
1023 | if (buf.ucr_data) { } | ||
1024 | return 0; | ||
1025 | }" HAVE_USBHID_UCR_DATA) | ||
1026 | if(HAVE_USBHID_UCR_DATA) | ||
1027 | string(APPEND USB_CFLAGS " -DUSBHID_UCR_DATA") | ||
1028 | endif() | ||
1029 | |||
1030 | check_c_source_compiles(" | ||
1031 | #include <sys/types.h> | ||
1032 | #if defined(HAVE_USB_H) | ||
1033 | #include <usb.h> | ||
1034 | #endif | ||
1035 | #ifdef __DragonFly__ | ||
1036 | #include <bus/u4b/usb.h> | ||
1037 | #include <bus/u4b/usbhid.h> | ||
1038 | #else | ||
1039 | #include <dev/usb/usb.h> | ||
1040 | #include <dev/usb/usbhid.h> | ||
1041 | #endif | ||
1042 | #if defined(HAVE_USBHID_H) | ||
1043 | #include <usbhid.h> | ||
1044 | #elif defined(HAVE_LIBUSB_H) | ||
1045 | #include <libusb.h> | ||
1046 | #elif defined(HAVE_LIBUSBHID_H) | ||
1047 | #include <libusbhid.h> | ||
1048 | #endif | ||
1049 | int main(int argc, char **argv) { | ||
1050 | report_desc_t d; | ||
1051 | hid_start_parse(d, 1, 1); | ||
1052 | return 0; | ||
1053 | }" HAVE_USBHID_NEW) | ||
1054 | if(HAVE_USBHID_NEW) | ||
1055 | string(APPEND USB_CFLAGS " -DUSBHID_NEW") | ||
1056 | endif() | ||
1057 | |||
1058 | check_c_source_compiles(" | ||
1059 | #include <machine/joystick.h> | ||
1060 | int main(int argc, char** argv) { | ||
1061 | struct joystick t; | ||
1062 | return 0; | ||
1063 | }" HAVE_MACHINE_JOYSTICK) | ||
1064 | if(HAVE_MACHINE_JOYSTICK) | ||
1065 | set(SDL_HAVE_MACHINE_JOYSTICK_H 1) | ||
1066 | endif() | ||
1067 | set(SDL_JOYSTICK_USBHID 1) | ||
1068 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/bsd/*.c") | ||
1069 | separate_arguments(USB_CFLAGS) | ||
1070 | sdl_compile_options(PRIVATE ${USB_CFLAGS}) | ||
1071 | #FIXME: properly add usb libs with pkg-config or whatever | ||
1072 | sdl_link_dependency(usbhid LIBS ${USB_LIBS}) | ||
1073 | set(HAVE_SDL_JOYSTICK TRUE) | ||
1074 | endif() | ||
1075 | cmake_pop_check_state() | ||
1076 | endmacro() | ||
1077 | |||
1078 | # Check for HIDAPI support | ||
1079 | macro(CheckHIDAPI) | ||
1080 | if(ANDROID) | ||
1081 | enable_language(CXX) | ||
1082 | sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp") | ||
1083 | endif() | ||
1084 | if(IOS OR TVOS) | ||
1085 | sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/ios/hid.m") | ||
1086 | set(SDL_FRAMEWORK_COREBLUETOOTH 1) | ||
1087 | endif() | ||
1088 | if(SDL_HIDAPI) | ||
1089 | set(HAVE_HIDAPI ON) | ||
1090 | if(SDL_HIDAPI_LIBUSB) | ||
1091 | set(HAVE_LIBUSB FALSE) | ||
1092 | find_package(LibUSB) | ||
1093 | if(LibUSB_FOUND) | ||
1094 | cmake_push_check_state() | ||
1095 | list(APPEND CMAKE_REQUIRED_LIBRARIES LibUSB::LibUSB) | ||
1096 | check_c_source_compiles(" | ||
1097 | #include <stddef.h> | ||
1098 | #include <libusb.h> | ||
1099 | int main(int argc, char **argv) { | ||
1100 | libusb_close(NULL); | ||
1101 | return 0; | ||
1102 | }" HAVE_LIBUSB_H) | ||
1103 | cmake_pop_check_state() | ||
1104 | if(HAVE_LIBUSB_H) | ||
1105 | set(HAVE_LIBUSB TRUE) | ||
1106 | target_get_dynamic_library(dynamic_libusb LibUSB::LibUSB) | ||
1107 | if(SDL_HIDAPI_LIBUSB_SHARED AND dynamic_libusb) | ||
1108 | set(HAVE_HIDAPI_LIBUSB_SHARED ON) | ||
1109 | set(SDL_LIBUSB_DYNAMIC "\"${dynamic_libusb}\"") | ||
1110 | sdl_link_dependency(hidapi INCLUDES $<TARGET_PROPERTY:LibUSB::LibUSB,INTERFACE_INCLUDE_DIRECTORIES>) | ||
1111 | else() | ||
1112 | sdl_link_dependency(hidapi LIBS LibUSB::LibUSB PKG_CONFIG_SPECS "${LibUSB_PKG_CONFIG_SPEC}" CMAKE_MODULE LibUSB) | ||
1113 | endif() | ||
1114 | endif() | ||
1115 | endif() | ||
1116 | set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB}) | ||
1117 | endif() | ||
1118 | |||
1119 | if(HAVE_HIDAPI) | ||
1120 | set(HAVE_SDL_HIDAPI TRUE) | ||
1121 | |||
1122 | if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK) | ||
1123 | set(SDL_JOYSTICK_HIDAPI 1) | ||
1124 | set(HAVE_SDL_JOYSTICK TRUE) | ||
1125 | set(HAVE_HIDAPI_JOYSTICK TRUE) | ||
1126 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/hidapi/*.c") | ||
1127 | endif() | ||
1128 | else() | ||
1129 | set(SDL_HIDAPI_DISABLED 1) | ||
1130 | endif() | ||
1131 | else() | ||
1132 | set(SDL_HIDAPI_DISABLED 1) | ||
1133 | endif() | ||
1134 | endmacro() | ||
1135 | |||
1136 | # Requires: | ||
1137 | # - n/a | ||
1138 | macro(CheckRPI) | ||
1139 | if(SDL_RPI) | ||
1140 | set(BCM_HOST_PKG_CONFIG_SPEC bcm_host) | ||
1141 | set(BRCMEGL_PKG_CONFIG_SPEC brcmegl) | ||
1142 | |||
1143 | set(original_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH}) | ||
1144 | set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}:/opt/vc/lib/pkgconfig") | ||
1145 | set(PC_BCM_HOST_FOUND FALSE) | ||
1146 | set(PC_BRCMEGL_FOUND FALSE) | ||
1147 | if(PKG_CONFIG_FOUND) | ||
1148 | pkg_check_modules(PC_BCM_HOST IMPORTED_TARGET QUIET ${BCM_HOST_PKG_CONFIG_SPEC}) | ||
1149 | pkg_check_modules(PC_BRCMEGL IMPORTED_TARGET QUIET ${BRCMEGL_PKG_CONFIG_SPEC}) | ||
1150 | endif() | ||
1151 | set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}") | ||
1152 | |||
1153 | if(TARGET PkgConfig::PC_BCM_HOST AND TARGET PkgConfig::PC_BRCMEGL) | ||
1154 | set(HAVE_RPI TRUE) | ||
1155 | if(SDL_VIDEO) | ||
1156 | set(HAVE_SDL_VIDEO TRUE) | ||
1157 | set(SDL_VIDEO_DRIVER_RPI 1) | ||
1158 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/raspberry/*.c") | ||
1159 | sdl_link_dependency(rpi-video LIBS PkgConfig::PC_BCM_HOST PKG_CONFIG_PREFIX PC_BCM_HOST PKG_CONFIG_SPECS ${BCM_HOST_PKG_CONFIG_SPEC}) | ||
1160 | endif() | ||
1161 | endif() | ||
1162 | endif() | ||
1163 | endmacro() | ||
1164 | |||
1165 | # Requires: | ||
1166 | # - n/a | ||
1167 | macro(CheckROCKCHIP) | ||
1168 | if(SDL_ROCKCHIP) | ||
1169 | set(MALI_PKG_CONFIG_SPEC mali) | ||
1170 | set(PC_MALI_FOUND FALSE) | ||
1171 | if(PKG_CONFIG_FOUND) | ||
1172 | pkg_check_modules(PC_MALI QUIET ${MALI_PKG_CONFIG_SPEC}) | ||
1173 | endif() | ||
1174 | if(PC_MALI_FOUND) | ||
1175 | set(HAVE_ROCKCHIP TRUE) | ||
1176 | endif() | ||
1177 | if(SDL_VIDEO AND HAVE_ROCKCHIP) | ||
1178 | set(HAVE_SDL_VIDEO TRUE) | ||
1179 | set(SDL_VIDEO_DRIVER_ROCKCHIP 1) | ||
1180 | endif() | ||
1181 | endif() | ||
1182 | endmacro() | ||
1183 | |||
1184 | # Requires: | ||
1185 | # - EGL | ||
1186 | # - PkgCheckModules | ||
1187 | # Optional: | ||
1188 | # - SDL_KMSDRM_SHARED opt | ||
1189 | # - HAVE_SDL_LOADSO opt | ||
1190 | macro(CheckKMSDRM) | ||
1191 | if(SDL_KMSDRM) | ||
1192 | set(PKG_CONFIG_LIBDRM_SPEC libdrm) | ||
1193 | set(PKG_CONFIG_GBM_SPEC gbm) | ||
1194 | set(PC_LIBDRM_FOUND FALSE) | ||
1195 | set(PC_GBM_FOUND FALSE) | ||
1196 | if(PKG_CONFIG_FOUND) | ||
1197 | pkg_check_modules(PC_LIBDRM IMPORTED_TARGET ${PKG_CONFIG_LIBDRM_SPEC}) | ||
1198 | pkg_check_modules(PC_GBM IMPORTED_TARGET ${PKG_CONFIG_GBM_SPEC}) | ||
1199 | endif() | ||
1200 | if(PC_LIBDRM_FOUND AND PC_GBM_FOUND AND HAVE_OPENGL_EGL) | ||
1201 | set(HAVE_KMSDRM TRUE) | ||
1202 | set(HAVE_SDL_VIDEO TRUE) | ||
1203 | |||
1204 | sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/kmsdrm/*.c") | ||
1205 | |||
1206 | set(SDL_VIDEO_DRIVER_KMSDRM 1) | ||
1207 | |||
1208 | if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO) | ||
1209 | message(WARNING "You must have SDL_LoadObject() support for dynamic KMS/DRM loading") | ||
1210 | endif() | ||
1211 | set(HAVE_KMSDRM_SHARED FALSE) | ||
1212 | if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO) | ||
1213 | FindLibraryAndSONAME(drm LIBDIRS ${PC_LIBDRM_LIBRARY_DIRS}) | ||
1214 | FindLibraryAndSONAME(gbm LIBDIRS ${PC_GBM_LIBRARY_DIRS}) | ||
1215 | if(DRM_LIB AND DRM_SHARED AND GBM_LIB AND GBM_SHARED) | ||
1216 | set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"") | ||
1217 | set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"") | ||
1218 | set(HAVE_KMSDRM_SHARED TRUE) | ||
1219 | sdl_link_dependency(kmsdrm-drm INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBDRM,INTERFACE_INCLUDE_DIRECTORIES>) | ||
1220 | sdl_link_dependency(kmsdrm-gbm INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_GBM,INTERFACE_INCLUDE_DIRECTORIES>) | ||
1221 | endif() | ||
1222 | endif() | ||
1223 | if(NOT HAVE_KMSDRM_SHARED) | ||
1224 | sdl_link_dependency(kmsdrm-libdrm LIBS PkgConfig::PC_LIBDRM PKG_CONFIG_PREFIX PC_LIBDRM PKG_CONFIG_SPECS ${PKG_CONFIG_LIBDRM_SPEC}) | ||
1225 | sdl_link_dependency(kmsdrm-gbm LIBS PkgConfig::PC_GBM PKG_CONFIG_PREFIX PC_GBM PKG_CONFIG_SPECS ${PKG_CONFIG_GBM_SPEC}) | ||
1226 | endif() | ||
1227 | endif() | ||
1228 | endif() | ||
1229 | endmacro() | ||
1230 | |||
1231 | macro(CheckLibUDev) | ||
1232 | if(SDL_LIBUDEV) | ||
1233 | check_include_file("libudev.h" HAVE_LIBUDEV_HEADER) | ||
1234 | if(HAVE_LIBUDEV_HEADER) | ||
1235 | set(HAVE_LIBUDEV_H TRUE) | ||
1236 | FindLibraryAndSONAME(udev) | ||
1237 | if(UDEV_LIB_SONAME) | ||
1238 | set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"") | ||
1239 | set(HAVE_LIBUDEV TRUE) | ||
1240 | endif() | ||
1241 | endif() | ||
1242 | endif() | ||
1243 | endmacro() | ||
1244 | |||
1245 | macro(CheckLibUnwind) | ||
1246 | if(TARGET SDL3_test) | ||
1247 | set(found_libunwind FALSE) | ||
1248 | set(_libunwind_src [==[ | ||
1249 | #include <libunwind.h> | ||
1250 | int main(int argc, char *argv[]) { | ||
1251 | (void)argc; (void)argv; | ||
1252 | unw_context_t context; | ||
1253 | unw_cursor_t cursor; | ||
1254 | unw_word_t pc; | ||
1255 | char sym[256]; | ||
1256 | unw_word_t offset; | ||
1257 | unw_getcontext(&context); | ||
1258 | unw_step(&cursor); | ||
1259 | unw_get_reg(&cursor, UNW_REG_IP, &pc); | ||
1260 | unw_get_proc_name(&cursor, sym, sizeof(sym), &offset); | ||
1261 | return 0; | ||
1262 | }]==]) | ||
1263 | |||
1264 | if(NOT found_libunwind) | ||
1265 | cmake_push_check_state() | ||
1266 | check_c_source_compiles("${_libunwind_src}" LIBC_HAS_WORKING_LIBUNWIND) | ||
1267 | cmake_pop_check_state() | ||
1268 | if(LIBC_HAS_WORKING_LIBUNWIND) | ||
1269 | set(found_libunwind TRUE) | ||
1270 | target_compile_definitions(SDL3_test PRIVATE HAVE_LIBUNWIND_H) | ||
1271 | endif() | ||
1272 | endif() | ||
1273 | |||
1274 | if(NOT found_libunwind) | ||
1275 | cmake_push_check_state() | ||
1276 | list(APPEND CMAKE_REQUIRED_LIBRARIES "unwind") | ||
1277 | check_c_source_compiles("${_libunwind_src}" LIBUNWIND_HAS_WORKINGLIBUNWIND) | ||
1278 | cmake_pop_check_state() | ||
1279 | if(LIBUNWIND_HAS_WORKINGLIBUNWIND) | ||
1280 | set(found_libunwind TRUE) | ||
1281 | sdl_test_link_dependency(UNWIND LIBS unwind) | ||
1282 | endif() | ||
1283 | endif() | ||
1284 | |||
1285 | if(NOT found_libunwind) | ||
1286 | set(LibUnwind_PKG_CONFIG_SPEC libunwind libunwind-generic) | ||
1287 | set(PC_LIBUNWIND_FOUND FALSE) | ||
1288 | if(PKG_CONFIG_FOUND) | ||
1289 | pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC}) | ||
1290 | endif() | ||
1291 | if(PC_LIBUNWIND_FOUND) | ||
1292 | cmake_push_check_state() | ||
1293 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${PC_LIBUNWIND_LIBRARIES}) | ||
1294 | list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS}) | ||
1295 | check_c_source_compiles("${_libunwind_src}" PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) | ||
1296 | cmake_pop_check_state() | ||
1297 | if(PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) | ||
1298 | set(found_libunwind TRUE) | ||
1299 | sdl_test_link_dependency(UNWIND LIBS PkgConfig::PC_LIBUNWIND PKG_CONFIG_PREFIX PC_LIBUNWIND PKG_CONFIG_SPECS ${LibUnwind_PKG_CONFIG_SPEC}) | ||
1300 | endif() | ||
1301 | endif() | ||
1302 | endif() | ||
1303 | |||
1304 | if(found_libunwind) | ||
1305 | target_compile_definitions(SDL3_test PRIVATE HAVE_LIBUNWIND_H) | ||
1306 | endif() | ||
1307 | endif() | ||
1308 | endmacro() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdlcompilers.cmake b/src/contrib/SDL-3.2.20/cmake/sdlcompilers.cmake new file mode 100644 index 0000000..c3d8c47 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdlcompilers.cmake | |||
@@ -0,0 +1,162 @@ | |||
1 | macro(SDL_DetectCompiler) | ||
2 | set(USE_CLANG FALSE) | ||
3 | set(USE_GCC FALSE) | ||
4 | set(USE_INTELCC FALSE) | ||
5 | set(USE_QCC FALSE) | ||
6 | if(CMAKE_C_COMPILER_ID MATCHES "Clang|IntelLLVM") | ||
7 | set(USE_CLANG TRUE) | ||
8 | # Visual Studio 2019 v16.2 added support for Clang/LLVM. | ||
9 | # Check if a Visual Studio project is being generated with the Clang toolset. | ||
10 | if(MSVC) | ||
11 | set(MSVC_CLANG TRUE) | ||
12 | endif() | ||
13 | elseif(CMAKE_COMPILER_IS_GNUCC) | ||
14 | set(USE_GCC TRUE) | ||
15 | elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$") | ||
16 | set(USE_INTELCC TRUE) | ||
17 | elseif(CMAKE_C_COMPILER_ID MATCHES "QCC") | ||
18 | set(USE_QCC TRUE) | ||
19 | endif() | ||
20 | endmacro() | ||
21 | |||
22 | function(sdl_target_compile_option_all_languages TARGET OPTION) | ||
23 | target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:${OPTION}>") | ||
24 | if(CMAKE_OBJC_COMPILER) | ||
25 | target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:OBJC>:${OPTION}>") | ||
26 | endif() | ||
27 | endfunction() | ||
28 | |||
29 | function(SDL_AddCommonCompilerFlags TARGET) | ||
30 | option(SDL_WERROR "Enable -Werror" OFF) | ||
31 | |||
32 | get_property(TARGET_TYPE TARGET "${TARGET}" PROPERTY TYPE) | ||
33 | if(MSVC) | ||
34 | cmake_push_check_state() | ||
35 | check_c_compiler_flag("/W3" COMPILER_SUPPORTS_W3) | ||
36 | if(COMPILER_SUPPORTS_W3) | ||
37 | target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/W3>") | ||
38 | endif() | ||
39 | cmake_pop_check_state() | ||
40 | endif() | ||
41 | |||
42 | if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) | ||
43 | if(MINGW) | ||
44 | # See if GCC's -gdwarf-4 is supported | ||
45 | # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377 for why this is needed on Windows | ||
46 | cmake_push_check_state() | ||
47 | check_c_compiler_flag("-gdwarf-4" HAVE_GDWARF_4) | ||
48 | if(HAVE_GDWARF_4) | ||
49 | target_compile_options(${TARGET} PRIVATE "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-gdwarf-4>") | ||
50 | endif() | ||
51 | cmake_pop_check_state() | ||
52 | endif() | ||
53 | |||
54 | # Check for -Wall first, so later things can override pieces of it. | ||
55 | # Note: clang-cl treats -Wall as -Weverything (which is very loud), | ||
56 | # /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough. | ||
57 | check_c_compiler_flag(-Wall HAVE_GCC_WALL) | ||
58 | if(MSVC_CLANG) | ||
59 | target_compile_options(${TARGET} PRIVATE "/W3") | ||
60 | elseif(HAVE_GCC_WALL) | ||
61 | sdl_target_compile_option_all_languages(${TARGET} "-Wall") | ||
62 | if(HAIKU) | ||
63 | sdl_target_compile_option_all_languages(${TARGET} "-Wno-multichar") | ||
64 | endif() | ||
65 | endif() | ||
66 | |||
67 | check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF) | ||
68 | if(HAVE_GCC_WUNDEF) | ||
69 | sdl_target_compile_option_all_languages(${TARGET} "-Wundef") | ||
70 | endif() | ||
71 | |||
72 | check_c_compiler_flag(-Wfloat-conversion HAVE_GCC_WFLOAT_CONVERSION) | ||
73 | if(HAVE_GCC_WFLOAT_CONVERSION) | ||
74 | sdl_target_compile_option_all_languages(${TARGET} "-Wfloat-conversion") | ||
75 | endif() | ||
76 | |||
77 | check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING) | ||
78 | if(HAVE_GCC_NO_STRICT_ALIASING) | ||
79 | sdl_target_compile_option_all_languages(${TARGET} "-fno-strict-aliasing") | ||
80 | endif() | ||
81 | |||
82 | check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION) | ||
83 | if(HAVE_GCC_WDOCUMENTATION) | ||
84 | if(SDL_WERROR) | ||
85 | check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION) | ||
86 | if(HAVE_GCC_WERROR_DOCUMENTATION) | ||
87 | sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation") | ||
88 | endif() | ||
89 | endif() | ||
90 | sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation") | ||
91 | endif() | ||
92 | |||
93 | check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) | ||
94 | if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) | ||
95 | if(SDL_WERROR) | ||
96 | check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) | ||
97 | if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) | ||
98 | sdl_target_compile_option_all_languages(${TARGET} "-Werror=documentation-unknown-command") | ||
99 | endif() | ||
100 | endif() | ||
101 | sdl_target_compile_option_all_languages(${TARGET} "-Wdocumentation-unknown-command") | ||
102 | endif() | ||
103 | |||
104 | check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS) | ||
105 | if(HAVE_GCC_COMMENT_BLOCK_COMMANDS) | ||
106 | sdl_target_compile_option_all_languages(${TARGET} "-fcomment-block-commands=threadsafety") | ||
107 | else() | ||
108 | check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS) | ||
109 | if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS) | ||
110 | sdl_target_compile_option_all_languages(${TARGET} "/clang:-fcomment-block-commands=threadsafety") | ||
111 | endif() | ||
112 | endif() | ||
113 | |||
114 | check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW) | ||
115 | if(HAVE_GCC_WSHADOW) | ||
116 | sdl_target_compile_option_all_languages(${TARGET} "-Wshadow") | ||
117 | endif() | ||
118 | |||
119 | check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS) | ||
120 | if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS) | ||
121 | sdl_target_compile_option_all_languages(${TARGET} "-Wno-unused-local-typedefs") | ||
122 | endif() | ||
123 | |||
124 | check_c_compiler_flag(-Wimplicit-fallthrough HAVE_GCC_WIMPLICIT_FALLTHROUGH) | ||
125 | if(HAVE_GCC_WIMPLICIT_FALLTHROUGH) | ||
126 | sdl_target_compile_option_all_languages(${TARGET} "-Wimplicit-fallthrough") | ||
127 | endif() | ||
128 | endif() | ||
129 | |||
130 | if(SDL_WERROR) | ||
131 | if(MSVC) | ||
132 | check_c_compiler_flag(/WX HAVE_WX) | ||
133 | if(HAVE_WX) | ||
134 | target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/WX>") | ||
135 | endif() | ||
136 | elseif(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QNX) | ||
137 | check_c_compiler_flag(-Werror HAVE_WERROR) | ||
138 | if(HAVE_WERROR) | ||
139 | sdl_target_compile_option_all_languages(${TARGET} "-Werror") | ||
140 | endif() | ||
141 | |||
142 | if(TARGET_TYPE STREQUAL "SHARED_LIBRARY") | ||
143 | check_linker_flag(C "-Wl,--no-undefined-version" LINKER_SUPPORTS_NO_UNDEFINED_VERSION) | ||
144 | if(LINKER_SUPPORTS_NO_UNDEFINED_VERSION) | ||
145 | target_link_options(${TARGET} PRIVATE "-Wl,--no-undefined-version") | ||
146 | endif() | ||
147 | endif() | ||
148 | endif() | ||
149 | endif() | ||
150 | |||
151 | if(USE_CLANG) | ||
152 | check_c_compiler_flag("-fcolor-diagnostics" COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS) | ||
153 | if(COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS) | ||
154 | sdl_target_compile_option_all_languages(${TARGET} "-fcolor-diagnostics") | ||
155 | endif() | ||
156 | else() | ||
157 | check_c_compiler_flag("-fdiagnostics-color=always" COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS) | ||
158 | if(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS) | ||
159 | sdl_target_compile_option_all_languages(${TARGET} "-fdiagnostics-color=always") | ||
160 | endif() | ||
161 | endif() | ||
162 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdlcpu.cmake b/src/contrib/SDL-3.2.20/cmake/sdlcpu.cmake new file mode 100644 index 0000000..0c2ca1f --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdlcpu.cmake | |||
@@ -0,0 +1,156 @@ | |||
1 | function(SDL_DetectTargetCPUArchitectures DETECTED_ARCHS) | ||
2 | |||
3 | set(known_archs EMSCRIPTEN ARM32 ARM64 ARM64EC LOONGARCH64 POWERPC32 POWERPC64 X86 X64) | ||
4 | |||
5 | if(APPLE AND CMAKE_OSX_ARCHITECTURES) | ||
6 | foreach(known_arch IN LISTS known_archs) | ||
7 | set(SDL_CPU_${known_arch} "0") | ||
8 | endforeach() | ||
9 | set(detected_archs) | ||
10 | foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES) | ||
11 | if(osx_arch STREQUAL "x86_64") | ||
12 | set(SDL_CPU_X64 "1") | ||
13 | list(APPEND detected_archs "X64") | ||
14 | elseif(osx_arch STREQUAL "arm64") | ||
15 | set(SDL_CPU_ARM64 "1") | ||
16 | list(APPEND detected_archs "ARM64") | ||
17 | endif() | ||
18 | endforeach() | ||
19 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) | ||
20 | return() | ||
21 | endif() | ||
22 | |||
23 | set(detected_archs) | ||
24 | foreach(known_arch IN LISTS known_archs) | ||
25 | if(SDL_CPU_${known_arch}) | ||
26 | list(APPEND detected_archs "${known_arch}") | ||
27 | endif() | ||
28 | endforeach() | ||
29 | |||
30 | if(detected_archs) | ||
31 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) | ||
32 | return() | ||
33 | endif() | ||
34 | |||
35 | set(arch_check_ARM32 "defined(__arm__) || defined(_M_ARM)") | ||
36 | set(arch_check_ARM64 "defined(__aarch64__) || defined(_M_ARM64)") | ||
37 | set(arch_check_ARM64EC "defined(_M_ARM64EC)") | ||
38 | set(arch_check_EMSCRIPTEN "defined(__EMSCRIPTEN__)") | ||
39 | set(arch_check_LOONGARCH64 "defined(__loongarch64)") | ||
40 | set(arch_check_POWERPC32 "(defined(__PPC__) || defined(__powerpc__)) && !defined(__powerpc64__)") | ||
41 | set(arch_check_POWERPC64 "defined(__PPC64__) || defined(__powerpc64__)") | ||
42 | set(arch_check_X86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)") | ||
43 | set(arch_check_X64 "(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)") | ||
44 | |||
45 | set(src_vars "") | ||
46 | set(src_main "") | ||
47 | foreach(known_arch IN LISTS known_archs) | ||
48 | set(detected_${known_arch} "0") | ||
49 | |||
50 | string(APPEND src_vars " | ||
51 | #if ${arch_check_${known_arch}} | ||
52 | #define ARCH_${known_arch} \"1\" | ||
53 | #else | ||
54 | #define ARCH_${known_arch} \"0\" | ||
55 | #endif | ||
56 | const char *arch_${known_arch} = \"INFO<${known_arch}=\" ARCH_${known_arch} \">\"; | ||
57 | ") | ||
58 | string(APPEND src_main " | ||
59 | result += arch_${known_arch}[argc];") | ||
60 | endforeach() | ||
61 | |||
62 | set(src_arch_detect "${src_vars} | ||
63 | int main(int argc, char *argv[]) { | ||
64 | int result = 0; | ||
65 | (void)argv; | ||
66 | ${src_main} | ||
67 | return result; | ||
68 | }") | ||
69 | |||
70 | if(CMAKE_C_COMPILER) | ||
71 | set(ext ".c") | ||
72 | elseif(CMAKE_CXX_COMPILER) | ||
73 | set(ext ".cpp") | ||
74 | else() | ||
75 | enable_language(C) | ||
76 | set(ext ".c") | ||
77 | endif() | ||
78 | set(path_src_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch${ext}") | ||
79 | file(WRITE "${path_src_arch_detect}" "${src_arch_detect}") | ||
80 | set(path_dir_arch_detect "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch") | ||
81 | set(path_bin_arch_detect "${path_dir_arch_detect}/bin") | ||
82 | |||
83 | set(detected_archs) | ||
84 | |||
85 | set(msg "Detecting Target CPU Architecture") | ||
86 | message(STATUS "${msg}") | ||
87 | |||
88 | include(CMakePushCheckState) | ||
89 | |||
90 | set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") | ||
91 | |||
92 | cmake_push_check_state(RESET) | ||
93 | try_compile(SDL_CPU_CHECK_ALL | ||
94 | "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/SDL_detect_arch" | ||
95 | SOURCES "${path_src_arch_detect}" | ||
96 | COPY_FILE "${path_bin_arch_detect}" | ||
97 | ) | ||
98 | cmake_pop_check_state() | ||
99 | if(NOT SDL_CPU_CHECK_ALL) | ||
100 | message(STATUS "${msg} - <ERROR>") | ||
101 | message(WARNING "Failed to compile source detecting the target CPU architecture") | ||
102 | else() | ||
103 | set(re "INFO<([A-Z0-9]+)=([01])>") | ||
104 | file(STRINGS "${path_bin_arch_detect}" infos REGEX "${re}") | ||
105 | |||
106 | foreach(info_arch_01 IN LISTS infos) | ||
107 | string(REGEX MATCH "${re}" A "${info_arch_01}") | ||
108 | if(NOT "${CMAKE_MATCH_1}" IN_LIST known_archs) | ||
109 | message(WARNING "Unknown architecture: \"${CMAKE_MATCH_1}\"") | ||
110 | continue() | ||
111 | endif() | ||
112 | set(arch "${CMAKE_MATCH_1}") | ||
113 | set(arch_01 "${CMAKE_MATCH_2}") | ||
114 | set(detected_${arch} "${arch_01}") | ||
115 | endforeach() | ||
116 | |||
117 | foreach(known_arch IN LISTS known_archs) | ||
118 | if(detected_${known_arch}) | ||
119 | list(APPEND detected_archs ${known_arch}) | ||
120 | endif() | ||
121 | endforeach() | ||
122 | endif() | ||
123 | |||
124 | if(detected_archs) | ||
125 | foreach(known_arch IN LISTS known_archs) | ||
126 | set("SDL_CPU_${known_arch}" "${detected_${known_arch}}" CACHE BOOL "Detected architecture ${known_arch}") | ||
127 | endforeach() | ||
128 | message(STATUS "${msg} - ${detected_archs}") | ||
129 | else() | ||
130 | include(CheckCSourceCompiles) | ||
131 | cmake_push_check_state(RESET) | ||
132 | foreach(known_arch IN LISTS known_archs) | ||
133 | if(NOT detected_archs) | ||
134 | set(cache_variable "SDL_CPU_${known_arch}") | ||
135 | set(test_src " | ||
136 | int main(int argc, char *argv[]) { | ||
137 | #if ${arch_check_${known_arch}} | ||
138 | return 0; | ||
139 | #else | ||
140 | choke | ||
141 | #endif | ||
142 | } | ||
143 | ") | ||
144 | check_c_source_compiles("${test_src}" "${cache_variable}") | ||
145 | if(${cache_variable}) | ||
146 | set(SDL_CPU_${known_arch} "1" CACHE BOOL "Detected architecture ${known_arch}") | ||
147 | set(detected_archs ${known_arch}) | ||
148 | else() | ||
149 | set(SDL_CPU_${known_arch} "0" CACHE BOOL "Detected architecture ${known_arch}") | ||
150 | endif() | ||
151 | endif() | ||
152 | endforeach() | ||
153 | cmake_pop_check_state() | ||
154 | endif() | ||
155 | set("${DETECTED_ARCHS}" "${detected_archs}" PARENT_SCOPE) | ||
156 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdlmanpages.cmake b/src/contrib/SDL-3.2.20/cmake/sdlmanpages.cmake new file mode 100644 index 0000000..dc3ebb6 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdlmanpages.cmake | |||
@@ -0,0 +1,68 @@ | |||
1 | include(CMakeParseArguments) | ||
2 | include(GNUInstallDirs) | ||
3 | |||
4 | function(SDL_generate_manpages) | ||
5 | cmake_parse_arguments(ARG "" "RESULT_VARIABLE;NAME;BUILD_DOCDIR;HEADERS_DIR;SOURCE_DIR;SYMBOL;OPTION_FILE;WIKIHEADERS_PL_PATH;REVISION" "" ${ARGN}) | ||
6 | |||
7 | set(wikiheaders_extra_args) | ||
8 | |||
9 | if(NOT ARG_NAME) | ||
10 | set(ARG_NAME "${PROJECT_NAME}") | ||
11 | endif() | ||
12 | |||
13 | if(NOT ARG_SOURCE_DIR) | ||
14 | set(ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
15 | endif() | ||
16 | |||
17 | if(NOT ARG_OPTION_FILE) | ||
18 | set(ARG_OPTION_FILE "${PROJECT_SOURCE_DIR}/.wikiheaders-options") | ||
19 | endif() | ||
20 | |||
21 | if(NOT ARG_HEADERS_DIR) | ||
22 | message(FATAL_ERROR "Missing required HEADERS_DIR argument") | ||
23 | endif() | ||
24 | |||
25 | # FIXME: get rid of SYMBOL and let the perl script figure out the dependencies | ||
26 | if(NOT ARG_SYMBOL) | ||
27 | message(FATAL_ERROR "Missing required SYMBOL argument") | ||
28 | endif() | ||
29 | |||
30 | if(ARG_REVISION) | ||
31 | list(APPEND wikiheaders_extra_args "--rev=${ARG_REVISION}") | ||
32 | endif() | ||
33 | |||
34 | if(NOT ARG_BUILD_DOCDIR) | ||
35 | set(ARG_BUILD_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/docs") | ||
36 | endif() | ||
37 | set(BUILD_WIKIDIR "${ARG_BUILD_DOCDIR}/wiki") | ||
38 | set(BUILD_MANDIR "${ARG_BUILD_DOCDIR}/man") | ||
39 | |||
40 | find_package(Perl) | ||
41 | file(GLOB HEADER_FILES "${ARG_HEADERS_DIR}/*.h") | ||
42 | |||
43 | set(result FALSE) | ||
44 | |||
45 | if(PERL_FOUND AND EXISTS "${ARG_WIKIHEADERS_PL_PATH}") | ||
46 | add_custom_command( | ||
47 | OUTPUT "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" | ||
48 | COMMAND "${CMAKE_COMMAND}" -E make_directory "${BUILD_WIKIDIR}" | ||
49 | COMMAND "${PERL_EXECUTABLE}" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_SOURCE_DIR}" "${BUILD_WIKIDIR}" "--options=${ARG_OPTION_FILE}" --copy-to-wiki ${wikiheaders_extra_args} | ||
50 | DEPENDS ${HEADER_FILES} "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" | ||
51 | COMMENT "Generating ${ARG_NAME} wiki markdown files" | ||
52 | ) | ||
53 | add_custom_command( | ||
54 | OUTPUT "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3" | ||
55 | 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} | ||
56 | DEPENDS "${BUILD_WIKIDIR}/${ARG_SYMBOL}.md" "${ARG_WIKIHEADERS_PL_PATH}" "${ARG_OPTION_FILE}" | ||
57 | COMMENT "Generating ${ARG_NAME} man pages" | ||
58 | ) | ||
59 | add_custom_target(${ARG_NAME}-docs ALL DEPENDS "${BUILD_MANDIR}/man3/${ARG_SYMBOL}.3") | ||
60 | |||
61 | install(DIRECTORY "${BUILD_MANDIR}/" DESTINATION "${CMAKE_INSTALL_MANDIR}") | ||
62 | set(result TRUE) | ||
63 | endif() | ||
64 | |||
65 | if(ARG_RESULT_VARIABLE) | ||
66 | set(${ARG_RESULT_VARIABLE} ${result} PARENT_SCOPE) | ||
67 | endif() | ||
68 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdlplatform.cmake b/src/contrib/SDL-3.2.20/cmake/sdlplatform.cmake new file mode 100644 index 0000000..677b187 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdlplatform.cmake | |||
@@ -0,0 +1,70 @@ | |||
1 | function(SDL_DetectCMakePlatform) | ||
2 | set(sdl_cmake_platform ) | ||
3 | if(WIN32) | ||
4 | set(sdl_cmake_platform Windows) | ||
5 | elseif(PSP) | ||
6 | set(sdl_cmake_platform psp) | ||
7 | elseif(APPLE) | ||
8 | if(CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*") | ||
9 | set(sdl_cmake_platform macOS) | ||
10 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*") | ||
11 | set(sdl_cmake_platform tvOS) | ||
12 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*") | ||
13 | set(sdl_cmake_platform iOS) | ||
14 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*watchOS.*") | ||
15 | set(sdl_cmake_platform watchOS) | ||
16 | elseif (CMAKE_SYSTEM_NAME MATCHES "visionOS") | ||
17 | set(sdl_cmake_platform visionOS) | ||
18 | else() | ||
19 | message(WARNING "Unknown Apple platform: \"${CMAKE_SYSTEM_NAME}\"") | ||
20 | endif() | ||
21 | elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*") | ||
22 | set(sdl_cmake_platform Haiku) | ||
23 | elseif(NINTENDO_3DS) | ||
24 | set(sdl_cmake_platform n3ds) | ||
25 | elseif(PS2) | ||
26 | set(sdl_cmake_platform ps2) | ||
27 | elseif(VITA) | ||
28 | set(sdl_cmake_platform Vita) | ||
29 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*Linux") | ||
30 | set(sdl_cmake_platform Linux) | ||
31 | elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*") | ||
32 | set(sdl_cmake_platform FreeBSD) | ||
33 | elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*") | ||
34 | set(sdl_cmake_platform NetBSD) | ||
35 | elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*") | ||
36 | set(sdl_cmake_platform OpenBSD) | ||
37 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*") | ||
38 | set(sdl_cmake_platform GNU) | ||
39 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*") | ||
40 | set(sdl_cmake_platform BSDi) | ||
41 | elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD") | ||
42 | set(sdl_cmake_platform FreeBSD) | ||
43 | elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*") | ||
44 | set(sdl_cmake_platform SYSV5) | ||
45 | elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*") | ||
46 | set(sdl_cmake_platform Solaris) | ||
47 | elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*") | ||
48 | set(sdl_cmake_platform HPUX) | ||
49 | elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*") | ||
50 | set(sdl_cmake_platform AIX) | ||
51 | elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*") | ||
52 | set(sdl_cmake_platform Minix) | ||
53 | elseif(CMAKE_SYSTEM_NAME MATCHES "Android.*") | ||
54 | set(sdl_cmake_platform Android) | ||
55 | elseif(CMAKE_SYSTEM_NAME MATCHES "Emscripten.*") | ||
56 | set(sdl_cmake_platform Emscripten) | ||
57 | elseif(CMAKE_SYSTEM_NAME MATCHES "QNX.*") | ||
58 | set(sdl_cmake_platform QNX) | ||
59 | elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*") | ||
60 | message(FATAL_ERROR "BeOS support has been removed as of SDL 2.0.2.") | ||
61 | endif() | ||
62 | |||
63 | if(sdl_cmake_platform) | ||
64 | string(TOUPPER "${sdl_cmake_platform}" _upper_platform) | ||
65 | set("${_upper_platform}" TRUE PARENT_SCOPE) | ||
66 | else() | ||
67 | set(sdl_cmake_platform "unknown") | ||
68 | endif() | ||
69 | set(SDL_CMAKE_PLATFORM "${sdl_cmake_platform}" PARENT_SCOPE) | ||
70 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake b/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake new file mode 100644 index 0000000..d658eb3 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake | |||
@@ -0,0 +1,386 @@ | |||
1 | add_library(SDL3-collector INTERFACE) | ||
2 | add_library(SDL3_test-collector INTERFACE) | ||
3 | |||
4 | # Use sdl_glob_sources to add glob sources to SDL3-shared, to SDL3-static, or to both. | ||
5 | function(sdl_glob_sources) | ||
6 | cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN}) | ||
7 | file(GLOB shared_sources ${ARGS_SHARED}) | ||
8 | file(GLOB static_sources ${ARGS_STATIC}) | ||
9 | file(GLOB both_sources ${ARGS_UNPARSED_ARGUMENTS}) | ||
10 | if(TARGET SDL3-shared) | ||
11 | target_sources(SDL3-shared PRIVATE ${shared_sources} ${both_sources}) | ||
12 | endif() | ||
13 | if(TARGET SDL3-static) | ||
14 | target_sources(SDL3-static PRIVATE ${static_sources} ${both_sources}) | ||
15 | endif() | ||
16 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${shared_sources} ${static_sources} ${both_sources}) | ||
17 | endfunction() | ||
18 | |||
19 | # Use sdl_sources to add sources to SDL3-shared, to SDL3-static, or to both. | ||
20 | function(sdl_sources) | ||
21 | cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN}) | ||
22 | if(TARGET SDL3-shared) | ||
23 | target_sources(SDL3-shared PRIVATE ${ARGS_SHARED} ${ARGS_UNPARSED_ARGUMENTS}) | ||
24 | endif() | ||
25 | if(TARGET SDL3-static) | ||
26 | target_sources(SDL3-static PRIVATE ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS}) | ||
27 | endif() | ||
28 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${ARGS_SHARED} ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS}) | ||
29 | endfunction() | ||
30 | |||
31 | # Use sdl_generic_link_dependency to describe a private dependency. All options are optional. | ||
32 | # Users should use sdl_link_dependency and sdl_test_link_dependency instead | ||
33 | # - SHARED_TARGETS: shared targets to add this dependency to | ||
34 | # - STATIC_TARGETS: static targets to add this dependency to | ||
35 | # - COLLECTOR: target that stores information, for pc and Config.cmake generation. | ||
36 | # - INCLUDES: the include directories of the dependency | ||
37 | # - PKG_CONFIG_PREFIX: name of the prefix, when using the functions of FindPkgConfig | ||
38 | # - PKG_CONFIG_SPECS: pkg-config spec, used as argument for the functions of FindPkgConfig | ||
39 | # - PKG_CONFIG_LIBS: libs that will only end up in the Libs.private of the .pc file | ||
40 | # - PKG_CONFIG_LINK_OPTIONS: ldflags that will only end up in the Libs.private of sdl3.pc | ||
41 | # - CMAKE_MODULE: CMake module name of the dependency, used as argument of find_package | ||
42 | # - LIBS: list of libraries to link to (cmake and pkg-config) | ||
43 | # - LINK_OPTIONS: list of link options (also used in pc file, unless PKG_CONFIG_LINK_OPTION is used) | ||
44 | function(sdl_generic_link_dependency ID) | ||
45 | 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}) | ||
46 | foreach(target IN LISTS ARGS_SHARED_TARGETS) | ||
47 | if(TARGET ${target}) | ||
48 | target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES}) | ||
49 | target_link_libraries(${target} PRIVATE ${ARGS_LIBS}) | ||
50 | target_link_options(${target} PRIVATE ${ARGS_LINK_OPTIONS}) | ||
51 | endif() | ||
52 | endforeach() | ||
53 | foreach(target IN LISTS ARGS_STATIC_TARGETS) | ||
54 | if(TARGET ${target}) | ||
55 | target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES}) | ||
56 | target_link_libraries(${target} PRIVATE ${ARGS_LIBS}) | ||
57 | target_link_options(${target} INTERFACE ${ARGS_LINK_OPTIONS}) | ||
58 | endif() | ||
59 | endforeach() | ||
60 | get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
61 | if(NOT ID IN_LIST ids) | ||
62 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_IDS ${ID}) | ||
63 | endif() | ||
64 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX ${ARGS_PKG_CONFIG_PREFIX}) | ||
65 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS ${ARGS_PKG_CONFIG_SPECS}) | ||
66 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS ${ARGS_PKG_CONFIG_LIBS}) | ||
67 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS ${ARGS_PKG_CONFIG_LINK_OPTIONS}) | ||
68 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS ${ARGS_LIBS}) | ||
69 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS ${ARGS_LINK_OPTIONS}) | ||
70 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE ${ARGS_CMAKE_MODULE}) | ||
71 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES ${ARGS_INCLUDES}) | ||
72 | endfunction() | ||
73 | |||
74 | function(sdl_link_dependency ) | ||
75 | sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3-collector SHARED_TARGETS SDL3-shared STATIC_TARGETS SDL3-static) | ||
76 | endfunction() | ||
77 | |||
78 | function(sdl_test_link_dependency ) | ||
79 | sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3_test-collector STATIC_TARGETS SDL3_test) | ||
80 | endfunction() | ||
81 | |||
82 | macro(_get_ARGS_visibility) | ||
83 | set(_conflict FALSE) | ||
84 | set(visibility) | ||
85 | if(ARGS_PRIVATE) | ||
86 | set(visibility PRIVATE) | ||
87 | elseif(ARGS_PUBLIC) | ||
88 | if(visibility) | ||
89 | set(_conflict TRUE) | ||
90 | endif() | ||
91 | set(visibility PUBLIC) | ||
92 | elseif(ARGS_INTERFACE) | ||
93 | if(visibility) | ||
94 | set(_conflict TRUE) | ||
95 | endif() | ||
96 | set(visibility INTERFACE) | ||
97 | endif() | ||
98 | if(_conflict OR NOT visibility) | ||
99 | message(FATAL_ERROR "PRIVATE/PUBLIC/INTERFACE must be used exactly once") | ||
100 | endif() | ||
101 | unset(_conflict) | ||
102 | endmacro() | ||
103 | |||
104 | # Use sdl_link_dependency to add compile definitions to the SDL3 libraries. | ||
105 | function(sdl_compile_definitions) | ||
106 | cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
107 | _get_ARGS_visibility() | ||
108 | if(TARGET SDL3-shared) | ||
109 | target_compile_definitions(SDL3-shared ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
110 | endif() | ||
111 | if(TARGET SDL3-static) | ||
112 | target_compile_definitions(SDL3-static ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
113 | endif() | ||
114 | if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
115 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "${ARGS_UNPARSED_ARGUMENTS}") | ||
116 | endif() | ||
117 | endfunction() | ||
118 | |||
119 | # Use sdl_link_dependency to add compile options to the SDL3 libraries. | ||
120 | function(sdl_compile_options) | ||
121 | cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
122 | _get_ARGS_visibility() | ||
123 | set(escaped_opts ${ARGS_UNPARSED_ARGUMENTS}) | ||
124 | if(ARGS_NO_EXPORT) | ||
125 | set(escaped_opts "$<BUILD_INTERFACE:${ARGS_UNPARSED_ARGUMENTS}>") | ||
126 | endif() | ||
127 | if(TARGET SDL3-shared) | ||
128 | target_compile_options(SDL3-shared ${visibility} ${escaped_opts}) | ||
129 | endif() | ||
130 | if(TARGET SDL3-static) | ||
131 | target_compile_options(SDL3-static ${visibility} ${escaped_opts}) | ||
132 | endif() | ||
133 | if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
134 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}") | ||
135 | endif() | ||
136 | endfunction() | ||
137 | |||
138 | # Use sdl_link_dependency to add include directories to the SDL3 libraries. | ||
139 | function(sdl_include_directories) | ||
140 | cmake_parse_arguments(ARGS "SYSTEM;BEFORE;AFTER;PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
141 | set(system "") | ||
142 | if(ARGS_SYSTEM) | ||
143 | set(system "SYSTEM") | ||
144 | endif() | ||
145 | set(before_after ) | ||
146 | if(ARGS_AFTER) | ||
147 | set(before_after "AFTER") | ||
148 | endif() | ||
149 | if(ARGS_BEFORE) | ||
150 | if(before_after) | ||
151 | message(FATAL_ERROR "before and after are exclusive options") | ||
152 | endif() | ||
153 | set(before_after "BEFORE") | ||
154 | endif() | ||
155 | _get_ARGS_visibility() | ||
156 | if(TARGET SDL3-shared) | ||
157 | target_include_directories(SDL3-shared ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
158 | endif() | ||
159 | if(TARGET SDL3-static) | ||
160 | target_include_directories(SDL3-static ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
161 | endif() | ||
162 | if(NOT NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
163 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ARGS_UNPARSED_ARGUMENTS}") | ||
164 | endif() | ||
165 | endfunction() | ||
166 | |||
167 | # Use sdl_link_dependency to add link directories to the SDL3 libraries. | ||
168 | function(sdl_link_directories) | ||
169 | if(TARGET SDL3-shared) | ||
170 | target_link_directories(SDL3-shared PRIVATE ${ARGN}) | ||
171 | endif() | ||
172 | if(TARGET SDL3-static) | ||
173 | target_link_directories(SDL3-static INTERFACE ${ARGN}) | ||
174 | endif() | ||
175 | endfunction() | ||
176 | |||
177 | # Use sdl_pc_link_options to add a link option, only visible in sdl3.pc | ||
178 | function(sdl_pc_link_options) | ||
179 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS "${ARGN}") | ||
180 | endfunction() | ||
181 | |||
182 | # Use sdl_pc_link_options to add a link option only to SDL3-shared | ||
183 | function(sdl_shared_link_options) | ||
184 | if(TARGET SDL3-shared) | ||
185 | target_link_options(SDL3-shared PRIVATE ${ARGN}) | ||
186 | endif() | ||
187 | endfunction() | ||
188 | |||
189 | # Return minimum list of custom SDL CMake modules, used for finding dependencies of SDL. | ||
190 | function(sdl_cmake_config_required_modules OUTPUT) | ||
191 | set(cmake_modules) | ||
192 | foreach(collector SDL3-collector SDL3_test-collector) | ||
193 | get_property(ids TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
194 | foreach(ID IN LISTS ids) | ||
195 | get_property(CMAKE_MODULE TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
196 | if(CMAKE_MODULE) | ||
197 | if(EXISTS "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake") | ||
198 | list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake") | ||
199 | endif() | ||
200 | endif() | ||
201 | endforeach() | ||
202 | if(cmake_modules) | ||
203 | list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/PkgConfigHelper.cmake") | ||
204 | endif() | ||
205 | endforeach() | ||
206 | set(${OUTPUT} "${cmake_modules}" PARENT_SCOPE) | ||
207 | endfunction() | ||
208 | |||
209 | # Generate string for SDL3Config.cmake, finding all pkg-config dependencies of SDL3. | ||
210 | function(sdl_cmake_config_find_pkg_config_commands OUTPUT) | ||
211 | cmake_parse_arguments(ARGS "" "COLLECTOR;CONFIG_COMPONENT_FOUND_NAME" "" ${ARGN}) | ||
212 | if(NOT ARGS_COLLECTOR OR NOT ARGS_CONFIG_COMPONENT_FOUND_NAME) | ||
213 | message(FATAL_ERROR "COLLECTOR AND CONFIG_COMPONENT_FOUND_NAME are required arguments") | ||
214 | endif() | ||
215 | get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
216 | |||
217 | set(static_pkgconfig_deps_checks) | ||
218 | set(static_module_deps_checks) | ||
219 | set(cmake_modules_seen) | ||
220 | |||
221 | foreach(ID IN LISTS ids) | ||
222 | get_property(PKG_CONFIG_PREFIX TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX) | ||
223 | get_property(PKG_CONFIG_SPECS TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
224 | get_property(CMAKE_MODULE TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
225 | if(CMAKE_MODULE AND NOT CMAKE_MODULE IN_LIST cmake_modules_seen) | ||
226 | list(APPEND static_module_deps_checks | ||
227 | "find_package(${CMAKE_MODULE})" | ||
228 | "if(NOT ${CMAKE_MODULE}_FOUND)" | ||
229 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
230 | "endif()" | ||
231 | ) | ||
232 | list(APPEND cmake_modules_seen ${CMAKE_MODULE}) | ||
233 | endif() | ||
234 | if(PKG_CONFIG_PREFIX AND PKG_CONFIG_SPECS) | ||
235 | string(JOIN " " pkg_config_specs_str ${PKG_CONFIG_SPECS}) | ||
236 | list(APPEND static_pkgconfig_deps_checks | ||
237 | " pkg_check_modules(${PKG_CONFIG_PREFIX} QUIET IMPORTED_TARGET ${pkg_config_specs_str})" | ||
238 | " if(NOT ${PKG_CONFIG_PREFIX}_FOUND)" | ||
239 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
240 | " endif()" | ||
241 | ) | ||
242 | endif() | ||
243 | endforeach() | ||
244 | |||
245 | set(prefix " ") | ||
246 | |||
247 | set(static_module_deps_texts) | ||
248 | if(static_module_deps_checks) | ||
249 | set(static_module_deps_texts | ||
250 | [[set(_original_module_path "${CMAKE_MODULE_PATH}")]] | ||
251 | [[list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")]] | ||
252 | ${static_module_deps_checks} | ||
253 | [[set(CMAKE_MODULE_PATH "${_original_module_path}")]] | ||
254 | [[unset(_original_module_path)]] | ||
255 | ) | ||
256 | endif() | ||
257 | |||
258 | set(static_pkgconfig_deps_texts) | ||
259 | if(static_pkgconfig_deps_checks) | ||
260 | string(JOIN "\n${prefix}" static_deps_texts_str ${static_deps_texts}) | ||
261 | list(APPEND static_pkgconfig_deps_texts | ||
262 | "find_package(PkgConfig)" | ||
263 | "if(PkgConfig_FOUND)" | ||
264 | ${static_pkgconfig_deps_checks} | ||
265 | "else()" | ||
266 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
267 | "endif()" | ||
268 | ) | ||
269 | endif() | ||
270 | |||
271 | set(text) | ||
272 | string(JOIN "\n${prefix}" text ${static_module_deps_texts} ${static_pkgconfig_deps_texts}) | ||
273 | if(text) | ||
274 | set(text "${prefix}${text}") | ||
275 | endif() | ||
276 | |||
277 | set(${OUTPUT} "${text}" PARENT_SCOPE) | ||
278 | endfunction() | ||
279 | |||
280 | # Create sdl3.pc. | ||
281 | function(configure_sdl3_pc) | ||
282 | # Clean up variables for sdl3.pc | ||
283 | if(TARGET SDL3-shared) | ||
284 | set(SDL_PC_SECTION_LIBS_PRIVATE "\nLibs.private:") | ||
285 | else() | ||
286 | set(SDL_PC_SECTION_LIBS_PRIVATE "") | ||
287 | endif() | ||
288 | |||
289 | get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS) | ||
290 | |||
291 | set(private_requires) | ||
292 | set(private_libs) | ||
293 | set(private_ldflags) | ||
294 | |||
295 | foreach(ID IN LISTS ids) | ||
296 | get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
297 | get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
298 | get_property(PKG_CONFIG_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS) | ||
299 | get_property(PKG_CONFIG_LDFLAGS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS) | ||
300 | get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS) | ||
301 | get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS) | ||
302 | |||
303 | list(APPEND private_requires ${PKG_CONFIG_SPECS}) | ||
304 | list(APPEND private_libs ${PKG_CONFIG_LIBS}) | ||
305 | if(PKG_CONFIG_SPECS OR PKG_CONFIG_LIBS OR PKG_CONFIG_LDFLAGS) | ||
306 | list(APPEND private_ldflags ${PKG_CONFIG_LDFLAGS}) | ||
307 | else() | ||
308 | list(APPEND private_ldflags ${LINK_OPTIONS}) | ||
309 | if(NOT CMAKE_MODULE) | ||
310 | list(APPEND private_libs ${LIBS}) | ||
311 | endif() | ||
312 | endif() | ||
313 | endforeach() | ||
314 | |||
315 | list(TRANSFORM private_libs PREPEND "-l") | ||
316 | set(SDL_PC_STATIC_LIBS ${private_ldflags} ${private_libs}) | ||
317 | list(REMOVE_DUPLICATES SDL_PC_STATIC_LIBS) | ||
318 | string(JOIN " " SDL_PC_STATIC_LIBS ${SDL_PC_STATIC_LIBS}) | ||
319 | |||
320 | string(JOIN " " SDL_PC_PRIVATE_REQUIRES ${private_requires}) | ||
321 | string(REGEX REPLACE "(>=|>|=|<|<=)" [[ \1 ]] SDL_PC_PRIVATE_REQUIRES "${SDL_PC_PRIVATE_REQUIRES}") | ||
322 | |||
323 | get_property(interface_defines TARGET SDL3-collector PROPERTY INTERFACE_COMPILE_DEFINITIONS) | ||
324 | list(TRANSFORM interface_defines PREPEND "-D") | ||
325 | get_property(interface_includes TARGET SDL3-collector PROPERTY INTERFACE_INCLUDE_DIRECTORIES) | ||
326 | list(TRANSFORM interface_includes PREPEND "-I") | ||
327 | set(SDL_PC_CFLAGS ${interface_defines} ${interface_includes}) | ||
328 | string(JOIN " " SDL_PC_CFLAGS ${SDL_PC_CFLAGS}) | ||
329 | |||
330 | get_property(SDL_PC_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS) | ||
331 | string(JOIN " " SDL_PC_LIBS ${SDL_PC_LIBS}) | ||
332 | |||
333 | string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_STATIC_LIBS "${SDL_PC_STATIC_LIBS}") | ||
334 | if(NOT SDL_SHARED) | ||
335 | string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_LIBS "${SDL_PC_LIBS}") | ||
336 | endif() | ||
337 | if(TARGET SDL3-shared AND TARGET SDL3-static AND NOT sdl_static_libname STREQUAL "SDL3") | ||
338 | message(STATUS "\"pkg-config --static --libs sdl3\" will return invalid information") | ||
339 | endif() | ||
340 | |||
341 | if(SDL_RELOCATABLE) | ||
342 | # Calculate prefix relative to location of sdl3.pc | ||
343 | if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") | ||
344 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") | ||
345 | endif() | ||
346 | file(RELATIVE_PATH SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${CMAKE_INSTALL_PREFIX}/${SDL_PKGCONFIG_INSTALLDIR}" "${CMAKE_INSTALL_PREFIX}") | ||
347 | string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") | ||
348 | set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") | ||
349 | else() | ||
350 | set(SDL_PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") | ||
351 | endif() | ||
352 | |||
353 | if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") | ||
354 | set(INCLUDEDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_INCLUDEDIR}") | ||
355 | else() | ||
356 | set(INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") | ||
357 | endif() | ||
358 | if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") | ||
359 | set(LIBDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_LIBDIR}") | ||
360 | else() | ||
361 | set(LIBDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_LIBDIR}") | ||
362 | endif() | ||
363 | |||
364 | configure_file("${SDL3_SOURCE_DIR}/cmake/sdl3.pc.in" "${SDL3_BINARY_DIR}/sdl3.pc" @ONLY) | ||
365 | endfunction() | ||
366 | |||
367 | # Write list of dependencies to output. Only visible when configuring with --log-level=DEBUG. | ||
368 | function(debug_show_sdl_deps) | ||
369 | get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS) | ||
370 | |||
371 | foreach(ID IN LISTS ids) | ||
372 | message(DEBUG "- id: ${ID}") | ||
373 | get_property(INCLUDES TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES) | ||
374 | get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
375 | get_property(PKG_CONFIG_PREFIX TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX) | ||
376 | get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
377 | get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS) | ||
378 | get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS) | ||
379 | message(DEBUG " INCLUDES: ${INCLUDES}") | ||
380 | message(DEBUG " CMAKE_MODULE: ${CMAKE_MODULE}") | ||
381 | message(DEBUG " PKG_CONFIG_PREFIX: ${PKG_CONFIG_PREFIX}") | ||
382 | message(DEBUG " PKG_CONFIG_SPECS: ${PKG_CONFIG_SPECS}") | ||
383 | message(DEBUG " LIBS: ${LIBS}") | ||
384 | message(DEBUG " LINK_OPTIONS: ${LINK_OPTIONS}") | ||
385 | endforeach() | ||
386 | endfunction() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/CMakeLists.txt b/src/contrib/SDL-3.2.20/cmake/test/CMakeLists.txt new file mode 100644 index 0000000..e3766f0 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/CMakeLists.txt | |||
@@ -0,0 +1,135 @@ | |||
1 | # This cmake build script is meant for verifying the various CMake configuration scripts. | ||
2 | |||
3 | cmake_minimum_required(VERSION 3.12) | ||
4 | project(SDL_cmake_selftest LANGUAGES C) | ||
5 | |||
6 | include(CheckLanguage) | ||
7 | |||
8 | # FIXME: how to target ios/tvos with Swift? | ||
9 | # https://gitlab.kitware.com/cmake/cmake/-/issues/20104 | ||
10 | if(APPLE AND CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*") | ||
11 | # multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift | ||
12 | list(LENGTH CMAKE_OSX_ARCHITECTURES count_osx_archs) | ||
13 | if(count_osx_archs LESS_EQUAL 1) | ||
14 | check_language(Swift) | ||
15 | if(CMAKE_Swift_COMPILER) | ||
16 | enable_language(Swift) | ||
17 | endif() | ||
18 | endif() | ||
19 | endif() | ||
20 | |||
21 | message(STATUS "CMAKE_SYSTEM_NAME= ${CMAKE_SYSTEM_NAME}") | ||
22 | message(STATUS "CMAKE_SYSTEM_PROCESSOR= ${CMAKE_SYSTEM_PROCESSOR}") | ||
23 | |||
24 | include(GenerateExportHeader) | ||
25 | |||
26 | if(ANDROID) | ||
27 | macro(add_executable NAME) | ||
28 | set(args ${ARGN}) | ||
29 | list(REMOVE_ITEM args WIN32) | ||
30 | add_library(${NAME} SHARED ${args}) | ||
31 | unset(args) | ||
32 | endmacro() | ||
33 | endif() | ||
34 | |||
35 | cmake_policy(SET CMP0074 NEW) | ||
36 | |||
37 | # Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL3 outside of sysroot | ||
38 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) | ||
39 | |||
40 | include(FeatureSummary) | ||
41 | |||
42 | option(TEST_SHARED "Test linking to shared SDL3 library" ON) | ||
43 | add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library") | ||
44 | |||
45 | option(TEST_STATIC "Test linking to static SDL3 library" ON) | ||
46 | add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") | ||
47 | |||
48 | option(TEST_TEST "Test linking to SDL3_test library" ON) | ||
49 | add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library") | ||
50 | |||
51 | option(TEST_FULL "Run complete SDL test suite" OFF) | ||
52 | add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite") | ||
53 | |||
54 | find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers) | ||
55 | add_library(headers_test_slash OBJECT inc_sdl_slash.c) | ||
56 | target_link_libraries(headers_test_slash PRIVATE SDL3::Headers) | ||
57 | |||
58 | if(TEST_SHARED) | ||
59 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared) | ||
60 | add_executable(gui-shared WIN32 main_gui.c) | ||
61 | target_link_libraries(gui-shared PRIVATE SDL3::SDL3-shared) | ||
62 | if(WIN32) | ||
63 | add_custom_command(TARGET gui-shared POST_BUILD | ||
64 | COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3-shared>" "$<TARGET_FILE_DIR:gui-shared>" | ||
65 | ) | ||
66 | endif() | ||
67 | |||
68 | add_library(sharedlib-shared SHARED main_lib.c) | ||
69 | target_link_libraries(sharedlib-shared PRIVATE SDL3::SDL3-shared) | ||
70 | generate_export_header(sharedlib-shared EXPORT_MACRO_NAME MYLIBRARY_EXPORT) | ||
71 | target_compile_definitions(sharedlib-shared PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared_export.h\"") | ||
72 | set_target_properties(sharedlib-shared PROPERTIES C_VISIBILITY_PRESET "hidden") | ||
73 | |||
74 | add_executable(cli-shared main_cli.c) | ||
75 | target_link_libraries(cli-shared PRIVATE SDL3::SDL3-shared) | ||
76 | if(WIN32) | ||
77 | add_custom_command(TARGET cli-shared POST_BUILD | ||
78 | COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3-shared>" "$<TARGET_FILE_DIR:cli-shared>" | ||
79 | ) | ||
80 | endif() | ||
81 | |||
82 | if(TEST_TEST) | ||
83 | add_executable(sdltest-shared sdltest.c) | ||
84 | target_link_libraries(sdltest-shared PRIVATE SDL3::SDL3_test SDL3::SDL3-shared) | ||
85 | endif() | ||
86 | |||
87 | if(CMAKE_Swift_COMPILER) | ||
88 | add_executable(swift-shared main.swift) | ||
89 | target_include_directories(swift-shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift") | ||
90 | target_link_libraries(swift-shared PRIVATE SDL3::SDL3-shared) | ||
91 | endif() | ||
92 | endif() | ||
93 | |||
94 | if(TEST_STATIC) | ||
95 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-static) | ||
96 | add_executable(gui-static WIN32 main_gui.c) | ||
97 | target_link_libraries(gui-static PRIVATE SDL3::SDL3-static) | ||
98 | |||
99 | # Assume SDL library has been built with `set(CMAKE_POSITION_INDEPENDENT_CODE ON)` | ||
100 | add_library(sharedlib-static SHARED main_lib.c) | ||
101 | target_link_libraries(sharedlib-static PRIVATE SDL3::SDL3-static) | ||
102 | generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT) | ||
103 | target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"") | ||
104 | set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden") | ||
105 | |||
106 | if(TEST_TEST) | ||
107 | add_executable(sdltest-static sdltest.c) | ||
108 | target_link_libraries(sdltest-static PRIVATE SDL3::SDL3_test SDL3::SDL3-static) | ||
109 | endif() | ||
110 | |||
111 | if(CMAKE_Swift_COMPILER) | ||
112 | add_executable(swift-static main.swift) | ||
113 | target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift") | ||
114 | target_link_libraries(swift-static PRIVATE SDL3::SDL3-static) | ||
115 | endif() | ||
116 | endif() | ||
117 | |||
118 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3) | ||
119 | add_executable(gui-whatever WIN32 main_gui.c) | ||
120 | target_link_libraries(gui-whatever PRIVATE SDL3::SDL3) | ||
121 | |||
122 | if(TEST_FULL) | ||
123 | enable_testing() | ||
124 | set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Test timeout multiplier") | ||
125 | set(SDL_TESTS_LINK_SHARED ${TEST_SHARED}) | ||
126 | |||
127 | add_definitions(-DNO_BUILD_CONFIG) | ||
128 | add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../test" SDL_test) | ||
129 | endif() | ||
130 | |||
131 | if(ANDROID) | ||
132 | find_package(SDL3 REQUIRED CONFIG COMPONENTS Jar) | ||
133 | endif() | ||
134 | |||
135 | feature_summary(WHAT ALL) | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/inc_sdl_slash.c b/src/contrib/SDL-3.2.20/cmake/test/inc_sdl_slash.c new file mode 100644 index 0000000..7acca15 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/inc_sdl_slash.c | |||
@@ -0,0 +1,8 @@ | |||
1 | #include "SDL3/SDL.h" | ||
2 | #include "SDL3/SDL_main.h" | ||
3 | |||
4 | void inc_sdl_slash(void) { | ||
5 | SDL_SetMainReady(); | ||
6 | SDL_Init(0); | ||
7 | SDL_Quit(); | ||
8 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/main.swift b/src/contrib/SDL-3.2.20/cmake/test/main.swift new file mode 100644 index 0000000..1943f7c --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/main.swift | |||
@@ -0,0 +1,13 @@ | |||
1 | /* Contributed by Piotr Usewicz (https://github.com/pusewicz) */ | ||
2 | |||
3 | import SDL3 | ||
4 | |||
5 | guard SDL_Init(SDL_INIT_VIDEO) else { | ||
6 | fatalError("SDL_Init error: \(String(cString: SDL_GetError()))") | ||
7 | } | ||
8 | |||
9 | var sdlVersion = SDL_GetVersion() | ||
10 | |||
11 | print("SDL version: \(sdlVersion)") | ||
12 | |||
13 | SDL_Quit() | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/main_cli.c b/src/contrib/SDL-3.2.20/cmake/test/main_cli.c new file mode 100644 index 0000000..39c5ce2 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/main_cli.c | |||
@@ -0,0 +1,15 @@ | |||
1 | #define SDL_MAIN_HANDLED | ||
2 | #include <SDL3/SDL.h> | ||
3 | #include <SDL3/SDL_main.h> | ||
4 | |||
5 | int main(int argc, char *argv[]) | ||
6 | { | ||
7 | SDL_SetMainReady(); | ||
8 | if (!SDL_Init(0)) { | ||
9 | SDL_Log("Could not initialize SDL: %s", SDL_GetError()); | ||
10 | return 1; | ||
11 | } | ||
12 | SDL_Delay(100); | ||
13 | SDL_Quit(); | ||
14 | return 0; | ||
15 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/main_gui.c b/src/contrib/SDL-3.2.20/cmake/test/main_gui.c new file mode 100644 index 0000000..18ed101 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/main_gui.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include <SDL3/SDL.h> | ||
2 | #include <SDL3/SDL_main.h> | ||
3 | |||
4 | int main(int argc, char *argv[]) | ||
5 | { | ||
6 | SDL_Window *window = NULL; | ||
7 | SDL_Surface *screenSurface = NULL; | ||
8 | if (!SDL_Init(SDL_INIT_VIDEO)) { | ||
9 | SDL_Log("Could not initialize SDL: %s", SDL_GetError()); | ||
10 | return 1; | ||
11 | } | ||
12 | window = SDL_CreateWindow("Hello SDL", 640, 480, 0); | ||
13 | if (!window) { | ||
14 | SDL_Log("could not create window: %s", SDL_GetError()); | ||
15 | return 1; | ||
16 | } | ||
17 | screenSurface = SDL_GetWindowSurface(window); | ||
18 | SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff)); | ||
19 | SDL_UpdateWindowSurface(window); | ||
20 | SDL_Delay(100); | ||
21 | SDL_DestroyWindow(window); | ||
22 | SDL_Quit(); | ||
23 | return 0; | ||
24 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/main_lib.c b/src/contrib/SDL-3.2.20/cmake/test/main_lib.c new file mode 100644 index 0000000..6aec1f6 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/main_lib.c | |||
@@ -0,0 +1,34 @@ | |||
1 | #include <SDL3/SDL.h> | ||
2 | #define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */ | ||
3 | #include <SDL3/SDL_main.h> | ||
4 | |||
5 | #include EXPORT_HEADER | ||
6 | |||
7 | #ifdef _WIN32 | ||
8 | #include <windows.h> | ||
9 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { | ||
10 | return TRUE; | ||
11 | } | ||
12 | #endif | ||
13 | |||
14 | int MYLIBRARY_EXPORT mylibrary_init(void); | ||
15 | void MYLIBRARY_EXPORT mylibrary_quit(void); | ||
16 | int MYLIBRARY_EXPORT mylibrary_work(void); | ||
17 | |||
18 | int mylibrary_init(void) { | ||
19 | SDL_SetMainReady(); | ||
20 | if (!SDL_Init(0)) { | ||
21 | SDL_Log("Could not initialize SDL: %s", SDL_GetError()); | ||
22 | return 1; | ||
23 | } | ||
24 | return 0; | ||
25 | } | ||
26 | |||
27 | void mylibrary_quit(void) { | ||
28 | SDL_Quit(); | ||
29 | } | ||
30 | |||
31 | int mylibrary_work(void) { | ||
32 | SDL_Delay(100); | ||
33 | return 0; | ||
34 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/sdltest.c b/src/contrib/SDL-3.2.20/cmake/test/sdltest.c new file mode 100644 index 0000000..f598a98 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/sdltest.c | |||
@@ -0,0 +1,9 @@ | |||
1 | #include <SDL3/SDL.h> | ||
2 | #include <SDL3/SDL_test.h> | ||
3 | |||
4 | |||
5 | int main(int argc, char *argv[]) { | ||
6 | SDLTest_CommonState state; | ||
7 | SDLTest_CommonDefaultArgs(&state, argc, argv); | ||
8 | return 0; | ||
9 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/swift/module.modulemap b/src/contrib/SDL-3.2.20/cmake/test/swift/module.modulemap new file mode 100644 index 0000000..bbc26a9 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/swift/module.modulemap | |||
@@ -0,0 +1,4 @@ | |||
1 | module SDL3 [extern_c] { | ||
2 | header "shim.h" | ||
3 | export * | ||
4 | } | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/swift/shim.h b/src/contrib/SDL-3.2.20/cmake/test/swift/shim.h new file mode 100644 index 0000000..dba8c6f --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/swift/shim.h | |||
@@ -0,0 +1,3 @@ | |||
1 | /* Contributed by Piotr Usewicz (https://github.com/pusewicz) */ | ||
2 | |||
3 | #include <SDL3/SDL.h> | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/test/test_pkgconfig.sh b/src/contrib/SDL-3.2.20/cmake/test/test_pkgconfig.sh new file mode 100755 index 0000000..5bb84df --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/test/test_pkgconfig.sh | |||
@@ -0,0 +1,51 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if test "x$CC" = "x"; then | ||
4 | CC=cc | ||
5 | fi | ||
6 | |||
7 | machine="$($CC -dumpmachine)" | ||
8 | case "$machine" in | ||
9 | *mingw* ) | ||
10 | EXEPREFIX="" | ||
11 | EXESUFFIX=".exe" | ||
12 | ;; | ||
13 | *android* ) | ||
14 | EXEPREFIX="lib" | ||
15 | EXESUFFIX=".so" | ||
16 | LDFLAGS="$EXTRA_LDFLAGS -shared" | ||
17 | ;; | ||
18 | * ) | ||
19 | EXEPREFIX="" | ||
20 | EXESUFFIX="" | ||
21 | ;; | ||
22 | esac | ||
23 | |||
24 | set -e | ||
25 | |||
26 | # Get the canonical path of the folder containing this script | ||
27 | testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)") | ||
28 | SDL_CFLAGS="$( pkg-config sdl3 --cflags )" | ||
29 | SDL_LDFLAGS="$( pkg-config sdl3 --libs )" | ||
30 | SDL_STATIC_LDFLAGS="$( pkg-config sdl3 --libs --static )" | ||
31 | |||
32 | compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $SDL_CFLAGS $CFLAGS" | ||
33 | link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS" | ||
34 | static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS" | ||
35 | |||
36 | echo "-- CC: $CC" | ||
37 | echo "-- CFLAGS: $CFLAGS" | ||
38 | echo "-- LDFLASG: $LDFLAGS" | ||
39 | echo "-- SDL_CFLAGS: $SDL_CFLAGS" | ||
40 | echo "-- SDL_LDFLAGS: $SDL_LDFLAGS" | ||
41 | echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS" | ||
42 | |||
43 | echo "-- COMPILE: $compile_cmd" | ||
44 | echo "-- LINK: $link_cmd" | ||
45 | echo "-- STATIC_LINK: $static_link_cmd" | ||
46 | |||
47 | set -x | ||
48 | |||
49 | $compile_cmd | ||
50 | $link_cmd | ||
51 | $static_link_cmd | ||
diff --git a/src/contrib/SDL-3.2.20/cmake/xxd.py b/src/contrib/SDL-3.2.20/cmake/xxd.py new file mode 100755 index 0000000..678946a --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/xxd.py | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | import argparse | ||
4 | import os | ||
5 | import pathlib | ||
6 | import re | ||
7 | |||
8 | def main(): | ||
9 | parser = argparse.ArgumentParser(allow_abbrev=False, description="Convert file into includable C header") | ||
10 | parser.add_argument("--in", "-i", type=pathlib.Path, metavar="INPUT", dest="input", required=True, help="Input file") | ||
11 | parser.add_argument("--out", "-o", type=pathlib.Path, metavar="OUTPUT", dest="output", required=True, help="Output header") | ||
12 | parser.add_argument("--columns", type=int, default=12, help="Column count") | ||
13 | args = parser.parse_args() | ||
14 | |||
15 | t = pathlib.Path() | ||
16 | varname, _ = re.subn("[^a-zA-Z0-9]", "_", str(args.input.name)) | ||
17 | |||
18 | binary_data = args.input.open("rb").read() | ||
19 | |||
20 | with args.output.open("w", newline="\n") as fout: | ||
21 | fout.write("unsigned char {}[] = {{\n".format(varname)) | ||
22 | bytes_written = 0 | ||
23 | while bytes_written < len(binary_data): | ||
24 | col = bytes_written % args.columns | ||
25 | if col == 0: | ||
26 | fout.write(" ") | ||
27 | column_data = binary_data[bytes_written:bytes_written+args.columns] | ||
28 | fout.write(", ".join("0x{:02x}".format(d) for d in column_data)) | ||
29 | bytes_written += len(column_data) | ||
30 | if bytes_written < len(binary_data): | ||
31 | fout.write(",\n") | ||
32 | else: | ||
33 | fout.write("\n") | ||
34 | fout.write("}};\nunsigned int {}_len = {:d};\n".format(varname, len(binary_data))) | ||
35 | |||
36 | if __name__ == "__main__": | ||
37 | raise SystemExit(main()) | ||