summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-2.30.2/sdl2-config.cmake.in
diff options
context:
space:
mode:
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.in222
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
3include(FeatureSummary)
4set_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`
10macro(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()
15endmacro()
16
17get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR} REALPATH)
18get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/@cmake_prefix_relpath@" ABSOLUTE)
19
20set(exec_prefix "@exec_prefix@")
21set(bindir "@bindir@")
22set(libdir "@libdir@")
23set(includedir "@includedir@")
24
25set_and_check(SDL2_PREFIX "${prefix}")
26set_and_check(SDL2_EXEC_PREFIX "${exec_prefix}")
27set_and_check(SDL2_BINDIR "${bindir}")
28set_and_check(SDL2_INCLUDE_DIR "${includedir}/SDL2")
29set_and_check(SDL2_LIBDIR "${libdir}")
30set(SDL2_INCLUDE_DIRS "${includedir};${SDL2_INCLUDE_DIR}")
31
32set(SDL2_LIBRARIES SDL2::SDL2)
33set(SDL2_STATIC_LIBRARIES SDL2::SDL2-static)
34set(SDL2MAIN_LIBRARY)
35set(SDL2TEST_LIBRARY SDL2::SDL2test)
36
37unset(prefix)
38unset(exec_prefix)
39unset(bindir)
40unset(libdir)
41unset(includedir)
42
43set(_sdl2_libraries_in "@SDL_LIBS@")
44set(_sdl2_static_private_libs_in "@SDL_STATIC_LIBS@")
45
46# Convert _sdl2_libraries to list and keep only libraries + library directories
47string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries_in}")
48string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}")
49string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}")
50string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_libdirs "${_sdl2_libraries_in}")
51string(REGEX REPLACE "^-L" "" _sdl2_libdirs "${_sdl2_libdirs}")
52string(REGEX REPLACE ";-L" ";" _sdl2_libdirs "${_sdl2_libdirs}")
53list(APPEND _sdl2_libdirs "${SDL2_LIBDIR}")
54
55# Convert _sdl2_static_private_libs to list and keep only libraries + library directories
56string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}")
57string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
58string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
59string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sdl2_static_private_libs_in}")
60string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
61string(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
64if(SDL2_NO_MWINDOWS)
65 list(REMOVE_ITEM _sdl2_libraries "-mwindows")
66endif()
67
68if(_sdl2_libraries MATCHES ".*SDL2main.*")
69 list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
70 list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
71endif()
72
73set(_sdl2main_library ${SDL2_LIBDIR}/libSDL2main.a)
74if(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)
102else()
103 set(SDL2_SDL2main_FOUND FALSE)
104endif()
105unset(_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`
110set(_sdl2_link_libraries ${_sdl2_libraries})
111list(REMOVE_ITEM _sdl2_link_libraries SDL2 SDL2main mingw32 cygwin)
112
113if(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)
136else()
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)
156endif()
157
158set(_sdl2_static "${SDL2_LIBDIR}/libSDL2.a")
159if(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)
174else()
175 set(SDL2_SDL2-static_FOUND FALSE)
176endif()
177unset(_sdl2_static)
178
179unset(_sdl2_link_libraries)
180
181set(_sdl2test_library "${SDL2_LIBDIR}/libSDL2_test.a")
182if(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)
195else()
196 set(SDL2_SDL2test_FOUND FALSE)
197endif()
198unset(_sdl2test_library)
199
200# Copied from `configure_package_config_file`
201macro(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()
209endmacro()
210
211check_required_components(SDL2)
212
213# Create SDL2::SDL2 alias for static-only builds
214if(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()
222endif()