diff options
Diffstat (limited to 'src/contrib/SDL-2.30.2/cmake')
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake | 42 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/macros.cmake | 148 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/sdlchecks.cmake | 1411 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/sdlfind.cmake | 9 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/sdlplatform.cmake | 59 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/test/CMakeLists.txt | 124 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/test/jni/Android.mk | 11 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/test/main_cli.c | 14 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/test/main_gui.c | 28 | ||||
-rw-r--r-- | src/contrib/SDL-2.30.2/cmake/test/main_lib.c | 33 | ||||
-rwxr-xr-x | src/contrib/SDL-2.30.2/cmake/test/test_pkgconfig.sh | 51 | ||||
-rwxr-xr-x | src/contrib/SDL-2.30.2/cmake/test/test_sdlconfig.sh | 51 |
12 files changed, 1981 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake b/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake new file mode 100644 index 0000000..7e3e459 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake | |||
@@ -0,0 +1,42 @@ | |||
1 | include(CheckCSourceCompiles) | ||
2 | include(CMakePushCheckState) | ||
3 | |||
4 | function(_internal_check_cpu_architecture macro_check NAME VARIABLE) | ||
5 | cmake_push_check_state(RESET) | ||
6 | string(TOUPPER "${NAME}" UPPER_NAME) | ||
7 | set(CACHE_VARIABLE "CHECK_CPU_ARCHITECTURE_${UPPER_NAME}") | ||
8 | set(test_src " | ||
9 | int main(int argc, char *argv[]) { | ||
10 | #if ${macro_check} | ||
11 | return 0; | ||
12 | #else | ||
13 | choke | ||
14 | #endif | ||
15 | } | ||
16 | ") | ||
17 | check_c_source_compiles("${test_src}" "${CACHE_VARIABLE}") | ||
18 | cmake_pop_check_state() | ||
19 | if(${CACHE_VARIABLE}) | ||
20 | set(${VARIABLE} "TRUE" PARENT_SCOPE) | ||
21 | else() | ||
22 | set(${VARIABLE} "FALSE" PARENT_SCOPE) | ||
23 | endif() | ||
24 | endfunction() | ||
25 | |||
26 | function(check_cpu_architecture ARCH VARIABLE) | ||
27 | if(ARCH STREQUAL "x86") | ||
28 | _internal_check_cpu_architecture("defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" x86 ${VARIABLE}) | ||
29 | elseif(ARCH STREQUAL "x64") | ||
30 | _internal_check_cpu_architecture("defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" x64 ${VARIABLE}) | ||
31 | elseif(ARCH STREQUAL "arm32") | ||
32 | _internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE}) | ||
33 | elseif(ARCH STREQUAL "arm64") | ||
34 | _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) | ||
35 | elseif(ARCH STREQUAL "loongarch64") | ||
36 | _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) | ||
37 | else() | ||
38 | message(WARNING "Unknown CPU architectures (${ARCH}).") | ||
39 | set(${VARIABLE} FALSE) | ||
40 | endif() | ||
41 | set("${VARIABLE}" "${${VARIABLE}}" PARENT_SCOPE) | ||
42 | endfunction() | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/macros.cmake b/src/contrib/SDL-2.30.2/cmake/macros.cmake new file mode 100644 index 0000000..5060923 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/macros.cmake | |||
@@ -0,0 +1,148 @@ | |||
1 | macro(ADD_TO_ALLOPTIONS _NEWNAME) | ||
2 | list(APPEND ALLOPTIONS ${_NEWNAME}) | ||
3 | string(LENGTH ${_NEWNAME} _SLEN) | ||
4 | if(${LONGESTOPTIONNAME} LESS ${_SLEN}) | ||
5 | set(LONGESTOPTIONNAME ${_SLEN}) | ||
6 | endif() | ||
7 | endmacro() | ||
8 | |||
9 | macro(SET_OPTION _NAME _DESC) | ||
10 | add_to_alloptions(${_NAME}) | ||
11 | if(${ARGC} EQUAL 3) | ||
12 | set(_DEFLT ${ARGV2}) | ||
13 | else() | ||
14 | set(_DEFLT OFF) | ||
15 | endif() | ||
16 | option(${_NAME} ${_DESC} ${_DEFLT}) | ||
17 | endmacro() | ||
18 | |||
19 | macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT) | ||
20 | add_to_alloptions("${_NAME}") | ||
21 | cmake_dependent_option("${_NAME}" "${_DESC}" "${_DEFLT}" "${_DEPTEST}" "${_FAILDFLT}") | ||
22 | endmacro() | ||
23 | |||
24 | macro(OPTION_STRING _NAME _DESC _VALUE) | ||
25 | add_to_alloptions(${_NAME}) | ||
26 | set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}") | ||
27 | set(HAVE_${_NAME} ${_VALUE}) | ||
28 | ENDMACRO() | ||
29 | |||
30 | # Message Output | ||
31 | macro(MESSAGE_WARN _TEXT) | ||
32 | message(WARNING "${_TEXT}") | ||
33 | endmacro() | ||
34 | |||
35 | macro(MESSAGE_ERROR _TEXT) | ||
36 | message(FATAL_ERROR "*** ERROR: ${_TEXT}") | ||
37 | endmacro() | ||
38 | |||
39 | macro(MESSAGE_BOOL_OPTION _NAME _VALUE) | ||
40 | if(${_VALUE}) | ||
41 | message(STATUS " ${_NAME}:\tON") | ||
42 | else() | ||
43 | message(STATUS " ${_NAME}:\tOFF") | ||
44 | endif() | ||
45 | endmacro() | ||
46 | |||
47 | macro(MESSAGE_TESTED_OPTION _NAME) | ||
48 | set(_REQVALUE ${${_NAME}}) | ||
49 | set(_PAD " ") | ||
50 | if(${ARGC} EQUAL 2) | ||
51 | set(_PAD ${ARGV1}) | ||
52 | endif() | ||
53 | string(SUBSTRING "${_NAME}" 0 4 _NAMESTART) | ||
54 | if(_NAMESTART STREQUAL "SDL_") | ||
55 | string(SUBSTRING "${_NAME}" 4 -1 _STRIPPEDNAME) | ||
56 | else() | ||
57 | set(_STRIPPEDNAME "${_NAME}") | ||
58 | endif() | ||
59 | if(NOT HAVE_${_STRIPPEDNAME}) | ||
60 | set(HAVE_${_STRIPPEDNAME} OFF) | ||
61 | elseif("${HAVE_${_STRIPPEDNAME}}" MATCHES "1|TRUE|YES|Y") | ||
62 | set(HAVE_${_STRIPPEDNAME} ON) | ||
63 | endif() | ||
64 | message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}") | ||
65 | endmacro() | ||
66 | |||
67 | function(LISTTOSTR _LIST _OUTPUT) | ||
68 | if(${ARGC} EQUAL 3) | ||
69 | # prefix for each element | ||
70 | set(_LPREFIX ${ARGV2}) | ||
71 | else() | ||
72 | set(_LPREFIX "") | ||
73 | endif() | ||
74 | # Do not use string(REPLACE ";" " ") here to avoid messing up list | ||
75 | # entries | ||
76 | set(res) | ||
77 | foreach(_ITEM ${${_LIST}}) | ||
78 | set(res "${res} ${_LPREFIX}${_ITEM}") | ||
79 | endforeach() | ||
80 | set(${_OUTPUT} "${res}" PARENT_SCOPE) | ||
81 | endfunction() | ||
82 | |||
83 | macro(LISTTOSTRREV _LIST _OUTPUT) | ||
84 | if(${ARGC} EQUAL 3) | ||
85 | # prefix for each element | ||
86 | set(_LPREFIX ${ARGV2}) | ||
87 | else() | ||
88 | set(_LPREFIX "") | ||
89 | endif() | ||
90 | # Do not use string(REPLACE ";" " ") here to avoid messing up list | ||
91 | # entries | ||
92 | foreach(_ITEM ${${_LIST}}) | ||
93 | set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}") | ||
94 | endforeach() | ||
95 | endmacro() | ||
96 | |||
97 | if(CMAKE_VERSION VERSION_LESS 3.16.0 OR SDL2_SUBPROJECT) | ||
98 | # - CMake versions <3.16 do not support the OBJC language | ||
99 | # - When SDL is built as a subproject and when the main project does not enable OBJC, | ||
100 | # CMake fails due to missing internal CMake variables (CMAKE_OBJC_COMPILE_OBJECT) | ||
101 | # (reproduced with CMake 3.24.2) | ||
102 | macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) | ||
103 | set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}") | ||
104 | set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}") | ||
105 | CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VAR}) | ||
106 | set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}") | ||
107 | endmacro() | ||
108 | else() | ||
109 | include(CheckOBJCSourceCompiles) | ||
110 | if (APPLE) | ||
111 | enable_language(OBJC) | ||
112 | endif() | ||
113 | endif() | ||
114 | |||
115 | if(APPLE) | ||
116 | check_language(OBJC) | ||
117 | if(NOT CMAKE_OBJC_COMPILER) | ||
118 | message(WARNING "Cannot find working OBJC compiler.") | ||
119 | endif() | ||
120 | endif() | ||
121 | |||
122 | if(CMAKE_VERSION VERSION_LESS 3.13.0) | ||
123 | macro(target_link_directories _TARGET _SCOPE) | ||
124 | link_directories(${ARGN}) | ||
125 | endmacro() | ||
126 | endif() | ||
127 | |||
128 | # CMP0087: install(CODE) and install(SCRIPT) support generator expressions. | ||
129 | if(POLICY CMP0087) | ||
130 | cmake_policy(SET CMP0087 NEW) | ||
131 | endif() | ||
132 | function(SDL_install_pdb TARGET DIRECTORY) | ||
133 | get_property(type TARGET ${TARGET} PROPERTY TYPE) | ||
134 | if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$") | ||
135 | if(NOT CMAKE_VERSION VERSION_LESS 3.1) | ||
136 | install(FILES $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL) | ||
137 | endif() | ||
138 | elseif(type STREQUAL "STATIC_LIBRARY") | ||
139 | if(NOT CMAKE_VERSION VERSION_LESS 3.15) | ||
140 | # FIXME: Use $<TARGET_COMPILE_PDB_FILE:${TARGET} once it becomes available (https://gitlab.kitware.com/cmake/cmake/-/issues/25244) | ||
141 | if(CMAKE_GENERATOR MATCHES "^Visual Studio.*") | ||
142 | install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${TARGET}.pdb\")") | ||
143 | else() | ||
144 | install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${TARGET}.pdb\")") | ||
145 | endif() | ||
146 | endif() | ||
147 | endif() | ||
148 | endfunction() | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/sdlchecks.cmake b/src/contrib/SDL-2.30.2/cmake/sdlchecks.cmake new file mode 100644 index 0000000..8156653 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/sdlchecks.cmake | |||
@@ -0,0 +1,1411 @@ | |||
1 | include(CMakeParseArguments) | ||
2 | include(${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake) | ||
3 | macro(FindLibraryAndSONAME _LIB) | ||
4 | cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN}) | ||
5 | |||
6 | string(TOUPPER ${_LIB} _UPPERLNAME) | ||
7 | string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}") | ||
8 | |||
9 | find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS}) | ||
10 | |||
11 | if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*") | ||
12 | set(${_LNAME}_SHARED TRUE) | ||
13 | else() | ||
14 | set(${_LNAME}_SHARED FALSE) | ||
15 | endif() | ||
16 | |||
17 | if(${_LNAME}_LIB) | ||
18 | # reduce the library name for shared linking | ||
19 | |||
20 | get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH) # resolves symlinks | ||
21 | get_filename_component(_LIB_DIRECTORY ${_LIB_REALPATH} DIRECTORY) | ||
22 | get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME) | ||
23 | |||
24 | if(APPLE) | ||
25 | string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}") | ||
26 | else() | ||
27 | string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}") | ||
28 | endif() | ||
29 | |||
30 | if(NOT EXISTS "${_LIB_DIRECTORY}/${_LIB_REGEXD}") | ||
31 | set(_LIB_REGEXD "${_LIB_JUSTNAME}") | ||
32 | endif() | ||
33 | set(${_LNAME}_LIBDIR "${_LIB_LIBDIR}") | ||
34 | |||
35 | SET(_DEBUG_FindSONAME FALSE) | ||
36 | if(_DEBUG_FindSONAME) | ||
37 | message_warn("DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB") | ||
38 | message_warn("DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}") | ||
39 | message_warn("DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}") | ||
40 | message_warn("DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}") | ||
41 | message_warn("DYNLIB REGEX'd LIB: ${_LIB} ... ${_LIB_REGEXD}") | ||
42 | endif() | ||
43 | |||
44 | message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}") | ||
45 | set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD}) | ||
46 | endif() | ||
47 | endmacro() | ||
48 | |||
49 | macro(CheckDLOPEN) | ||
50 | cmake_push_check_state(RESET) | ||
51 | check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC) | ||
52 | if(NOT HAVE_DLOPEN_IN_LIBC) | ||
53 | set(CMAKE_REQUIRED_LIBRARIES dl) | ||
54 | check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL) | ||
55 | if(HAVE_DLOPEN_IN_LIBDL) | ||
56 | list(APPEND EXTRA_LIBS dl) | ||
57 | endif() | ||
58 | endif() | ||
59 | if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL) | ||
60 | set(HAVE_DLOPEN TRUE) | ||
61 | endif() | ||
62 | cmake_pop_check_state() | ||
63 | endmacro() | ||
64 | |||
65 | macro(CheckO_CLOEXEC) | ||
66 | check_c_source_compiles(" | ||
67 | #include <fcntl.h> | ||
68 | int flag = O_CLOEXEC; | ||
69 | int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC) | ||
70 | endmacro() | ||
71 | |||
72 | # Requires: | ||
73 | # - n/a | ||
74 | macro(CheckOSS) | ||
75 | if(SDL_OSS) | ||
76 | check_c_source_compiles(" | ||
77 | #include <sys/soundcard.h> | ||
78 | int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" HAVE_OSS_SYS_SOUNDCARD_H) | ||
79 | |||
80 | if(HAVE_OSS_SYS_SOUNDCARD_H) | ||
81 | set(HAVE_OSS TRUE) | ||
82 | file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c) | ||
83 | set(SDL_AUDIO_DRIVER_OSS 1) | ||
84 | list(APPEND SOURCE_FILES ${OSS_SOURCES}) | ||
85 | if(NETBSD) | ||
86 | list(APPEND EXTRA_LIBS ossaudio) | ||
87 | endif() | ||
88 | set(HAVE_SDL_AUDIO TRUE) | ||
89 | endif() | ||
90 | endif() | ||
91 | endmacro() | ||
92 | |||
93 | # Requires: | ||
94 | # - n/a | ||
95 | # Optional: | ||
96 | # - SDL_ALSA_SHARED opt | ||
97 | # - HAVE_SDL_LOADSO opt | ||
98 | macro(CheckALSA) | ||
99 | if(SDL_ALSA) | ||
100 | sdlFindALSA() | ||
101 | if(ALSA_FOUND) | ||
102 | file(GLOB ALSA_SOURCES "${SDL2_SOURCE_DIR}/src/audio/alsa/*.c") | ||
103 | list(APPEND SOURCE_FILES ${ALSA_SOURCES}) | ||
104 | set(SDL_AUDIO_DRIVER_ALSA 1) | ||
105 | set(HAVE_ALSA TRUE) | ||
106 | set(HAVE_ALSA_SHARED FALSE) | ||
107 | if(SDL_ALSA_SHARED) | ||
108 | if(HAVE_SDL_LOADSO) | ||
109 | FindLibraryAndSONAME("asound") | ||
110 | if(ASOUND_LIB AND ASOUND_SHARED) | ||
111 | target_include_directories(sdl-build-options SYSTEM INTERFACE $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>) | ||
112 | set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"") | ||
113 | set(HAVE_ALSA_SHARED TRUE) | ||
114 | else() | ||
115 | message(WARNING "Unable to find asound shared object") | ||
116 | endif() | ||
117 | else() | ||
118 | message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading") | ||
119 | endif() | ||
120 | endif() | ||
121 | if(NOT HAVE_ALSA_SHARED) | ||
122 | list(APPEND CMAKE_DEPENDS ALSA::ALSA) | ||
123 | list(APPEND PKGCONFIG_DEPENDS alsa) | ||
124 | endif() | ||
125 | set(HAVE_SDL_AUDIO TRUE) | ||
126 | else() | ||
127 | set(HAVE_ALSA FALSE) | ||
128 | message(WARNING "Unable to found the alsa development library") | ||
129 | endif() | ||
130 | endif() | ||
131 | endmacro() | ||
132 | |||
133 | # Requires: | ||
134 | # - PkgCheckModules | ||
135 | # Optional: | ||
136 | # - SDL_PIPEWIRE_SHARED opt | ||
137 | # - HAVE_SDL_LOADSO opt | ||
138 | macro(CheckPipewire) | ||
139 | if(SDL_PIPEWIRE) | ||
140 | pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20) | ||
141 | if(PKG_PIPEWIRE_FOUND) | ||
142 | set(HAVE_PIPEWIRE TRUE) | ||
143 | file(GLOB PIPEWIRE_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pipewire/*.c) | ||
144 | list(APPEND SOURCE_FILES ${PIPEWIRE_SOURCES}) | ||
145 | set(SDL_AUDIO_DRIVER_PIPEWIRE 1) | ||
146 | list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS}) | ||
147 | if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO) | ||
148 | message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading") | ||
149 | endif() | ||
150 | FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS}) | ||
151 | if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO) | ||
152 | set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"") | ||
153 | set(HAVE_PIPEWIRE_SHARED TRUE) | ||
154 | else() | ||
155 | list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS}) | ||
156 | endif() | ||
157 | set(HAVE_SDL_AUDIO TRUE) | ||
158 | endif() | ||
159 | endif() | ||
160 | endmacro() | ||
161 | |||
162 | # Requires: | ||
163 | # - PkgCheckModules | ||
164 | # Optional: | ||
165 | # - SDL_PULSEAUDIO_SHARED opt | ||
166 | # - HAVE_SDL_LOADSO opt | ||
167 | macro(CheckPulseAudio) | ||
168 | if(SDL_PULSEAUDIO) | ||
169 | pkg_check_modules(PKG_PULSEAUDIO libpulse>=0.9.15) | ||
170 | if(PKG_PULSEAUDIO_FOUND) | ||
171 | set(HAVE_PULSEAUDIO TRUE) | ||
172 | file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c) | ||
173 | list(APPEND SOURCE_FILES ${PULSEAUDIO_SOURCES}) | ||
174 | set(SDL_AUDIO_DRIVER_PULSEAUDIO 1) | ||
175 | list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS}) | ||
176 | if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO) | ||
177 | message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading") | ||
178 | endif() | ||
179 | FindLibraryAndSONAME("pulse" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS}) | ||
180 | if(SDL_PULSEAUDIO_SHARED AND PULSE_LIB AND HAVE_SDL_LOADSO) | ||
181 | set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_LIB_SONAME}\"") | ||
182 | set(HAVE_PULSEAUDIO_SHARED TRUE) | ||
183 | else() | ||
184 | list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS}) | ||
185 | endif() | ||
186 | set(HAVE_SDL_AUDIO TRUE) | ||
187 | endif() | ||
188 | endif() | ||
189 | endmacro() | ||
190 | |||
191 | # Requires: | ||
192 | # - PkgCheckModules | ||
193 | # Optional: | ||
194 | # - SDL_JACK_SHARED opt | ||
195 | # - HAVE_SDL_LOADSO opt | ||
196 | macro(CheckJACK) | ||
197 | if(SDL_JACK) | ||
198 | pkg_check_modules(PKG_JACK jack) | ||
199 | if(PKG_JACK_FOUND) | ||
200 | set(HAVE_JACK TRUE) | ||
201 | file(GLOB JACK_SOURCES ${SDL2_SOURCE_DIR}/src/audio/jack/*.c) | ||
202 | list(APPEND SOURCE_FILES ${JACK_SOURCES}) | ||
203 | set(SDL_AUDIO_DRIVER_JACK 1) | ||
204 | list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS}) | ||
205 | if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO) | ||
206 | message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading") | ||
207 | endif() | ||
208 | FindLibraryAndSONAME("jack" LIBDIRS ${PKG_JACK_LIBRARY_DIRS}) | ||
209 | if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO) | ||
210 | set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"") | ||
211 | set(HAVE_JACK_SHARED TRUE) | ||
212 | else() | ||
213 | list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS}) | ||
214 | endif() | ||
215 | set(HAVE_SDL_AUDIO TRUE) | ||
216 | endif() | ||
217 | endif() | ||
218 | endmacro() | ||
219 | |||
220 | # Requires: | ||
221 | # - PkgCheckModules | ||
222 | # Optional: | ||
223 | # - SDL_ESD_SHARED opt | ||
224 | # - HAVE_SDL_LOADSO opt | ||
225 | macro(CheckESD) | ||
226 | if(SDL_ESD) | ||
227 | pkg_check_modules(PKG_ESD esound) | ||
228 | if(PKG_ESD_FOUND) | ||
229 | set(HAVE_ESD TRUE) | ||
230 | file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c) | ||
231 | list(APPEND SOURCE_FILES ${ESD_SOURCES}) | ||
232 | set(SDL_AUDIO_DRIVER_ESD 1) | ||
233 | list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS}) | ||
234 | if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO) | ||
235 | message_warn("You must have SDL_LoadObject() support for dynamic ESD loading") | ||
236 | endif() | ||
237 | FindLibraryAndSONAME(esd LIBDIRS ${PKG_ESD_LIBRARY_DIRS}) | ||
238 | if(SDL_ESD_SHARED AND ESD_LIB AND HAVE_SDL_LOADSO) | ||
239 | set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"") | ||
240 | set(HAVE_ESD_SHARED TRUE) | ||
241 | else() | ||
242 | list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS}) | ||
243 | endif() | ||
244 | set(HAVE_SDL_AUDIO TRUE) | ||
245 | endif() | ||
246 | endif() | ||
247 | endmacro() | ||
248 | |||
249 | # Requires: | ||
250 | # - n/a | ||
251 | # Optional: | ||
252 | # - SDL_ARTS_SHARED opt | ||
253 | # - HAVE_SDL_LOADSO opt | ||
254 | macro(CheckARTS) | ||
255 | if(SDL_ARTS) | ||
256 | find_program(ARTS_CONFIG arts-config) | ||
257 | if(ARTS_CONFIG) | ||
258 | execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags | ||
259 | OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
260 | list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS}) | ||
261 | execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs | ||
262 | OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
263 | file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c) | ||
264 | list(APPEND SOURCE_FILES ${ARTS_SOURCES}) | ||
265 | set(SDL_AUDIO_DRIVER_ARTS 1) | ||
266 | set(HAVE_ARTS TRUE) | ||
267 | if(SDL_ARTS_SHARED AND NOT HAVE_SDL_LOADSO) | ||
268 | message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading") | ||
269 | endif() | ||
270 | FindLibraryAndSONAME(artsc) | ||
271 | if(SDL_ARTS_SHARED AND ARTSC_LIB AND HAVE_SDL_LOADSO) | ||
272 | # TODO | ||
273 | set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"") | ||
274 | set(HAVE_ARTS_SHARED TRUE) | ||
275 | else() | ||
276 | list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS}) | ||
277 | endif() | ||
278 | set(HAVE_SDL_AUDIO TRUE) | ||
279 | endif() | ||
280 | endif() | ||
281 | endmacro() | ||
282 | |||
283 | # Requires: | ||
284 | # - n/a | ||
285 | # Optional: | ||
286 | # - SDL_NAS_SHARED opt | ||
287 | # - HAVE_SDL_LOADSO opt | ||
288 | macro(CheckNAS) | ||
289 | if(SDL_NAS) | ||
290 | # TODO: set include paths properly, so the NAS headers are found | ||
291 | check_include_file(audio/audiolib.h HAVE_NAS_H) | ||
292 | find_library(D_NAS_LIB audio) | ||
293 | if(HAVE_NAS_H AND D_NAS_LIB) | ||
294 | set(HAVE_NAS TRUE) | ||
295 | file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c) | ||
296 | list(APPEND SOURCE_FILES ${NAS_SOURCES}) | ||
297 | set(SDL_AUDIO_DRIVER_NAS 1) | ||
298 | if(SDL_NAS_SHARED AND NOT HAVE_SDL_LOADSO) | ||
299 | message_warn("You must have SDL_LoadObject() support for dynamic NAS loading") | ||
300 | endif() | ||
301 | FindLibraryAndSONAME("audio") | ||
302 | if(SDL_NAS_SHARED AND AUDIO_LIB AND HAVE_SDL_LOADSO) | ||
303 | set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"") | ||
304 | set(HAVE_NAS_SHARED TRUE) | ||
305 | else() | ||
306 | list(APPEND EXTRA_LIBS ${D_NAS_LIB}) | ||
307 | endif() | ||
308 | set(HAVE_SDL_AUDIO TRUE) | ||
309 | endif() | ||
310 | endif() | ||
311 | endmacro() | ||
312 | |||
313 | # Requires: | ||
314 | # - PkgCheckModules | ||
315 | # Optional: | ||
316 | # - SDL_SNDIO_SHARED opt | ||
317 | # - HAVE_SDL_LOADSO opt | ||
318 | macro(CheckSNDIO) | ||
319 | if(SDL_SNDIO) | ||
320 | pkg_check_modules(PKG_SNDIO sndio) | ||
321 | if(PKG_SNDIO_FOUND) | ||
322 | set(HAVE_SNDIO TRUE) | ||
323 | file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c) | ||
324 | list(APPEND SOURCE_FILES ${SNDIO_SOURCES}) | ||
325 | set(SDL_AUDIO_DRIVER_SNDIO 1) | ||
326 | list(APPEND EXTRA_CFLAGS ${PKG_SNDIO_CFLAGS}) | ||
327 | if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO) | ||
328 | message_warn("You must have SDL_LoadObject() support for dynamic sndio loading") | ||
329 | endif() | ||
330 | FindLibraryAndSONAME("sndio" LIBDIRS ${PKG_SNDIO_LIBRARY_DIRS}) | ||
331 | if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO) | ||
332 | set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"") | ||
333 | set(HAVE_SNDIO_SHARED TRUE) | ||
334 | else() | ||
335 | list(APPEND EXTRA_LIBS ${PKG_SNDIO_LDFLAGS}) | ||
336 | endif() | ||
337 | set(HAVE_SDL_AUDIO TRUE) | ||
338 | endif() | ||
339 | endif() | ||
340 | endmacro() | ||
341 | |||
342 | # Requires: | ||
343 | # - PkgCheckModules | ||
344 | # Optional: | ||
345 | # - FUSIONSOUND_SHARED opt | ||
346 | # - HAVE_SDL_LOADSO opt | ||
347 | macro(CheckFusionSound) | ||
348 | if(FUSIONSOUND) | ||
349 | pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0) | ||
350 | if(PKG_FUSIONSOUND_FOUND) | ||
351 | set(HAVE_FUSIONSOUND TRUE) | ||
352 | file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c) | ||
353 | list(APPEND SOURCE_FILES ${FUSIONSOUND_SOURCES}) | ||
354 | set(SDL_AUDIO_DRIVER_FUSIONSOUND 1) | ||
355 | list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS}) | ||
356 | if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO) | ||
357 | message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading") | ||
358 | endif() | ||
359 | FindLibraryAndSONAME("fusionsound" LIBDIRS ${PKG_FUSIONSOUND_LIBRARY_DIRS}) | ||
360 | if(FUSIONSOUND_SHARED AND FUSIONSOUND_LIB AND HAVE_SDL_LOADSO) | ||
361 | set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"") | ||
362 | set(HAVE_FUSIONSOUND_SHARED TRUE) | ||
363 | else() | ||
364 | list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS}) | ||
365 | endif() | ||
366 | set(HAVE_SDL_AUDIO TRUE) | ||
367 | endif() | ||
368 | endif() | ||
369 | endmacro() | ||
370 | |||
371 | # Requires: | ||
372 | # - SDL_LIBSAMPLERATE | ||
373 | # Optional: | ||
374 | # - SDL_LIBSAMPLERATE_SHARED opt | ||
375 | # - HAVE_SDL_LOADSO opt | ||
376 | macro(CheckLibSampleRate) | ||
377 | if(SDL_LIBSAMPLERATE) | ||
378 | find_package(SampleRate QUIET) | ||
379 | if(SampleRate_FOUND AND TARGET SampleRate::samplerate) | ||
380 | set(HAVE_LIBSAMPLERATE TRUE) | ||
381 | set(HAVE_LIBSAMPLERATE_H TRUE) | ||
382 | if(SDL_LIBSAMPLERATE_SHARED) | ||
383 | target_include_directories(sdl-build-options SYSTEM INTERFACE $<TARGET_PROPERTY:SampleRate::samplerate,INTERFACE_INCLUDE_DIRECTORIES>) | ||
384 | if(NOT HAVE_SDL_LOADSO) | ||
385 | message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading") | ||
386 | else() | ||
387 | get_property(_samplerate_type TARGET SampleRate::samplerate PROPERTY TYPE) | ||
388 | if(_samplerate_type STREQUAL "SHARED_LIBRARY") | ||
389 | set(HAVE_LIBSAMPLERATE_SHARED TRUE) | ||
390 | if(WIN32 OR OS2) | ||
391 | set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_FILE_NAME:SampleRate::samplerate>\"") | ||
392 | else() | ||
393 | set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_SONAME_FILE_NAME:SampleRate::samplerate>\"") | ||
394 | endif() | ||
395 | endif() | ||
396 | endif() | ||
397 | else() | ||
398 | target_link_libraries(sdl-build-options INTERFACE SampleRate::samplerate) | ||
399 | list(APPEND SDL_REQUIRES_PRIVATE SampleRate::samplerate) | ||
400 | endif() | ||
401 | else() | ||
402 | check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H) | ||
403 | if(HAVE_LIBSAMPLERATE_H) | ||
404 | set(HAVE_LIBSAMPLERATE TRUE) | ||
405 | if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO) | ||
406 | message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading") | ||
407 | endif() | ||
408 | FindLibraryAndSONAME("samplerate") | ||
409 | if(SDL_LIBSAMPLERATE_SHARED AND SAMPLERATE_LIB AND HAVE_SDL_LOADSO) | ||
410 | set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"") | ||
411 | set(HAVE_LIBSAMPLERATE_SHARED TRUE) | ||
412 | else() | ||
413 | list(APPEND EXTRA_LDFLAGS -lsamplerate) | ||
414 | endif() | ||
415 | endif() | ||
416 | endif() | ||
417 | endif() | ||
418 | endmacro() | ||
419 | |||
420 | # Requires: | ||
421 | # - n/a | ||
422 | # Optional: | ||
423 | # - SDL_X11_SHARED opt | ||
424 | # - HAVE_SDL_LOADSO opt | ||
425 | macro(CheckX11) | ||
426 | cmake_push_check_state(RESET) | ||
427 | if(SDL_X11) | ||
428 | foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss) | ||
429 | FindLibraryAndSONAME("${_LIB}") | ||
430 | endforeach() | ||
431 | |||
432 | set(X11_dirs) | ||
433 | find_path(X_INCLUDEDIR | ||
434 | NAMES X11/Xlib.h | ||
435 | PATHS | ||
436 | /usr/pkg/xorg/include | ||
437 | /usr/X11R6/include | ||
438 | /usr/X11R7/include | ||
439 | /usr/local/include/X11 | ||
440 | /usr/include/X11 | ||
441 | /usr/openwin/include | ||
442 | /usr/openwin/share/include | ||
443 | /opt/graphics/OpenGL/include | ||
444 | /opt/X11/include | ||
445 | ) | ||
446 | |||
447 | if(X_INCLUDEDIR) | ||
448 | list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}") | ||
449 | list(APPEND CMAKE_REQUIRED_INCLUDES ${X_INCLUDEDIR}) | ||
450 | endif() | ||
451 | |||
452 | find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X_INCLUDEDIR}") | ||
453 | find_file(HAVE_XINPUT2_H NAMES "X11/extensions/XInput2.h" HINTS "${X_INCLUDEDIR}") | ||
454 | find_file(HAVE_XRANDR_H NAMES "X11/extensions/Xrandr.h" HINTS "${X_INCLUDEDIR}") | ||
455 | find_file(HAVE_XFIXES_H_ NAMES "X11/extensions/Xfixes.h" HINTS "${X_INCLUDEDIR}") | ||
456 | find_file(HAVE_XRENDER_H NAMES "X11/extensions/Xrender.h" HINTS "${X_INCLUDEDIR}") | ||
457 | find_file(HAVE_XSS_H NAMES "X11/extensions/scrnsaver.h" HINTS "${X_INCLUDEDIR}") | ||
458 | find_file(HAVE_XSHAPE_H NAMES "X11/extensions/shape.h" HINTS "${X_INCLUDEDIR}") | ||
459 | find_file(HAVE_XDBE_H NAMES "X11/extensions/Xdbe.h" HINTS "${X_INCLUDEDIR}") | ||
460 | find_file(HAVE_XEXT_H NAMES "X11/extensions/Xext.h" HINTS "${X_INCLUDEDIR}") | ||
461 | |||
462 | if(X11_LIB) | ||
463 | if(NOT HAVE_XEXT_H) | ||
464 | message_error("Missing Xext.h, maybe you need to install the libxext-dev package?") | ||
465 | endif() | ||
466 | |||
467 | set(HAVE_X11 TRUE) | ||
468 | set(HAVE_SDL_VIDEO TRUE) | ||
469 | |||
470 | file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c) | ||
471 | list(APPEND SOURCE_FILES ${X11_SOURCES}) | ||
472 | set(SDL_VIDEO_DRIVER_X11 1) | ||
473 | |||
474 | # Note: Disabled on Apple because the dynamic mode backend for X11 doesn't | ||
475 | # work properly on Apple during several issues like inconsistent paths | ||
476 | # among platforms. See #6778 (https://github.com/libsdl-org/SDL/issues/6778) | ||
477 | if(APPLE) | ||
478 | set(SDL_X11_SHARED OFF) | ||
479 | endif() | ||
480 | |||
481 | check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT_IN_LIBC) | ||
482 | if(NOT HAVE_SHMAT_IN_LIBC) | ||
483 | check_library_exists(ipc shmat "" HAVE_SHMAT_IN_LIBIPC) | ||
484 | if(HAVE_SHMAT_IN_LIBIPC) | ||
485 | list(APPEND EXTRA_LIBS ipc) | ||
486 | endif() | ||
487 | if(NOT HAVE_SHMAT_IN_LIBIPC) | ||
488 | list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY") | ||
489 | endif() | ||
490 | endif() | ||
491 | |||
492 | if(SDL_X11_SHARED) | ||
493 | if(NOT HAVE_SDL_LOADSO) | ||
494 | message_warn("You must have SDL_LoadObject() support for dynamic X11 loading") | ||
495 | set(HAVE_X11_SHARED FALSE) | ||
496 | else() | ||
497 | set(HAVE_X11_SHARED TRUE) | ||
498 | endif() | ||
499 | if(X11_LIB) | ||
500 | if(HAVE_X11_SHARED) | ||
501 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"") | ||
502 | else() | ||
503 | list(APPEND EXTRA_LIBS ${X11_LIB}) | ||
504 | endif() | ||
505 | endif() | ||
506 | if(XEXT_LIB) | ||
507 | if(HAVE_X11_SHARED) | ||
508 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"") | ||
509 | else() | ||
510 | list(APPEND EXTRA_LIBS ${XEXT_LIB_SONAME}) | ||
511 | endif() | ||
512 | endif() | ||
513 | else() | ||
514 | list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB}) | ||
515 | endif() | ||
516 | |||
517 | set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB}) | ||
518 | |||
519 | check_c_source_compiles(" | ||
520 | #include <X11/Xlib.h> | ||
521 | int main(int argc, char **argv) { | ||
522 | Display *display; | ||
523 | XEvent event; | ||
524 | XGenericEventCookie *cookie = &event.xcookie; | ||
525 | XNextEvent(display, &event); | ||
526 | XGetEventData(display, cookie); | ||
527 | XFreeEventData(display, cookie); | ||
528 | return 0; }" HAVE_XGENERICEVENT) | ||
529 | if(HAVE_XGENERICEVENT) | ||
530 | set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1) | ||
531 | endif() | ||
532 | |||
533 | check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM) | ||
534 | |||
535 | if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB) | ||
536 | set(HAVE_X11_XCURSOR TRUE) | ||
537 | if(HAVE_X11_SHARED) | ||
538 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"") | ||
539 | else() | ||
540 | list(APPEND EXTRA_LIBS ${XCURSOR_LIB}) | ||
541 | endif() | ||
542 | set(SDL_VIDEO_DRIVER_X11_XCURSOR 1) | ||
543 | endif() | ||
544 | |||
545 | if(SDL_X11_XDBE AND HAVE_XDBE_H) | ||
546 | set(HAVE_X11_XDBE TRUE) | ||
547 | set(SDL_VIDEO_DRIVER_X11_XDBE 1) | ||
548 | endif() | ||
549 | |||
550 | if(SDL_X11_XINPUT AND HAVE_XINPUT2_H AND XI_LIB) | ||
551 | set(HAVE_X11_XINPUT TRUE) | ||
552 | if(HAVE_X11_SHARED) | ||
553 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"") | ||
554 | else() | ||
555 | list(APPEND EXTRA_LIBS ${XI_LIB}) | ||
556 | endif() | ||
557 | set(SDL_VIDEO_DRIVER_X11_XINPUT2 1) | ||
558 | |||
559 | # Check for multitouch | ||
560 | check_c_source_compiles(" | ||
561 | #include <X11/Xlib.h> | ||
562 | #include <X11/Xproto.h> | ||
563 | #include <X11/extensions/XInput2.h> | ||
564 | int event_type = XI_TouchBegin; | ||
565 | XITouchClassInfo *t; | ||
566 | Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) { | ||
567 | return (Status)0; | ||
568 | } | ||
569 | int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH) | ||
570 | if(HAVE_XINPUT2_MULTITOUCH) | ||
571 | set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1) | ||
572 | endif() | ||
573 | endif() | ||
574 | |||
575 | # check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer | ||
576 | if(SDL_X11_XFIXES AND HAVE_XFIXES_H_ AND HAVE_XINPUT2_H) | ||
577 | check_c_source_compiles(" | ||
578 | #include <X11/Xlib.h> | ||
579 | #include <X11/Xproto.h> | ||
580 | #include <X11/extensions/XInput2.h> | ||
581 | #include <X11/extensions/Xfixes.h> | ||
582 | BarrierEventID b; | ||
583 | int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H) | ||
584 | endif() | ||
585 | if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H AND XFIXES_LIB) | ||
586 | if(HAVE_X11_SHARED) | ||
587 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"") | ||
588 | else() | ||
589 | list(APPEND EXTRA_LIBS ${XFIXES_LIB}) | ||
590 | endif() | ||
591 | set(SDL_VIDEO_DRIVER_X11_XFIXES 1) | ||
592 | set(HAVE_X11_XFIXES TRUE) | ||
593 | endif() | ||
594 | |||
595 | if(SDL_X11_XRANDR AND HAVE_XRANDR_H AND XRANDR_LIB) | ||
596 | if(HAVE_X11_SHARED) | ||
597 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"") | ||
598 | else() | ||
599 | list(APPEND EXTRA_LIBS ${XRANDR_LIB}) | ||
600 | endif() | ||
601 | set(SDL_VIDEO_DRIVER_X11_XRANDR 1) | ||
602 | set(HAVE_X11_XRANDR TRUE) | ||
603 | endif() | ||
604 | |||
605 | if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H AND XSS_LIB) | ||
606 | if(HAVE_X11_SHARED) | ||
607 | set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"") | ||
608 | else() | ||
609 | list(APPEND EXTRA_LIBS ${XSS_LIB}) | ||
610 | endif() | ||
611 | set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1) | ||
612 | set(HAVE_X11_XSCRNSAVER TRUE) | ||
613 | endif() | ||
614 | |||
615 | if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H) | ||
616 | set(SDL_VIDEO_DRIVER_X11_XSHAPE 1) | ||
617 | set(HAVE_X11_XSHAPE TRUE) | ||
618 | endif() | ||
619 | |||
620 | set(CMAKE_REQUIRED_LIBRARIES) | ||
621 | endif() | ||
622 | endif() | ||
623 | if(NOT HAVE_X11) | ||
624 | # Prevent Mesa from including X11 headers | ||
625 | list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11") | ||
626 | endif() | ||
627 | cmake_pop_check_state() | ||
628 | endmacro() | ||
629 | |||
630 | macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL) | ||
631 | set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c") | ||
632 | set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h") | ||
633 | |||
634 | add_custom_command( | ||
635 | OUTPUT "${_WAYLAND_PROT_H_CODE}" | ||
636 | DEPENDS "${_XML}" | ||
637 | COMMAND "${_SCANNER}" | ||
638 | ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}" | ||
639 | ) | ||
640 | |||
641 | add_custom_command( | ||
642 | OUTPUT "${_WAYLAND_PROT_C_CODE}" | ||
643 | DEPENDS "${_WAYLAND_PROT_H_CODE}" | ||
644 | COMMAND "${_SCANNER}" | ||
645 | ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}" | ||
646 | ) | ||
647 | |||
648 | list(APPEND SDL_GENERATED_HEADERS "${_WAYLAND_PROT_H_CODE}") | ||
649 | list(APPEND SOURCE_FILES "${_WAYLAND_PROT_C_CODE}") | ||
650 | endmacro() | ||
651 | |||
652 | # Requires: | ||
653 | # - EGL | ||
654 | # - PkgCheckModules | ||
655 | # Optional: | ||
656 | # - SDL_WAYLAND_SHARED opt | ||
657 | # - HAVE_SDL_LOADSO opt | ||
658 | macro(CheckWayland) | ||
659 | if(SDL_WAYLAND) | ||
660 | set(WAYLAND_FOUND FALSE) | ||
661 | pkg_check_modules(PKG_WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0") | ||
662 | |||
663 | if(PKG_WAYLAND_FOUND) | ||
664 | set(WAYLAND_FOUND TRUE) | ||
665 | find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED) | ||
666 | execute_process( | ||
667 | COMMAND ${WAYLAND_SCANNER} --version | ||
668 | RESULT_VARIABLE WAYLAND_SCANNER_VERSION_RC | ||
669 | ERROR_VARIABLE WAYLAND_SCANNER_VERSION | ||
670 | ERROR_STRIP_TRAILING_WHITESPACE | ||
671 | ) | ||
672 | if(NOT WAYLAND_SCANNER_VERSION_RC EQUAL 0) | ||
673 | message(FATAL "Failed to get wayland-scanner version") | ||
674 | set(WAYLAND_FOUND FALSE) | ||
675 | endif() | ||
676 | string(REPLACE "wayland-scanner " "" WAYLAND_SCANNER_VERSION ${WAYLAND_SCANNER_VERSION}) | ||
677 | |||
678 | string(COMPARE LESS ${WAYLAND_SCANNER_VERSION} "1.15.0" WAYLAND_SCANNER_PRE_1_15) | ||
679 | if(WAYLAND_SCANNER_PRE_1_15) | ||
680 | set(WAYLAND_SCANNER_CODE_MODE "code") | ||
681 | else() | ||
682 | set(WAYLAND_SCANNER_CODE_MODE "private-code") | ||
683 | endif() | ||
684 | endif() | ||
685 | |||
686 | if(WAYLAND_FOUND) | ||
687 | target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}") | ||
688 | target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}") | ||
689 | |||
690 | set(HAVE_WAYLAND TRUE) | ||
691 | set(HAVE_SDL_VIDEO TRUE) | ||
692 | |||
693 | file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c) | ||
694 | list(APPEND SOURCE_FILES ${WAYLAND_SOURCES}) | ||
695 | |||
696 | # We have to generate some protocol interface code for some unstable Wayland features. | ||
697 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols") | ||
698 | target_include_directories(sdl-build-options SYSTEM INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols") | ||
699 | |||
700 | file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml") | ||
701 | foreach(_XML ${WAYLAND_PROTOCOLS_XML}) | ||
702 | string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}") | ||
703 | WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}") | ||
704 | endforeach() | ||
705 | |||
706 | if(SDL_WAYLAND_QT_TOUCH) | ||
707 | set(HAVE_WAYLAND_QT_TOUCH TRUE) | ||
708 | set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1) | ||
709 | endif() | ||
710 | |||
711 | if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO) | ||
712 | message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading") | ||
713 | endif() | ||
714 | FindLibraryAndSONAME(wayland-client LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS}) | ||
715 | FindLibraryAndSONAME(wayland-egl LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS}) | ||
716 | FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS}) | ||
717 | FindLibraryAndSONAME(xkbcommon LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS}) | ||
718 | if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO) | ||
719 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"") | ||
720 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"") | ||
721 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"") | ||
722 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"") | ||
723 | set(HAVE_WAYLAND_SHARED TRUE) | ||
724 | else() | ||
725 | list(APPEND EXTRA_LIBS ${PKG_WAYLAND_LIBRARIES}) | ||
726 | endif() | ||
727 | |||
728 | if(SDL_WAYLAND_LIBDECOR) | ||
729 | pkg_check_modules(PKG_LIBDECOR libdecor-0) | ||
730 | if(PKG_LIBDECOR_FOUND) | ||
731 | set(HAVE_WAYLAND_LIBDECOR TRUE) | ||
732 | set(HAVE_LIBDECOR_H 1) | ||
733 | target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}") | ||
734 | target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}") | ||
735 | if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO) | ||
736 | message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading") | ||
737 | endif() | ||
738 | FindLibraryAndSONAME(decor-0 LIBDIRS ${PKG_LIBDECOR_LIBRARY_DIRS}) | ||
739 | if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO) | ||
740 | set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE) | ||
741 | set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"") | ||
742 | else() | ||
743 | list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES}) | ||
744 | endif() | ||
745 | |||
746 | cmake_push_check_state() | ||
747 | list(APPEND CMAKE_REQUIRED_FLAGS ${PKG_LIBDECOR_CFLAGS}) | ||
748 | list(APPEND CMAKE_REQUIRED_INCLUDES ${PKG_LIBDECOR_INCLUDE_DIRS}) | ||
749 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${PKG_LIBDECOR_LINK_LIBRARIES}) | ||
750 | check_symbol_exists(libdecor_frame_get_max_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE) | ||
751 | check_symbol_exists(libdecor_frame_get_min_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE) | ||
752 | if(HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE AND HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE) | ||
753 | set(SDL_HAVE_LIBDECOR_GET_MIN_MAX 1) | ||
754 | endif() | ||
755 | cmake_pop_check_state() | ||
756 | endif() | ||
757 | endif() | ||
758 | |||
759 | set(SDL_VIDEO_DRIVER_WAYLAND 1) | ||
760 | endif() | ||
761 | endif() | ||
762 | endmacro() | ||
763 | |||
764 | # Requires: | ||
765 | # - n/a | ||
766 | # | ||
767 | macro(CheckCOCOA) | ||
768 | if(SDL_COCOA) | ||
769 | if(APPLE) # Apple always has Cocoa. | ||
770 | set(HAVE_COCOA TRUE) | ||
771 | endif() | ||
772 | if(HAVE_COCOA) | ||
773 | file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m) | ||
774 | list(APPEND SOURCE_FILES ${COCOA_SOURCES}) | ||
775 | set(SDL_VIDEO_DRIVER_COCOA 1) | ||
776 | set(HAVE_SDL_VIDEO TRUE) | ||
777 | endif() | ||
778 | endif() | ||
779 | endmacro() | ||
780 | |||
781 | # Requires: | ||
782 | # - PkgCheckModules | ||
783 | # Optional: | ||
784 | # - DIRECTFB_SHARED opt | ||
785 | # - HAVE_SDL_LOADSO opt | ||
786 | macro(CheckDirectFB) | ||
787 | if(SDL_DIRECTFB) | ||
788 | pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0) | ||
789 | if(PKG_DIRECTFB_FOUND) | ||
790 | set(HAVE_DIRECTFB TRUE) | ||
791 | file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c) | ||
792 | list(APPEND SOURCE_FILES ${DIRECTFB_SOURCES}) | ||
793 | set(SDL_VIDEO_DRIVER_DIRECTFB 1) | ||
794 | set(SDL_VIDEO_RENDER_DIRECTFB 1) | ||
795 | list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS}) | ||
796 | list(APPEND SDL_CFLAGS ${PKG_DIRECTFB_CFLAGS}) | ||
797 | if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO) | ||
798 | message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading") | ||
799 | endif() | ||
800 | FindLibraryAndSONAME("directfb" LIBDIRS ${PKG_DIRECTFB_LIBRARY_DIRS}) | ||
801 | if(SDL_DIRECTFB_SHARED AND DIRECTFB_LIB AND HAVE_SDL_LOADSO) | ||
802 | set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"") | ||
803 | set(HAVE_DIRECTFB_SHARED TRUE) | ||
804 | else() | ||
805 | list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS}) | ||
806 | endif() | ||
807 | set(HAVE_SDL_VIDEO TRUE) | ||
808 | endif() | ||
809 | endif() | ||
810 | endmacro() | ||
811 | |||
812 | # Requires: | ||
813 | # - n/a | ||
814 | macro(CheckVivante) | ||
815 | if(SDL_VIVANTE) | ||
816 | check_c_source_compiles(" | ||
817 | #include <gc_vdk.h> | ||
818 | int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK) | ||
819 | check_c_source_compiles(" | ||
820 | #define LINUX | ||
821 | #define EGL_API_FB | ||
822 | #include <EGL/eglvivante.h> | ||
823 | int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB) | ||
824 | if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB) | ||
825 | set(HAVE_VIVANTE TRUE) | ||
826 | set(HAVE_SDL_VIDEO TRUE) | ||
827 | |||
828 | file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c) | ||
829 | list(APPEND SOURCE_FILES ${VIVANTE_SOURCES}) | ||
830 | set(SDL_VIDEO_DRIVER_VIVANTE 1) | ||
831 | if(HAVE_VIVANTE_VDK) | ||
832 | set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1) | ||
833 | find_library(VIVANTE_LIBRARY REQUIRED NAMES VIVANTE vivante drm_vivante) | ||
834 | find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED) | ||
835 | list(APPEND EXTRA_LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY}) | ||
836 | else() | ||
837 | list(APPEND SDL_CFLAGS -DLINUX -DEGL_API_FB) | ||
838 | list(APPEND EXTRA_LIBS EGL) | ||
839 | endif(HAVE_VIVANTE_VDK) | ||
840 | endif() | ||
841 | endif() | ||
842 | endmacro() | ||
843 | |||
844 | # Requires: | ||
845 | # - nada | ||
846 | macro(CheckGLX) | ||
847 | if(SDL_OPENGL) | ||
848 | check_c_source_compiles(" | ||
849 | #include <GL/glx.h> | ||
850 | int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX) | ||
851 | if(HAVE_OPENGL_GLX) | ||
852 | set(SDL_VIDEO_OPENGL_GLX 1) | ||
853 | endif() | ||
854 | endif() | ||
855 | endmacro() | ||
856 | |||
857 | # Requires: | ||
858 | # - PkgCheckModules | ||
859 | macro(CheckEGL) | ||
860 | if (SDL_OPENGL OR SDL_OPENGLES) | ||
861 | pkg_check_modules(EGL egl) | ||
862 | set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${EGL_CFLAGS}") | ||
863 | check_c_source_compiles(" | ||
864 | #define EGL_API_FB | ||
865 | #define MESA_EGL_NO_X11_HEADERS | ||
866 | #define EGL_NO_X11 | ||
867 | #include <EGL/egl.h> | ||
868 | #include <EGL/eglext.h> | ||
869 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL) | ||
870 | if(HAVE_OPENGL_EGL) | ||
871 | set(SDL_VIDEO_OPENGL_EGL 1) | ||
872 | endif() | ||
873 | endif() | ||
874 | endmacro() | ||
875 | |||
876 | # Requires: | ||
877 | # - nada | ||
878 | macro(CheckOpenGL) | ||
879 | if(SDL_OPENGL) | ||
880 | check_c_source_compiles(" | ||
881 | #include <GL/gl.h> | ||
882 | #include <GL/glext.h> | ||
883 | int main(int argc, char** argv) { return 0; }" HAVE_OPENGL) | ||
884 | if(HAVE_OPENGL) | ||
885 | set(SDL_VIDEO_OPENGL 1) | ||
886 | set(SDL_VIDEO_RENDER_OGL 1) | ||
887 | endif() | ||
888 | endif() | ||
889 | endmacro() | ||
890 | |||
891 | # Requires: | ||
892 | # - nada | ||
893 | macro(CheckOpenGLES) | ||
894 | if(SDL_OPENGLES) | ||
895 | check_c_source_compiles(" | ||
896 | #include <GLES/gl.h> | ||
897 | #include <GLES/glext.h> | ||
898 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1) | ||
899 | if(HAVE_OPENGLES_V1) | ||
900 | set(HAVE_OPENGLES TRUE) | ||
901 | set(SDL_VIDEO_OPENGL_ES 1) | ||
902 | set(SDL_VIDEO_RENDER_OGL_ES 1) | ||
903 | endif() | ||
904 | check_c_source_compiles(" | ||
905 | #include <GLES2/gl2.h> | ||
906 | #include <GLES2/gl2ext.h> | ||
907 | int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2) | ||
908 | if(HAVE_OPENGLES_V2) | ||
909 | set(HAVE_OPENGLES TRUE) | ||
910 | set(SDL_VIDEO_OPENGL_ES2 1) | ||
911 | set(SDL_VIDEO_RENDER_OGL_ES2 1) | ||
912 | endif() | ||
913 | endif() | ||
914 | endmacro() | ||
915 | |||
916 | # Requires: | ||
917 | # - EGL | ||
918 | macro(CheckQNXScreen) | ||
919 | if(QNX AND HAVE_OPENGL_EGL) | ||
920 | check_c_source_compiles(" | ||
921 | #include <screen/screen.h> | ||
922 | int main (int argc, char** argv) { return 0; }" HAVE_QNX_SCREEN) | ||
923 | if(HAVE_QNX_SCREEN) | ||
924 | set(SDL_VIDEO_DRIVER_QNX 1) | ||
925 | file(GLOB QNX_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/qnx/*.c) | ||
926 | list(APPEND SOURCE_FILES ${QNX_VIDEO_SOURCES}) | ||
927 | list(APPEND EXTRA_LIBS screen EGL) | ||
928 | endif() | ||
929 | endif() | ||
930 | endmacro() | ||
931 | |||
932 | # Requires: | ||
933 | # - nada | ||
934 | # Optional: | ||
935 | # - THREADS opt | ||
936 | # Sets: | ||
937 | # PTHREAD_CFLAGS | ||
938 | # PTHREAD_LIBS | ||
939 | macro(CheckPTHREAD) | ||
940 | if(SDL_THREADS AND SDL_PTHREADS) | ||
941 | if(ANDROID) | ||
942 | # the android libc provides built-in support for pthreads, so no | ||
943 | # additional linking or compile flags are necessary | ||
944 | elseif(LINUX) | ||
945 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
946 | set(PTHREAD_LDFLAGS "-pthread") | ||
947 | elseif(BSDI) | ||
948 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
949 | set(PTHREAD_LDFLAGS "") | ||
950 | elseif(DARWIN) | ||
951 | set(PTHREAD_CFLAGS "-D_THREAD_SAFE") | ||
952 | # causes Carbon.p complaints? | ||
953 | # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
954 | set(PTHREAD_LDFLAGS "") | ||
955 | elseif(FREEBSD) | ||
956 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
957 | set(PTHREAD_LDFLAGS "-pthread") | ||
958 | elseif(NETBSD) | ||
959 | set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE") | ||
960 | set(PTHREAD_LDFLAGS "-lpthread") | ||
961 | elseif(OPENBSD) | ||
962 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
963 | set(PTHREAD_LDFLAGS "-lpthread") | ||
964 | elseif(SOLARIS) | ||
965 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
966 | set(PTHREAD_LDFLAGS "-pthread -lposix4") | ||
967 | elseif(SYSV5) | ||
968 | set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread") | ||
969 | set(PTHREAD_LDFLAGS "") | ||
970 | elseif(AIX) | ||
971 | set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads") | ||
972 | set(PTHREAD_LDFLAGS "-pthread") | ||
973 | elseif(HPUX) | ||
974 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
975 | set(PTHREAD_LDFLAGS "-L/usr/lib -pthread") | ||
976 | elseif(HAIKU) | ||
977 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
978 | set(PTHREAD_LDFLAGS "") | ||
979 | elseif(EMSCRIPTEN) | ||
980 | set(PTHREAD_CFLAGS "-D_REENTRANT -pthread") | ||
981 | set(PTHREAD_LDFLAGS "-pthread") | ||
982 | elseif(QNX) | ||
983 | # pthread support is baked in | ||
984 | else() | ||
985 | set(PTHREAD_CFLAGS "-D_REENTRANT") | ||
986 | set(PTHREAD_LDFLAGS "-lpthread") | ||
987 | endif() | ||
988 | |||
989 | # Run some tests | ||
990 | set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
991 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}") | ||
992 | check_c_source_compiles(" | ||
993 | #include <pthread.h> | ||
994 | int main(int argc, char** argv) { | ||
995 | pthread_attr_t type; | ||
996 | pthread_attr_init(&type); | ||
997 | return 0; | ||
998 | }" HAVE_PTHREADS) | ||
999 | if(HAVE_PTHREADS) | ||
1000 | set(SDL_THREAD_PTHREAD 1) | ||
1001 | list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS}) | ||
1002 | list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS}) | ||
1003 | list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS}) | ||
1004 | |||
1005 | check_c_source_compiles(" | ||
1006 | #include <pthread.h> | ||
1007 | int main(int argc, char **argv) { | ||
1008 | pthread_mutexattr_t attr; | ||
1009 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); | ||
1010 | return 0; | ||
1011 | }" HAVE_RECURSIVE_MUTEXES) | ||
1012 | if(HAVE_RECURSIVE_MUTEXES) | ||
1013 | set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1) | ||
1014 | else() | ||
1015 | check_c_source_compiles(" | ||
1016 | #include <pthread.h> | ||
1017 | int main(int argc, char **argv) { | ||
1018 | pthread_mutexattr_t attr; | ||
1019 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); | ||
1020 | return 0; | ||
1021 | }" HAVE_RECURSIVE_MUTEXES_NP) | ||
1022 | if(HAVE_RECURSIVE_MUTEXES_NP) | ||
1023 | set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1) | ||
1024 | endif() | ||
1025 | endif() | ||
1026 | |||
1027 | if(SDL_PTHREADS_SEM) | ||
1028 | check_c_source_compiles("#include <pthread.h> | ||
1029 | #include <semaphore.h> | ||
1030 | int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM) | ||
1031 | if(HAVE_PTHREADS_SEM) | ||
1032 | check_c_source_compiles(" | ||
1033 | #include <pthread.h> | ||
1034 | #include <semaphore.h> | ||
1035 | int main(int argc, char **argv) { | ||
1036 | sem_timedwait(NULL, NULL); | ||
1037 | return 0; | ||
1038 | }" HAVE_SEM_TIMEDWAIT) | ||
1039 | endif() | ||
1040 | endif() | ||
1041 | |||
1042 | check_include_files("pthread.h" HAVE_PTHREAD_H) | ||
1043 | check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H) | ||
1044 | if (HAVE_PTHREAD_H) | ||
1045 | check_c_source_compiles(" | ||
1046 | #include <pthread.h> | ||
1047 | int main(int argc, char **argv) { | ||
1048 | #ifdef __APPLE__ | ||
1049 | pthread_setname_np(\"\"); | ||
1050 | #else | ||
1051 | pthread_setname_np(pthread_self(),\"\"); | ||
1052 | #endif | ||
1053 | return 0; | ||
1054 | }" HAVE_PTHREAD_SETNAME_NP) | ||
1055 | if (HAVE_PTHREAD_NP_H) | ||
1056 | check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP) | ||
1057 | endif() | ||
1058 | endif() | ||
1059 | |||
1060 | set(SOURCE_FILES ${SOURCE_FILES} | ||
1061 | ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c | ||
1062 | ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c # Can be faked, if necessary | ||
1063 | ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c # Can be faked, if necessary | ||
1064 | ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c | ||
1065 | ) | ||
1066 | if(HAVE_PTHREADS_SEM) | ||
1067 | set(SOURCE_FILES ${SOURCE_FILES} | ||
1068 | ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c) | ||
1069 | else() | ||
1070 | set(SOURCE_FILES ${SOURCE_FILES} | ||
1071 | ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c) | ||
1072 | endif() | ||
1073 | set(HAVE_SDL_THREADS TRUE) | ||
1074 | endif() | ||
1075 | set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}") | ||
1076 | endif() | ||
1077 | endmacro() | ||
1078 | |||
1079 | # Requires | ||
1080 | # - nada | ||
1081 | # Optional: | ||
1082 | # Sets: | ||
1083 | # USB_LIBS | ||
1084 | # USB_CFLAGS | ||
1085 | macro(CheckUSBHID) | ||
1086 | check_library_exists(usbhid hid_init "" LIBUSBHID) | ||
1087 | if(LIBUSBHID) | ||
1088 | check_include_file(usbhid.h HAVE_USBHID_H) | ||
1089 | if(HAVE_USBHID_H) | ||
1090 | set(USB_CFLAGS "-DHAVE_USBHID_H") | ||
1091 | endif() | ||
1092 | |||
1093 | check_include_file(libusbhid.h HAVE_LIBUSBHID_H) | ||
1094 | if(HAVE_LIBUSBHID_H) | ||
1095 | set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H") | ||
1096 | endif() | ||
1097 | set(USB_LIBS ${USB_LIBS} usbhid) | ||
1098 | else() | ||
1099 | check_include_file(usb.h HAVE_USB_H) | ||
1100 | if(HAVE_USB_H) | ||
1101 | set(USB_CFLAGS "-DHAVE_USB_H") | ||
1102 | endif() | ||
1103 | check_include_file(libusb.h HAVE_LIBUSB_H) | ||
1104 | if(HAVE_LIBUSB_H) | ||
1105 | set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H") | ||
1106 | endif() | ||
1107 | check_library_exists(usb hid_init "" LIBUSB) | ||
1108 | if(LIBUSB) | ||
1109 | set(USB_LIBS ${USB_LIBS} usb) | ||
1110 | endif() | ||
1111 | endif() | ||
1112 | |||
1113 | set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
1114 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}") | ||
1115 | set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}") | ||
1116 | check_c_source_compiles(" | ||
1117 | #include <sys/types.h> | ||
1118 | #if defined(HAVE_USB_H) | ||
1119 | #include <usb.h> | ||
1120 | #endif | ||
1121 | #ifdef __DragonFly__ | ||
1122 | # include <bus/u4b/usb.h> | ||
1123 | # include <bus/u4b/usbhid.h> | ||
1124 | #else | ||
1125 | # include <dev/usb/usb.h> | ||
1126 | # include <dev/usb/usbhid.h> | ||
1127 | #endif | ||
1128 | #if defined(HAVE_USBHID_H) | ||
1129 | #include <usbhid.h> | ||
1130 | #elif defined(HAVE_LIBUSB_H) | ||
1131 | #include <libusb.h> | ||
1132 | #elif defined(HAVE_LIBUSBHID_H) | ||
1133 | #include <libusbhid.h> | ||
1134 | #endif | ||
1135 | int main(int argc, char **argv) { | ||
1136 | struct report_desc *repdesc; | ||
1137 | struct usb_ctl_report *repbuf; | ||
1138 | hid_kind_t hidkind; | ||
1139 | return 0; | ||
1140 | }" HAVE_USBHID) | ||
1141 | if(HAVE_USBHID) | ||
1142 | check_c_source_compiles(" | ||
1143 | #include <sys/types.h> | ||
1144 | #if defined(HAVE_USB_H) | ||
1145 | #include <usb.h> | ||
1146 | #endif | ||
1147 | #ifdef __DragonFly__ | ||
1148 | # include <bus/u4b/usb.h> | ||
1149 | # include <bus/u4b/usbhid.h> | ||
1150 | #else | ||
1151 | # include <dev/usb/usb.h> | ||
1152 | # include <dev/usb/usbhid.h> | ||
1153 | #endif | ||
1154 | #if defined(HAVE_USBHID_H) | ||
1155 | #include <usbhid.h> | ||
1156 | #elif defined(HAVE_LIBUSB_H) | ||
1157 | #include <libusb.h> | ||
1158 | #elif defined(HAVE_LIBUSBHID_H) | ||
1159 | #include <libusbhid.h> | ||
1160 | #endif | ||
1161 | int main(int argc, char** argv) { | ||
1162 | struct usb_ctl_report buf; | ||
1163 | if (buf.ucr_data) { } | ||
1164 | return 0; | ||
1165 | }" HAVE_USBHID_UCR_DATA) | ||
1166 | if(HAVE_USBHID_UCR_DATA) | ||
1167 | set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA") | ||
1168 | endif() | ||
1169 | |||
1170 | check_c_source_compiles(" | ||
1171 | #include <sys/types.h> | ||
1172 | #if defined(HAVE_USB_H) | ||
1173 | #include <usb.h> | ||
1174 | #endif | ||
1175 | #ifdef __DragonFly__ | ||
1176 | #include <bus/u4b/usb.h> | ||
1177 | #include <bus/u4b/usbhid.h> | ||
1178 | #else | ||
1179 | #include <dev/usb/usb.h> | ||
1180 | #include <dev/usb/usbhid.h> | ||
1181 | #endif | ||
1182 | #if defined(HAVE_USBHID_H) | ||
1183 | #include <usbhid.h> | ||
1184 | #elif defined(HAVE_LIBUSB_H) | ||
1185 | #include <libusb.h> | ||
1186 | #elif defined(HAVE_LIBUSBHID_H) | ||
1187 | #include <libusbhid.h> | ||
1188 | #endif | ||
1189 | int main(int argc, char **argv) { | ||
1190 | report_desc_t d; | ||
1191 | hid_start_parse(d, 1, 1); | ||
1192 | return 0; | ||
1193 | }" HAVE_USBHID_NEW) | ||
1194 | if(HAVE_USBHID_NEW) | ||
1195 | set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW") | ||
1196 | endif() | ||
1197 | |||
1198 | check_c_source_compiles(" | ||
1199 | #include <machine/joystick.h> | ||
1200 | int main(int argc, char** argv) { | ||
1201 | struct joystick t; | ||
1202 | return 0; | ||
1203 | }" HAVE_MACHINE_JOYSTICK) | ||
1204 | if(HAVE_MACHINE_JOYSTICK) | ||
1205 | set(SDL_HAVE_MACHINE_JOYSTICK_H 1) | ||
1206 | endif() | ||
1207 | set(SDL_JOYSTICK_USBHID 1) | ||
1208 | file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c) | ||
1209 | list(APPEND SOURCE_FILES ${BSD_JOYSTICK_SOURCES}) | ||
1210 | list(APPEND EXTRA_CFLAGS ${USB_CFLAGS}) | ||
1211 | list(APPEND EXTRA_LIBS ${USB_LIBS}) | ||
1212 | set(HAVE_SDL_JOYSTICK TRUE) | ||
1213 | |||
1214 | set(CMAKE_REQUIRED_LIBRARIES) | ||
1215 | set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}") | ||
1216 | endif() | ||
1217 | endmacro() | ||
1218 | |||
1219 | # Check for HIDAPI support | ||
1220 | macro(CheckHIDAPI) | ||
1221 | set(HAVE_HIDAPI TRUE) | ||
1222 | if(SDL_HIDAPI) | ||
1223 | if(SDL_HIDAPI_LIBUSB) | ||
1224 | set(HAVE_LIBUSB FALSE) | ||
1225 | pkg_check_modules(PKG_LIBUSB libusb-1.0) | ||
1226 | if(PKG_LIBUSB_FOUND) | ||
1227 | check_include_file(libusb.h HAVE_LIBUSB_H ${PKG_LIBUSB_CFLAGS}) | ||
1228 | if(HAVE_LIBUSB_H) | ||
1229 | set(HAVE_LIBUSB TRUE) | ||
1230 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_LIBUSB_CFLAGS}") | ||
1231 | if(HIDAPI_ONLY_LIBUSB) | ||
1232 | list(APPEND EXTRA_LIBS ${PKG_LIBUSB_LIBRARIES}) | ||
1233 | elseif(OS2) | ||
1234 | set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"") | ||
1235 | else() | ||
1236 | # libusb is loaded dynamically, so don't add it to EXTRA_LIBS | ||
1237 | FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PKG_LIBUSB_LIBRARY_DIRS}) | ||
1238 | if(USB_1.0_LIB) | ||
1239 | set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"") | ||
1240 | endif() | ||
1241 | endif() | ||
1242 | endif() | ||
1243 | endif() | ||
1244 | if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB) | ||
1245 | set(HAVE_HIDAPI FALSE) | ||
1246 | endif() | ||
1247 | set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB}) | ||
1248 | endif() | ||
1249 | |||
1250 | if(HAVE_HIDAPI) | ||
1251 | if(ANDROID) | ||
1252 | list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp) | ||
1253 | endif() | ||
1254 | if(IOS OR TVOS) | ||
1255 | list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m) | ||
1256 | set(SDL_FRAMEWORK_COREBLUETOOTH 1) | ||
1257 | endif() | ||
1258 | set(HAVE_SDL_HIDAPI TRUE) | ||
1259 | |||
1260 | if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK) | ||
1261 | set(SDL_JOYSTICK_HIDAPI 1) | ||
1262 | set(HAVE_SDL_JOYSTICK TRUE) | ||
1263 | set(HAVE_HIDAPI_JOYSTICK TRUE) | ||
1264 | file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c) | ||
1265 | list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES}) | ||
1266 | endif() | ||
1267 | else() | ||
1268 | set(SDL_HIDAPI_DISABLED 1) | ||
1269 | endif() | ||
1270 | else() | ||
1271 | set(SDL_HIDAPI_DISABLED 1) | ||
1272 | endif() | ||
1273 | endmacro() | ||
1274 | |||
1275 | # Requires: | ||
1276 | # - n/a | ||
1277 | macro(CheckRPI) | ||
1278 | if(SDL_RPI) | ||
1279 | pkg_check_modules(VIDEO_RPI bcm_host brcmegl) | ||
1280 | if (NOT VIDEO_RPI_FOUND) | ||
1281 | set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" ) | ||
1282 | set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" ) | ||
1283 | set(VIDEO_RPI_LIBRARIES bcm_host ) | ||
1284 | set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib") | ||
1285 | endif() | ||
1286 | listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I") | ||
1287 | listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L") | ||
1288 | |||
1289 | set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
1290 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}") | ||
1291 | set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}") | ||
1292 | check_c_source_compiles(" | ||
1293 | #include <bcm_host.h> | ||
1294 | #include <EGL/eglplatform.h> | ||
1295 | int main(int argc, char **argv) { | ||
1296 | EGL_DISPMANX_WINDOW_T window; | ||
1297 | bcm_host_init(); | ||
1298 | }" HAVE_RPI) | ||
1299 | set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}") | ||
1300 | set(CMAKE_REQUIRED_LIBRARIES) | ||
1301 | |||
1302 | if(SDL_VIDEO AND HAVE_RPI) | ||
1303 | set(HAVE_SDL_VIDEO TRUE) | ||
1304 | set(SDL_VIDEO_DRIVER_RPI 1) | ||
1305 | file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c) | ||
1306 | list(APPEND SOURCE_FILES ${VIDEO_RPI_SOURCES}) | ||
1307 | list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES}) | ||
1308 | # !!! FIXME: shouldn't be using CMAKE_C_FLAGS, right? | ||
1309 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}") | ||
1310 | list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS}) | ||
1311 | endif() | ||
1312 | endif() | ||
1313 | endmacro() | ||
1314 | |||
1315 | # Requires: | ||
1316 | # - EGL | ||
1317 | # - PkgCheckModules | ||
1318 | # Optional: | ||
1319 | # - SDL_KMSDRM_SHARED opt | ||
1320 | # - HAVE_SDL_LOADSO opt | ||
1321 | macro(CheckKMSDRM) | ||
1322 | if(SDL_KMSDRM) | ||
1323 | pkg_check_modules(PKG_KMSDRM libdrm gbm egl) | ||
1324 | if(PKG_KMSDRM_FOUND AND HAVE_OPENGL_EGL) | ||
1325 | target_link_directories(sdl-build-options INTERFACE ${PKG_KMSDRM_LIBRARY_DIRS}) | ||
1326 | target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}") | ||
1327 | set(HAVE_KMSDRM TRUE) | ||
1328 | set(HAVE_SDL_VIDEO TRUE) | ||
1329 | |||
1330 | file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c) | ||
1331 | list(APPEND SOURCE_FILES ${KMSDRM_SOURCES}) | ||
1332 | |||
1333 | list(APPEND EXTRA_CFLAGS ${PKG_KMSDRM_CFLAGS}) | ||
1334 | |||
1335 | set(SDL_VIDEO_DRIVER_KMSDRM 1) | ||
1336 | |||
1337 | if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO) | ||
1338 | message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading") | ||
1339 | endif() | ||
1340 | if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO) | ||
1341 | FindLibraryAndSONAME(drm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS}) | ||
1342 | FindLibraryAndSONAME(gbm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS}) | ||
1343 | set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"") | ||
1344 | set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"") | ||
1345 | set(HAVE_KMSDRM_SHARED TRUE) | ||
1346 | else() | ||
1347 | list(APPEND EXTRA_LIBS ${PKG_KMSDRM_LIBRARIES}) | ||
1348 | endif() | ||
1349 | endif() | ||
1350 | endif() | ||
1351 | endmacro() | ||
1352 | |||
1353 | macro(CheckLibUDev) | ||
1354 | if(SDL_LIBUDEV) | ||
1355 | check_include_file("libudev.h" have_libudev_header) | ||
1356 | if(have_libudev_header) | ||
1357 | set(HAVE_LIBUDEV_H TRUE) | ||
1358 | FindLibraryAndSONAME(udev) | ||
1359 | if(UDEV_LIB_SONAME) | ||
1360 | set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"") | ||
1361 | endif() | ||
1362 | endif() | ||
1363 | endif() | ||
1364 | endmacro() | ||
1365 | |||
1366 | |||
1367 | macro(CheckLibUnwind) | ||
1368 | set(found_libunwind FALSE) | ||
1369 | set(_libunwind_src "#include <libunwind.h>\nint main() {unw_context_t context; unw_getcontext(&context); return 0;}") | ||
1370 | |||
1371 | if(NOT found_libunwind) | ||
1372 | cmake_push_check_state() | ||
1373 | check_c_source_compiles("${_libunwind_src}" LIBC_HAS_WORKING_LIBUNWIND) | ||
1374 | cmake_pop_check_state() | ||
1375 | if(LIBC_HAS_WORKING_LIBUNWIND) | ||
1376 | set(found_libunwind TRUE) | ||
1377 | endif() | ||
1378 | endif() | ||
1379 | |||
1380 | if(NOT found_libunwind) | ||
1381 | cmake_push_check_state() | ||
1382 | list(APPEND CMAKE_REQUIRED_LIBRARIES "unwind") | ||
1383 | check_c_source_compiles("${_libunwind_src}" LIBUNWIND_HAS_WORKINGLIBUNWIND) | ||
1384 | cmake_pop_check_state() | ||
1385 | if(LIBUNWIND_HAS_WORKINGLIBUNWIND) | ||
1386 | set(found_libunwind TRUE) | ||
1387 | list(APPEND EXTRA_TEST_LIBS unwind) | ||
1388 | endif() | ||
1389 | endif() | ||
1390 | |||
1391 | if(NOT found_libunwind) | ||
1392 | set(LibUnwind_PKG_CONFIG_SPEC libunwind libunwind-generic) | ||
1393 | pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC}) | ||
1394 | if(PC_LIBUNWIND_FOUND) | ||
1395 | cmake_push_check_state() | ||
1396 | list(APPEND CMAKE_REQUIRED_LIBRARIES ${PC_LIBUNWIND_LIBRARIES}) | ||
1397 | list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS}) | ||
1398 | check_c_source_compiles("${_libunwind_src}" PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) | ||
1399 | cmake_pop_check_state() | ||
1400 | if(PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) | ||
1401 | set(found_libunwind TRUE) | ||
1402 | list(APPEND EXTRA_TEST_LIBS ${PC_LIBUNWIND_LIBRARIES}) | ||
1403 | list(APPEND EXTRA_TEST_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS}) | ||
1404 | endif() | ||
1405 | endif() | ||
1406 | endif() | ||
1407 | |||
1408 | if(found_libunwind) | ||
1409 | set(HAVE_LIBUNWIND_H TRUE) | ||
1410 | endif() | ||
1411 | endmacro() | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/sdlfind.cmake b/src/contrib/SDL-2.30.2/cmake/sdlfind.cmake new file mode 100644 index 0000000..a814548 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/sdlfind.cmake | |||
@@ -0,0 +1,9 @@ | |||
1 | |||
2 | macro(sdlFindALSA) | ||
3 | find_package(ALSA MODULE) | ||
4 | if(ALSA_FOUND AND (NOT TARGET ALSA::ALSA) ) | ||
5 | add_Library(ALSA::ALSA UNKNOWN IMPORTED) | ||
6 | set_property(TARGET ALSA::ALSA PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS}) | ||
7 | set_property(TARGET ALSA::ALSA APPEND PROPERTY IMPORTED_LOCATION ${ALSA_LIBRARY}) | ||
8 | endif() | ||
9 | endmacro() | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/sdlplatform.cmake b/src/contrib/SDL-2.30.2/cmake/sdlplatform.cmake new file mode 100644 index 0000000..6d8ece6 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/sdlplatform.cmake | |||
@@ -0,0 +1,59 @@ | |||
1 | macro(SDL_DetectCMakePlatform) | ||
2 | set(SDL_CMAKE_PLATFORM ) | ||
3 | # Get the platform | ||
4 | if(WIN32) | ||
5 | set(SDL_CMAKE_PLATFORM WINDOWS) | ||
6 | elseif(UNIX AND NOT APPLE) | ||
7 | if(CMAKE_SYSTEM_NAME MATCHES ".*Linux") | ||
8 | set(SDL_CMAKE_PLATFORM LINUX) | ||
9 | elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*") | ||
10 | set(SDL_CMAKE_PLATFORM FREEBSD) | ||
11 | elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*") | ||
12 | set(SDL_CMAKE_PLATFORM NETBSD) | ||
13 | elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*") | ||
14 | set(SDL_CMAKE_PLATFORM OPENBSD) | ||
15 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*") | ||
16 | set(SDL_CMAKE_PLATFORM GNU) | ||
17 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*") | ||
18 | set(SDL_CMAKE_PLATFORM BSDI) | ||
19 | elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD") | ||
20 | set(SDL_CMAKE_PLATFORM FREEBSD) | ||
21 | elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*") | ||
22 | set(SDL_CMAKE_PLATFORM SYSV5) | ||
23 | elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*") | ||
24 | set(SDL_CMAKE_PLATFORM SOLARIS) | ||
25 | elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*") | ||
26 | set(SDL_CMAKE_PLATFORM HPUX) | ||
27 | elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*") | ||
28 | set(SDL_CMAKE_PLATFORM AIX) | ||
29 | elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*") | ||
30 | set(SDL_CMAKE_PLATFORM MINIX) | ||
31 | elseif(CMAKE_SYSTEM_NAME MATCHES "QNX") | ||
32 | set(SDL_CMAKE_PLATFORM QNX) | ||
33 | endif() | ||
34 | elseif(APPLE) | ||
35 | if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*") | ||
36 | set(SDL_CMAKE_PLATFORM DARWIN) | ||
37 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*") | ||
38 | set(SDL_CMAKE_PLATFORM MACOSX) | ||
39 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*") | ||
40 | set(SDL_CMAKE_PLATFORM TVOS) | ||
41 | elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*") | ||
42 | # !!! FIXME: remove the version check when we start requiring >= 3.14.0 | ||
43 | if(CMAKE_VERSION VERSION_LESS 3.14) | ||
44 | set(SDL_CMAKE_PLATFORM IOS) | ||
45 | endif() | ||
46 | endif() | ||
47 | elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*") | ||
48 | message_error("BeOS support has been removed as of SDL 2.0.2.") | ||
49 | elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*") | ||
50 | set(SDL_CMAKE_PLATFORM HAIKU) | ||
51 | elseif(NINTENDO_3DS) | ||
52 | set(SDL_CMAKE_PLATFORM N3DS) | ||
53 | elseif(OS2) | ||
54 | set(SDL_CMAKE_PLATFORM OS2) | ||
55 | endif() | ||
56 | if(SDL_CMAKE_PLATFORM) | ||
57 | set(${SDL_CMAKE_PLATFORM} TRUE) | ||
58 | endif() | ||
59 | endmacro() | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/CMakeLists.txt b/src/contrib/SDL-2.30.2/cmake/test/CMakeLists.txt new file mode 100644 index 0000000..388e86c --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/CMakeLists.txt | |||
@@ -0,0 +1,124 @@ | |||
1 | # This cmake build script is meant for verifying the various CMake configuration script. | ||
2 | |||
3 | cmake_minimum_required(VERSION 3.12) | ||
4 | project(sdl_test LANGUAGES C) | ||
5 | |||
6 | include(GenerateExportHeader) | ||
7 | |||
8 | if(ANDROID) | ||
9 | macro(add_executable NAME) | ||
10 | set(args ${ARGN}) | ||
11 | list(REMOVE_ITEM args WIN32) | ||
12 | add_library(${NAME} SHARED ${args}) | ||
13 | unset(args) | ||
14 | endmacro() | ||
15 | endif() | ||
16 | |||
17 | cmake_policy(SET CMP0074 NEW) | ||
18 | |||
19 | # Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL2 outside of sysroot | ||
20 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) | ||
21 | |||
22 | include(FeatureSummary) | ||
23 | |||
24 | option(TEST_SHARED "Test linking to shared SDL2 library" ON) | ||
25 | add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library") | ||
26 | |||
27 | option(TEST_STATIC "Test linking to static SDL2 library" ON) | ||
28 | add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") | ||
29 | |||
30 | if(TEST_SHARED) | ||
31 | find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2) | ||
32 | if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE)) | ||
33 | find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main) | ||
34 | endif() | ||
35 | add_executable(gui-shared WIN32 main_gui.c) | ||
36 | if(TARGET SDL2::SDL2main) | ||
37 | target_link_libraries(gui-shared PRIVATE SDL2::SDL2main) | ||
38 | endif() | ||
39 | target_link_libraries(gui-shared PRIVATE SDL2::SDL2) | ||
40 | if(WIN32) | ||
41 | add_custom_command(TARGET gui-shared POST_BUILD | ||
42 | COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL2::SDL2>" "$<TARGET_FILE_DIR:gui-shared>" | ||
43 | ) | ||
44 | endif() | ||
45 | |||
46 | add_library(sharedlib-shared SHARED main_lib.c) | ||
47 | target_link_libraries(sharedlib-shared PRIVATE SDL2::SDL2) | ||
48 | generate_export_header(sharedlib-shared EXPORT_MACRO_NAME MYLIBRARY_EXPORT) | ||
49 | target_compile_definitions(sharedlib-shared PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared_export.h\"") | ||
50 | set_target_properties(sharedlib-shared PROPERTIES C_VISIBILITY_PRESET "hidden") | ||
51 | |||
52 | add_executable(gui-shared-vars WIN32 main_gui.c) | ||
53 | target_link_libraries(gui-shared-vars PRIVATE ${SDL2_LIBRARIES}) | ||
54 | target_include_directories(gui-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS}) | ||
55 | |||
56 | add_executable(cli-shared main_cli.c) | ||
57 | target_link_libraries(cli-shared PRIVATE SDL2::SDL2) | ||
58 | if(WIN32) | ||
59 | add_custom_command(TARGET cli-shared POST_BUILD | ||
60 | COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL2::SDL2>" "$<TARGET_FILE_DIR:cli-shared>" | ||
61 | ) | ||
62 | endif() | ||
63 | |||
64 | # SDL2_LIBRARIES does not support creating a cli SDL2 application | ||
65 | # (it is possible that SDL2main is a stub, but we don't know for sure) | ||
66 | if(NOT TARGET SDL2::SDL2main) | ||
67 | add_executable(cli-shared-vars main_cli.c) | ||
68 | target_link_libraries(cli-shared-vars PRIVATE ${SDL2_LIBRARIES}) | ||
69 | target_include_directories(cli-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS}) | ||
70 | endif() | ||
71 | |||
72 | add_library(sharedlib-shared-vars SHARED main_lib.c) | ||
73 | target_link_libraries(sharedlib-shared-vars PRIVATE ${SDL2_LIBRARIES}) | ||
74 | target_include_directories(sharedlib-shared-vars PRIVATE ${SDL2_INCLUDE_DIRS}) | ||
75 | generate_export_header(sharedlib-shared-vars EXPORT_MACRO_NAME MYLIBRARY_EXPORT) | ||
76 | target_compile_definitions(sharedlib-shared-vars PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-shared-vars_export.h\"") | ||
77 | set_target_properties(sharedlib-shared-vars PROPERTIES C_VISIBILITY_PRESET "hidden") | ||
78 | endif() | ||
79 | |||
80 | if(TEST_STATIC) | ||
81 | find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2-static) | ||
82 | if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE)) | ||
83 | find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main) | ||
84 | endif() | ||
85 | add_executable(gui-static WIN32 main_gui.c) | ||
86 | if(TARGET SDL2::SDL2main) | ||
87 | target_link_libraries(gui-static PRIVATE SDL2::SDL2main) | ||
88 | endif() | ||
89 | target_link_libraries(gui-static PRIVATE SDL2::SDL2-static) | ||
90 | |||
91 | option(SDL_STATIC_PIC "SDL static library has been built with PIC") | ||
92 | if(SDL_STATIC_PIC OR WIN32) | ||
93 | add_library(sharedlib-static SHARED main_lib.c) | ||
94 | target_link_libraries(sharedlib-static PRIVATE SDL2::SDL2-static) | ||
95 | generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT) | ||
96 | target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"") | ||
97 | set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden") | ||
98 | endif() | ||
99 | |||
100 | add_executable(gui-static-vars WIN32 main_gui.c) | ||
101 | target_link_libraries(gui-static-vars PRIVATE ${SDL2MAIN_LIBRARY} ${SDL2_STATIC_LIBRARIES}) | ||
102 | target_include_directories(gui-static-vars PRIVATE ${SDL2_INCLUDE_DIRS}) | ||
103 | |||
104 | add_executable(cli-static main_cli.c) | ||
105 | target_link_libraries(cli-static PRIVATE SDL2::SDL2-static) | ||
106 | |||
107 | # SDL2_LIBRARIES does not support creating a cli SDL2 application (when SDL2::SDL2main is available) | ||
108 | # (it is possible that SDL2main is a stub, but we don't know for sure) | ||
109 | if(NOT TARGET SDL2::SDL2main) | ||
110 | add_executable(cli-static-vars main_cli.c) | ||
111 | target_link_libraries(cli-static-vars PRIVATE ${SDL2_STATIC_LIBRARIES}) | ||
112 | target_include_directories(cli-static-vars PRIVATE ${SDL2_INCLUDE_DIRS}) | ||
113 | endif() | ||
114 | endif() | ||
115 | |||
116 | message(STATUS "SDL2_PREFIX: ${SDL2_PREFIX}") | ||
117 | message(STATUS "SDL2_INCLUDE_DIR: ${SDL2_INCLUDE_DIR}") | ||
118 | message(STATUS "SDL2_INCLUDE_DIRS: ${SDL2_INCLUDE_DIRS}") | ||
119 | message(STATUS "SDL2_LIBRARIES: ${SDL2_LIBRARIES}") | ||
120 | message(STATUS "SDL2_STATIC_LIBRARIES: ${SDL2_STATIC_LIBRARIES}") | ||
121 | message(STATUS "SDL2MAIN_LIBRARY: ${SDL2MAIN_LIBRARY}") | ||
122 | message(STATUS "SDL2TEST_LIBRARY: ${SDL2TEST_LIBRARY}") | ||
123 | |||
124 | feature_summary(WHAT ALL) | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/jni/Android.mk b/src/contrib/SDL-2.30.2/cmake/test/jni/Android.mk new file mode 100644 index 0000000..c4956d6 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/jni/Android.mk | |||
@@ -0,0 +1,11 @@ | |||
1 | LOCAL_PATH := $(call my-dir) | ||
2 | |||
3 | include $(CLEAR_VARS) | ||
4 | |||
5 | LOCAL_MODULE := main_gui_androidmk | ||
6 | LOCAL_SRC_FILES := ../main_gui.c | ||
7 | LOCAL_SHARED_LIBRARIES += SDL2 | ||
8 | include $(BUILD_SHARED_LIBRARY) | ||
9 | |||
10 | $(call import-module,SDL2main) | ||
11 | $(call import-module,SDL2) | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/main_cli.c b/src/contrib/SDL-2.30.2/cmake/test/main_cli.c new file mode 100644 index 0000000..f6b0836 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/main_cli.c | |||
@@ -0,0 +1,14 @@ | |||
1 | #define SDL_MAIN_HANDLED | ||
2 | #include "SDL.h" | ||
3 | #include <stdio.h> | ||
4 | |||
5 | int main(int argc, char *argv[]) { | ||
6 | SDL_SetMainReady(); | ||
7 | if (SDL_Init(0) < 0) { | ||
8 | fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); | ||
9 | return 1; | ||
10 | } | ||
11 | SDL_Delay(100); | ||
12 | SDL_Quit(); | ||
13 | return 0; | ||
14 | } | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/main_gui.c b/src/contrib/SDL-2.30.2/cmake/test/main_gui.c new file mode 100644 index 0000000..ca2d92e --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/main_gui.c | |||
@@ -0,0 +1,28 @@ | |||
1 | #include "SDL.h" | ||
2 | #include <stdio.h> | ||
3 | |||
4 | int main(int argc, char *argv[]) { | ||
5 | SDL_Window *window = NULL; | ||
6 | SDL_Surface *screenSurface = NULL; | ||
7 | if (SDL_Init(SDL_INIT_VIDEO) < 0) { | ||
8 | fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); | ||
9 | return 1; | ||
10 | } | ||
11 | window = SDL_CreateWindow( | ||
12 | "hello_sdl2", | ||
13 | SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, | ||
14 | 640, 480, | ||
15 | SDL_WINDOW_SHOWN | ||
16 | ); | ||
17 | if (!window) { | ||
18 | fprintf(stderr, "could not create window: %s\n", SDL_GetError()); | ||
19 | return 1; | ||
20 | } | ||
21 | screenSurface = SDL_GetWindowSurface(window); | ||
22 | SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xff, 0xff, 0xff)); | ||
23 | SDL_UpdateWindowSurface(window); | ||
24 | SDL_Delay(100); | ||
25 | SDL_DestroyWindow(window); | ||
26 | SDL_Quit(); | ||
27 | return 0; | ||
28 | } | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/main_lib.c b/src/contrib/SDL-2.30.2/cmake/test/main_lib.c new file mode 100644 index 0000000..9801ed5 --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/main_lib.c | |||
@@ -0,0 +1,33 @@ | |||
1 | #include "SDL.h" | ||
2 | #include <stdio.h> | ||
3 | |||
4 | #include EXPORT_HEADER | ||
5 | |||
6 | #if defined(_WIN32) | ||
7 | #include <windows.h> | ||
8 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { | ||
9 | return TRUE; | ||
10 | } | ||
11 | #endif | ||
12 | |||
13 | int MYLIBRARY_EXPORT mylibrary_init(void); | ||
14 | void MYLIBRARY_EXPORT mylibrary_quit(void); | ||
15 | int MYLIBRARY_EXPORT mylibrary_work(void); | ||
16 | |||
17 | int mylibrary_init(void) { | ||
18 | SDL_SetMainReady(); | ||
19 | if (SDL_Init(0) < 0) { | ||
20 | fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); | ||
21 | return 1; | ||
22 | } | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | void mylibrary_quit(void) { | ||
27 | SDL_Quit(); | ||
28 | } | ||
29 | |||
30 | int mylibrary_work(void) { | ||
31 | SDL_Delay(100); | ||
32 | return 0; | ||
33 | } | ||
diff --git a/src/contrib/SDL-2.30.2/cmake/test/test_pkgconfig.sh b/src/contrib/SDL-2.30.2/cmake/test/test_pkgconfig.sh new file mode 100755 index 0000000..500cd09 --- /dev/null +++ b/src/contrib/SDL-2.30.2/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="$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 sdl2 --cflags )" | ||
29 | SDL_LDFLAGS="$( pkg-config sdl2 --libs )" | ||
30 | SDL_STATIC_LDFLAGS="$( pkg-config sdl2 --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-2.30.2/cmake/test/test_sdlconfig.sh b/src/contrib/SDL-2.30.2/cmake/test/test_sdlconfig.sh new file mode 100755 index 0000000..fa41dbb --- /dev/null +++ b/src/contrib/SDL-2.30.2/cmake/test/test_sdlconfig.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="$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="$( sdl2-config --cflags )" | ||
29 | SDL_LDFLAGS="$( sdl2-config --libs )" | ||
30 | SDL_STATIC_LDFLAGS="$( sdl2-config --static-libs )" | ||
31 | |||
32 | compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $SDL_CFLAGS" | ||
33 | link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS" | ||
34 | static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS" | ||
35 | |||
36 | echo "-- CC: $CC" | ||
37 | echo "-- CFLAGS: $CFLAGS" | ||
38 | echo "-- LDFLAGS: $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 | ||