diff options
Diffstat (limited to 'src/contrib/SDL-2.30.2/sdl2-config.cmake.in')
-rw-r--r-- | src/contrib/SDL-2.30.2/sdl2-config.cmake.in | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/sdl2-config.cmake.in b/src/contrib/SDL-2.30.2/sdl2-config.cmake.in new file mode 100644 index 0000000..842f826 --- /dev/null +++ b/src/contrib/SDL-2.30.2/sdl2-config.cmake.in | |||
@@ -0,0 +1,222 @@ | |||
1 | # sdl2 cmake project-config input for ./configure script | ||
2 | |||
3 | include(FeatureSummary) | ||
4 | set_package_properties(SDL2 PROPERTIES | ||
5 | URL "https://www.libsdl.org/" | ||
6 | DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware" | ||
7 | ) | ||
8 | |||
9 | # Copied from `configure_package_config_file` | ||
10 | macro(set_and_check _var _file) | ||
11 | set(${_var} "${_file}") | ||
12 | if(NOT EXISTS "${_file}") | ||
13 | message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") | ||
14 | endif() | ||
15 | endmacro() | ||
16 | |||
17 | get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR} REALPATH) | ||
18 | get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/@cmake_prefix_relpath@" ABSOLUTE) | ||
19 | |||
20 | set(exec_prefix "@exec_prefix@") | ||
21 | set(bindir "@bindir@") | ||
22 | set(libdir "@libdir@") | ||
23 | set(includedir "@includedir@") | ||
24 | |||
25 | set_and_check(SDL2_PREFIX "${prefix}") | ||
26 | set_and_check(SDL2_EXEC_PREFIX "${exec_prefix}") | ||
27 | set_and_check(SDL2_BINDIR "${bindir}") | ||
28 | set_and_check(SDL2_INCLUDE_DIR "${includedir}/SDL2") | ||
29 | set_and_check(SDL2_LIBDIR "${libdir}") | ||
30 | set(SDL2_INCLUDE_DIRS "${includedir};${SDL2_INCLUDE_DIR}") | ||
31 | |||
32 | set(SDL2_LIBRARIES SDL2::SDL2) | ||
33 | set(SDL2_STATIC_LIBRARIES SDL2::SDL2-static) | ||
34 | set(SDL2MAIN_LIBRARY) | ||
35 | set(SDL2TEST_LIBRARY SDL2::SDL2test) | ||
36 | |||
37 | unset(prefix) | ||
38 | unset(exec_prefix) | ||
39 | unset(bindir) | ||
40 | unset(libdir) | ||
41 | unset(includedir) | ||
42 | |||
43 | set(_sdl2_libraries_in "@SDL_LIBS@") | ||
44 | set(_sdl2_static_private_libs_in "@SDL_STATIC_LIBS@") | ||
45 | |||
46 | # Convert _sdl2_libraries to list and keep only libraries + library directories | ||
47 | string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries_in}") | ||
48 | string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}") | ||
49 | string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}") | ||
50 | string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_libdirs "${_sdl2_libraries_in}") | ||
51 | string(REGEX REPLACE "^-L" "" _sdl2_libdirs "${_sdl2_libdirs}") | ||
52 | string(REGEX REPLACE ";-L" ";" _sdl2_libdirs "${_sdl2_libdirs}") | ||
53 | list(APPEND _sdl2_libdirs "${SDL2_LIBDIR}") | ||
54 | |||
55 | # Convert _sdl2_static_private_libs to list and keep only libraries + library directories | ||
56 | string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}") | ||
57 | string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}") | ||
58 | string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}") | ||
59 | string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sdl2_static_private_libs_in}") | ||
60 | string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}") | ||
61 | string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}") | ||
62 | |||
63 | # Set SDL2_NO_MWINDOWS to a true-ish value to not add the -mwindows link option | ||
64 | if(SDL2_NO_MWINDOWS) | ||
65 | list(REMOVE_ITEM _sdl2_libraries "-mwindows") | ||
66 | endif() | ||
67 | |||
68 | if(_sdl2_libraries MATCHES ".*SDL2main.*") | ||
69 | list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main) | ||
70 | list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main) | ||
71 | endif() | ||
72 | |||
73 | set(_sdl2main_library ${SDL2_LIBDIR}/libSDL2main.a) | ||
74 | if(EXISTS "${_sdl2main_library}") | ||
75 | set(SDL2MAIN_LIBRARY SDL2::SDL2main) | ||
76 | if(NOT TARGET SDL2::SDL2main) | ||
77 | add_library(SDL2::SDL2main STATIC IMPORTED) | ||
78 | set_target_properties(SDL2::SDL2main | ||
79 | PROPERTIES | ||
80 | IMPORTED_LOCATION "${_sdl2main_library}" | ||
81 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" | ||
82 | INTERFACE_SDL_VERSION "SDL2" | ||
83 | ) | ||
84 | if(WIN32) | ||
85 | # INTERFACE_LINK_OPTIONS needs CMake 3.13 | ||
86 | cmake_minimum_required(VERSION 3.13) | ||
87 | # Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker. | ||
88 | if(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
89 | set_target_properties(SDL2::SDL2main | ||
90 | PROPERTIES | ||
91 | INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>" | ||
92 | ) | ||
93 | else() | ||
94 | set_target_properties(SDL2::SDL2main | ||
95 | PROPERTIES | ||
96 | INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>" | ||
97 | ) | ||
98 | endif() | ||
99 | endif() | ||
100 | endif() | ||
101 | set(SDL2_SDL2main_FOUND TRUE) | ||
102 | else() | ||
103 | set(SDL2_SDL2main_FOUND FALSE) | ||
104 | endif() | ||
105 | unset(_sdl2main_library) | ||
106 | |||
107 | # Remove SDL2 since this is the "central" library | ||
108 | # Remove SDL2main since this will be provided by SDL2::SDL2main (if available) | ||
109 | # Remove mingw32 and cygwin since these are not needed when using `-Wl,--undefined,WinMain` | ||
110 | set(_sdl2_link_libraries ${_sdl2_libraries}) | ||
111 | list(REMOVE_ITEM _sdl2_link_libraries SDL2 SDL2main mingw32 cygwin) | ||
112 | |||
113 | if(WIN32) | ||
114 | set(_sdl2_implib "${SDL2_LIBDIR}/libSDL2.dll.a") | ||
115 | set(_sdl2_dll "${SDL2_BINDIR}/SDL2.dll") | ||
116 | if(EXISTS "${_sdl2_implib}" AND EXISTS "${_sdl2_dll}") | ||
117 | if(NOT TARGET SDL2::SDL2) | ||
118 | add_library(SDL2::SDL2 SHARED IMPORTED) | ||
119 | set_target_properties(SDL2::SDL2 PROPERTIES | ||
120 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" | ||
121 | INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}" | ||
122 | INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}" | ||
123 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
124 | IMPORTED_IMPLIB "${_sdl2_implib}" | ||
125 | IMPORTED_LOCATION "${_sdl2_dll}" | ||
126 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" | ||
127 | INTERFACE_SDL_VERSION "SDL2" | ||
128 | ) | ||
129 | endif() | ||
130 | set(SDL2_SDL2_FOUND TRUE) | ||
131 | else() | ||
132 | set(SDL2_SDL2_FOUND FALSE) | ||
133 | endif() | ||
134 | unset(_sdl2_implib) | ||
135 | unset(_sdl2_dll) | ||
136 | else() | ||
137 | set(_sdl2_shared "${SDL2_LIBDIR}/libSDL2${CMAKE_SHARED_LIBRARY_SUFFIX}") | ||
138 | if(EXISTS "${_sdl2_shared}") | ||
139 | if(NOT TARGET SDL2::SDL2) | ||
140 | add_library(SDL2::SDL2 SHARED IMPORTED) | ||
141 | set_target_properties(SDL2::SDL2 PROPERTIES | ||
142 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" | ||
143 | INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}" | ||
144 | INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}" | ||
145 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
146 | IMPORTED_LOCATION "${_sdl2_shared}" | ||
147 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" | ||
148 | INTERFACE_SDL_VERSION "SDL2" | ||
149 | ) | ||
150 | endif() | ||
151 | set(SDL2_SDL2_FOUND TRUE) | ||
152 | else() | ||
153 | set(SDL2_SDL2_FOUND FALSE) | ||
154 | endif() | ||
155 | unset(_sdl2_shared) | ||
156 | endif() | ||
157 | |||
158 | set(_sdl2_static "${SDL2_LIBDIR}/libSDL2.a") | ||
159 | if(EXISTS "${_sdl2_static}") | ||
160 | if(NOT TARGET SDL2::SDL2-static) | ||
161 | add_library(SDL2::SDL2-static STATIC IMPORTED) | ||
162 | set_target_properties(SDL2::SDL2-static | ||
163 | PROPERTIES | ||
164 | IMPORTED_LOCATION "${_sdl2_static}" | ||
165 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" | ||
166 | INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries};${_sdl2_static_private_libs}" | ||
167 | INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs};${_sdl2_static_private_libdirs}" | ||
168 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
169 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" | ||
170 | INTERFACE_SDL_VERSION "SDL2" | ||
171 | ) | ||
172 | endif() | ||
173 | set(SDL2_SDL2-static_FOUND TRUE) | ||
174 | else() | ||
175 | set(SDL2_SDL2-static_FOUND FALSE) | ||
176 | endif() | ||
177 | unset(_sdl2_static) | ||
178 | |||
179 | unset(_sdl2_link_libraries) | ||
180 | |||
181 | set(_sdl2test_library "${SDL2_LIBDIR}/libSDL2_test.a") | ||
182 | if(EXISTS "${_sdl2test_library}") | ||
183 | if(NOT TARGET SDL2::SDL2test) | ||
184 | add_library(SDL2::SDL2test STATIC IMPORTED) | ||
185 | set_target_properties(SDL2::SDL2test | ||
186 | PROPERTIES | ||
187 | IMPORTED_LOCATION "${_sdl2test_library}" | ||
188 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" | ||
189 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
190 | COMPATIBLE_INTERFACE_STRING "SDL_VERSION" | ||
191 | INTERFACE_SDL_VERSION "SDL2" | ||
192 | ) | ||
193 | endif() | ||
194 | set(SDL2_SDL2test_FOUND TRUE) | ||
195 | else() | ||
196 | set(SDL2_SDL2test_FOUND FALSE) | ||
197 | endif() | ||
198 | unset(_sdl2test_library) | ||
199 | |||
200 | # Copied from `configure_package_config_file` | ||
201 | macro(check_required_components _NAME) | ||
202 | foreach(comp ${${_NAME}_FIND_COMPONENTS}) | ||
203 | if(NOT ${_NAME}_${comp}_FOUND) | ||
204 | if(${_NAME}_FIND_REQUIRED_${comp}) | ||
205 | set(${_NAME}_FOUND FALSE) | ||
206 | endif() | ||
207 | endif() | ||
208 | endforeach() | ||
209 | endmacro() | ||
210 | |||
211 | check_required_components(SDL2) | ||
212 | |||
213 | # Create SDL2::SDL2 alias for static-only builds | ||
214 | if(TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2) | ||
215 | if(CMAKE_VERSION VERSION_LESS "3.18") | ||
216 | # FIXME: Aliasing local targets is not supported on CMake < 3.18, so make it global. | ||
217 | add_library(SDL2::SDL2 INTERFACE IMPORTED) | ||
218 | set_target_properties(SDL2::SDL2 PROPERTIES INTERFACE_LINK_LIBRARIES "SDL2::SDL2-static") | ||
219 | else() | ||
220 | add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static) | ||
221 | endif() | ||
222 | endif() | ||