diff options
Diffstat (limited to 'src/contrib/SDL-3.2.20/cmake/sdltargets.cmake')
-rw-r--r-- | src/contrib/SDL-3.2.20/cmake/sdltargets.cmake | 386 |
1 files changed, 386 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake b/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake new file mode 100644 index 0000000..d658eb3 --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/sdltargets.cmake | |||
@@ -0,0 +1,386 @@ | |||
1 | add_library(SDL3-collector INTERFACE) | ||
2 | add_library(SDL3_test-collector INTERFACE) | ||
3 | |||
4 | # Use sdl_glob_sources to add glob sources to SDL3-shared, to SDL3-static, or to both. | ||
5 | function(sdl_glob_sources) | ||
6 | cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN}) | ||
7 | file(GLOB shared_sources ${ARGS_SHARED}) | ||
8 | file(GLOB static_sources ${ARGS_STATIC}) | ||
9 | file(GLOB both_sources ${ARGS_UNPARSED_ARGUMENTS}) | ||
10 | if(TARGET SDL3-shared) | ||
11 | target_sources(SDL3-shared PRIVATE ${shared_sources} ${both_sources}) | ||
12 | endif() | ||
13 | if(TARGET SDL3-static) | ||
14 | target_sources(SDL3-static PRIVATE ${static_sources} ${both_sources}) | ||
15 | endif() | ||
16 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${shared_sources} ${static_sources} ${both_sources}) | ||
17 | endfunction() | ||
18 | |||
19 | # Use sdl_sources to add sources to SDL3-shared, to SDL3-static, or to both. | ||
20 | function(sdl_sources) | ||
21 | cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN}) | ||
22 | if(TARGET SDL3-shared) | ||
23 | target_sources(SDL3-shared PRIVATE ${ARGS_SHARED} ${ARGS_UNPARSED_ARGUMENTS}) | ||
24 | endif() | ||
25 | if(TARGET SDL3-static) | ||
26 | target_sources(SDL3-static PRIVATE ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS}) | ||
27 | endif() | ||
28 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${ARGS_SHARED} ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS}) | ||
29 | endfunction() | ||
30 | |||
31 | # Use sdl_generic_link_dependency to describe a private dependency. All options are optional. | ||
32 | # Users should use sdl_link_dependency and sdl_test_link_dependency instead | ||
33 | # - SHARED_TARGETS: shared targets to add this dependency to | ||
34 | # - STATIC_TARGETS: static targets to add this dependency to | ||
35 | # - COLLECTOR: target that stores information, for pc and Config.cmake generation. | ||
36 | # - INCLUDES: the include directories of the dependency | ||
37 | # - PKG_CONFIG_PREFIX: name of the prefix, when using the functions of FindPkgConfig | ||
38 | # - PKG_CONFIG_SPECS: pkg-config spec, used as argument for the functions of FindPkgConfig | ||
39 | # - PKG_CONFIG_LIBS: libs that will only end up in the Libs.private of the .pc file | ||
40 | # - PKG_CONFIG_LINK_OPTIONS: ldflags that will only end up in the Libs.private of sdl3.pc | ||
41 | # - CMAKE_MODULE: CMake module name of the dependency, used as argument of find_package | ||
42 | # - LIBS: list of libraries to link to (cmake and pkg-config) | ||
43 | # - LINK_OPTIONS: list of link options (also used in pc file, unless PKG_CONFIG_LINK_OPTION is used) | ||
44 | function(sdl_generic_link_dependency ID) | ||
45 | cmake_parse_arguments(ARGS "" "COLLECTOR" "SHARED_TARGETS;STATIC_TARGETS;INCLUDES;PKG_CONFIG_LINK_OPTIONS;PKG_CONFIG_LIBS;PKG_CONFIG_PREFIX;PKG_CONFIG_SPECS;CMAKE_MODULE;LIBS;LINK_OPTIONS" ${ARGN}) | ||
46 | foreach(target IN LISTS ARGS_SHARED_TARGETS) | ||
47 | if(TARGET ${target}) | ||
48 | target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES}) | ||
49 | target_link_libraries(${target} PRIVATE ${ARGS_LIBS}) | ||
50 | target_link_options(${target} PRIVATE ${ARGS_LINK_OPTIONS}) | ||
51 | endif() | ||
52 | endforeach() | ||
53 | foreach(target IN LISTS ARGS_STATIC_TARGETS) | ||
54 | if(TARGET ${target}) | ||
55 | target_include_directories(${target} SYSTEM PRIVATE ${ARGS_INCLUDES}) | ||
56 | target_link_libraries(${target} PRIVATE ${ARGS_LIBS}) | ||
57 | target_link_options(${target} INTERFACE ${ARGS_LINK_OPTIONS}) | ||
58 | endif() | ||
59 | endforeach() | ||
60 | get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
61 | if(NOT ID IN_LIST ids) | ||
62 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_IDS ${ID}) | ||
63 | endif() | ||
64 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX ${ARGS_PKG_CONFIG_PREFIX}) | ||
65 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS ${ARGS_PKG_CONFIG_SPECS}) | ||
66 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS ${ARGS_PKG_CONFIG_LIBS}) | ||
67 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS ${ARGS_PKG_CONFIG_LINK_OPTIONS}) | ||
68 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS ${ARGS_LIBS}) | ||
69 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS ${ARGS_LINK_OPTIONS}) | ||
70 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE ${ARGS_CMAKE_MODULE}) | ||
71 | set_property(TARGET ${ARGS_COLLECTOR} APPEND PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES ${ARGS_INCLUDES}) | ||
72 | endfunction() | ||
73 | |||
74 | function(sdl_link_dependency ) | ||
75 | sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3-collector SHARED_TARGETS SDL3-shared STATIC_TARGETS SDL3-static) | ||
76 | endfunction() | ||
77 | |||
78 | function(sdl_test_link_dependency ) | ||
79 | sdl_generic_link_dependency(${ARGN} COLLECTOR SDL3_test-collector STATIC_TARGETS SDL3_test) | ||
80 | endfunction() | ||
81 | |||
82 | macro(_get_ARGS_visibility) | ||
83 | set(_conflict FALSE) | ||
84 | set(visibility) | ||
85 | if(ARGS_PRIVATE) | ||
86 | set(visibility PRIVATE) | ||
87 | elseif(ARGS_PUBLIC) | ||
88 | if(visibility) | ||
89 | set(_conflict TRUE) | ||
90 | endif() | ||
91 | set(visibility PUBLIC) | ||
92 | elseif(ARGS_INTERFACE) | ||
93 | if(visibility) | ||
94 | set(_conflict TRUE) | ||
95 | endif() | ||
96 | set(visibility INTERFACE) | ||
97 | endif() | ||
98 | if(_conflict OR NOT visibility) | ||
99 | message(FATAL_ERROR "PRIVATE/PUBLIC/INTERFACE must be used exactly once") | ||
100 | endif() | ||
101 | unset(_conflict) | ||
102 | endmacro() | ||
103 | |||
104 | # Use sdl_link_dependency to add compile definitions to the SDL3 libraries. | ||
105 | function(sdl_compile_definitions) | ||
106 | cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
107 | _get_ARGS_visibility() | ||
108 | if(TARGET SDL3-shared) | ||
109 | target_compile_definitions(SDL3-shared ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
110 | endif() | ||
111 | if(TARGET SDL3-static) | ||
112 | target_compile_definitions(SDL3-static ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
113 | endif() | ||
114 | if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
115 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "${ARGS_UNPARSED_ARGUMENTS}") | ||
116 | endif() | ||
117 | endfunction() | ||
118 | |||
119 | # Use sdl_link_dependency to add compile options to the SDL3 libraries. | ||
120 | function(sdl_compile_options) | ||
121 | cmake_parse_arguments(ARGS "PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
122 | _get_ARGS_visibility() | ||
123 | set(escaped_opts ${ARGS_UNPARSED_ARGUMENTS}) | ||
124 | if(ARGS_NO_EXPORT) | ||
125 | set(escaped_opts "$<BUILD_INTERFACE:${ARGS_UNPARSED_ARGUMENTS}>") | ||
126 | endif() | ||
127 | if(TARGET SDL3-shared) | ||
128 | target_compile_options(SDL3-shared ${visibility} ${escaped_opts}) | ||
129 | endif() | ||
130 | if(TARGET SDL3-static) | ||
131 | target_compile_options(SDL3-static ${visibility} ${escaped_opts}) | ||
132 | endif() | ||
133 | if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
134 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}") | ||
135 | endif() | ||
136 | endfunction() | ||
137 | |||
138 | # Use sdl_link_dependency to add include directories to the SDL3 libraries. | ||
139 | function(sdl_include_directories) | ||
140 | cmake_parse_arguments(ARGS "SYSTEM;BEFORE;AFTER;PRIVATE;PUBLIC;INTERFACE;NO_EXPORT" "" "" ${ARGN}) | ||
141 | set(system "") | ||
142 | if(ARGS_SYSTEM) | ||
143 | set(system "SYSTEM") | ||
144 | endif() | ||
145 | set(before_after ) | ||
146 | if(ARGS_AFTER) | ||
147 | set(before_after "AFTER") | ||
148 | endif() | ||
149 | if(ARGS_BEFORE) | ||
150 | if(before_after) | ||
151 | message(FATAL_ERROR "before and after are exclusive options") | ||
152 | endif() | ||
153 | set(before_after "BEFORE") | ||
154 | endif() | ||
155 | _get_ARGS_visibility() | ||
156 | if(TARGET SDL3-shared) | ||
157 | target_include_directories(SDL3-shared ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
158 | endif() | ||
159 | if(TARGET SDL3-static) | ||
160 | target_include_directories(SDL3-static ${system} ${before_after} ${visibility} ${ARGS_UNPARSED_ARGUMENTS}) | ||
161 | endif() | ||
162 | if(NOT NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE)) | ||
163 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ARGS_UNPARSED_ARGUMENTS}") | ||
164 | endif() | ||
165 | endfunction() | ||
166 | |||
167 | # Use sdl_link_dependency to add link directories to the SDL3 libraries. | ||
168 | function(sdl_link_directories) | ||
169 | if(TARGET SDL3-shared) | ||
170 | target_link_directories(SDL3-shared PRIVATE ${ARGN}) | ||
171 | endif() | ||
172 | if(TARGET SDL3-static) | ||
173 | target_link_directories(SDL3-static INTERFACE ${ARGN}) | ||
174 | endif() | ||
175 | endfunction() | ||
176 | |||
177 | # Use sdl_pc_link_options to add a link option, only visible in sdl3.pc | ||
178 | function(sdl_pc_link_options) | ||
179 | set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS "${ARGN}") | ||
180 | endfunction() | ||
181 | |||
182 | # Use sdl_pc_link_options to add a link option only to SDL3-shared | ||
183 | function(sdl_shared_link_options) | ||
184 | if(TARGET SDL3-shared) | ||
185 | target_link_options(SDL3-shared PRIVATE ${ARGN}) | ||
186 | endif() | ||
187 | endfunction() | ||
188 | |||
189 | # Return minimum list of custom SDL CMake modules, used for finding dependencies of SDL. | ||
190 | function(sdl_cmake_config_required_modules OUTPUT) | ||
191 | set(cmake_modules) | ||
192 | foreach(collector SDL3-collector SDL3_test-collector) | ||
193 | get_property(ids TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
194 | foreach(ID IN LISTS ids) | ||
195 | get_property(CMAKE_MODULE TARGET ${collector} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
196 | if(CMAKE_MODULE) | ||
197 | if(EXISTS "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake") | ||
198 | list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/Find${CMAKE_MODULE}.cmake") | ||
199 | endif() | ||
200 | endif() | ||
201 | endforeach() | ||
202 | if(cmake_modules) | ||
203 | list(APPEND cmake_modules "${SDL3_SOURCE_DIR}/cmake/PkgConfigHelper.cmake") | ||
204 | endif() | ||
205 | endforeach() | ||
206 | set(${OUTPUT} "${cmake_modules}" PARENT_SCOPE) | ||
207 | endfunction() | ||
208 | |||
209 | # Generate string for SDL3Config.cmake, finding all pkg-config dependencies of SDL3. | ||
210 | function(sdl_cmake_config_find_pkg_config_commands OUTPUT) | ||
211 | cmake_parse_arguments(ARGS "" "COLLECTOR;CONFIG_COMPONENT_FOUND_NAME" "" ${ARGN}) | ||
212 | if(NOT ARGS_COLLECTOR OR NOT ARGS_CONFIG_COMPONENT_FOUND_NAME) | ||
213 | message(FATAL_ERROR "COLLECTOR AND CONFIG_COMPONENT_FOUND_NAME are required arguments") | ||
214 | endif() | ||
215 | get_property(ids TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_IDS) | ||
216 | |||
217 | set(static_pkgconfig_deps_checks) | ||
218 | set(static_module_deps_checks) | ||
219 | set(cmake_modules_seen) | ||
220 | |||
221 | foreach(ID IN LISTS ids) | ||
222 | get_property(PKG_CONFIG_PREFIX TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX) | ||
223 | get_property(PKG_CONFIG_SPECS TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
224 | get_property(CMAKE_MODULE TARGET ${ARGS_COLLECTOR} PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
225 | if(CMAKE_MODULE AND NOT CMAKE_MODULE IN_LIST cmake_modules_seen) | ||
226 | list(APPEND static_module_deps_checks | ||
227 | "find_package(${CMAKE_MODULE})" | ||
228 | "if(NOT ${CMAKE_MODULE}_FOUND)" | ||
229 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
230 | "endif()" | ||
231 | ) | ||
232 | list(APPEND cmake_modules_seen ${CMAKE_MODULE}) | ||
233 | endif() | ||
234 | if(PKG_CONFIG_PREFIX AND PKG_CONFIG_SPECS) | ||
235 | string(JOIN " " pkg_config_specs_str ${PKG_CONFIG_SPECS}) | ||
236 | list(APPEND static_pkgconfig_deps_checks | ||
237 | " pkg_check_modules(${PKG_CONFIG_PREFIX} QUIET IMPORTED_TARGET ${pkg_config_specs_str})" | ||
238 | " if(NOT ${PKG_CONFIG_PREFIX}_FOUND)" | ||
239 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
240 | " endif()" | ||
241 | ) | ||
242 | endif() | ||
243 | endforeach() | ||
244 | |||
245 | set(prefix " ") | ||
246 | |||
247 | set(static_module_deps_texts) | ||
248 | if(static_module_deps_checks) | ||
249 | set(static_module_deps_texts | ||
250 | [[set(_original_module_path "${CMAKE_MODULE_PATH}")]] | ||
251 | [[list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")]] | ||
252 | ${static_module_deps_checks} | ||
253 | [[set(CMAKE_MODULE_PATH "${_original_module_path}")]] | ||
254 | [[unset(_original_module_path)]] | ||
255 | ) | ||
256 | endif() | ||
257 | |||
258 | set(static_pkgconfig_deps_texts) | ||
259 | if(static_pkgconfig_deps_checks) | ||
260 | string(JOIN "\n${prefix}" static_deps_texts_str ${static_deps_texts}) | ||
261 | list(APPEND static_pkgconfig_deps_texts | ||
262 | "find_package(PkgConfig)" | ||
263 | "if(PkgConfig_FOUND)" | ||
264 | ${static_pkgconfig_deps_checks} | ||
265 | "else()" | ||
266 | " set(${ARGS_CONFIG_COMPONENT_FOUND_NAME} OFF)" | ||
267 | "endif()" | ||
268 | ) | ||
269 | endif() | ||
270 | |||
271 | set(text) | ||
272 | string(JOIN "\n${prefix}" text ${static_module_deps_texts} ${static_pkgconfig_deps_texts}) | ||
273 | if(text) | ||
274 | set(text "${prefix}${text}") | ||
275 | endif() | ||
276 | |||
277 | set(${OUTPUT} "${text}" PARENT_SCOPE) | ||
278 | endfunction() | ||
279 | |||
280 | # Create sdl3.pc. | ||
281 | function(configure_sdl3_pc) | ||
282 | # Clean up variables for sdl3.pc | ||
283 | if(TARGET SDL3-shared) | ||
284 | set(SDL_PC_SECTION_LIBS_PRIVATE "\nLibs.private:") | ||
285 | else() | ||
286 | set(SDL_PC_SECTION_LIBS_PRIVATE "") | ||
287 | endif() | ||
288 | |||
289 | get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS) | ||
290 | |||
291 | set(private_requires) | ||
292 | set(private_libs) | ||
293 | set(private_ldflags) | ||
294 | |||
295 | foreach(ID IN LISTS ids) | ||
296 | get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
297 | get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
298 | get_property(PKG_CONFIG_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LIBS) | ||
299 | get_property(PKG_CONFIG_LDFLAGS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_LINK_OPTIONS) | ||
300 | get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS) | ||
301 | get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS) | ||
302 | |||
303 | list(APPEND private_requires ${PKG_CONFIG_SPECS}) | ||
304 | list(APPEND private_libs ${PKG_CONFIG_LIBS}) | ||
305 | if(PKG_CONFIG_SPECS OR PKG_CONFIG_LIBS OR PKG_CONFIG_LDFLAGS) | ||
306 | list(APPEND private_ldflags ${PKG_CONFIG_LDFLAGS}) | ||
307 | else() | ||
308 | list(APPEND private_ldflags ${LINK_OPTIONS}) | ||
309 | if(NOT CMAKE_MODULE) | ||
310 | list(APPEND private_libs ${LIBS}) | ||
311 | endif() | ||
312 | endif() | ||
313 | endforeach() | ||
314 | |||
315 | list(TRANSFORM private_libs PREPEND "-l") | ||
316 | set(SDL_PC_STATIC_LIBS ${private_ldflags} ${private_libs}) | ||
317 | list(REMOVE_DUPLICATES SDL_PC_STATIC_LIBS) | ||
318 | string(JOIN " " SDL_PC_STATIC_LIBS ${SDL_PC_STATIC_LIBS}) | ||
319 | |||
320 | string(JOIN " " SDL_PC_PRIVATE_REQUIRES ${private_requires}) | ||
321 | string(REGEX REPLACE "(>=|>|=|<|<=)" [[ \1 ]] SDL_PC_PRIVATE_REQUIRES "${SDL_PC_PRIVATE_REQUIRES}") | ||
322 | |||
323 | get_property(interface_defines TARGET SDL3-collector PROPERTY INTERFACE_COMPILE_DEFINITIONS) | ||
324 | list(TRANSFORM interface_defines PREPEND "-D") | ||
325 | get_property(interface_includes TARGET SDL3-collector PROPERTY INTERFACE_INCLUDE_DIRECTORIES) | ||
326 | list(TRANSFORM interface_includes PREPEND "-I") | ||
327 | set(SDL_PC_CFLAGS ${interface_defines} ${interface_includes}) | ||
328 | string(JOIN " " SDL_PC_CFLAGS ${SDL_PC_CFLAGS}) | ||
329 | |||
330 | get_property(SDL_PC_LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_PC_LINK_OPTIONS) | ||
331 | string(JOIN " " SDL_PC_LIBS ${SDL_PC_LIBS}) | ||
332 | |||
333 | string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_STATIC_LIBS "${SDL_PC_STATIC_LIBS}") | ||
334 | if(NOT SDL_SHARED) | ||
335 | string(REGEX REPLACE "-lSDL3( |$)" "-l${sdl_static_libname} " SDL_PC_LIBS "${SDL_PC_LIBS}") | ||
336 | endif() | ||
337 | if(TARGET SDL3-shared AND TARGET SDL3-static AND NOT sdl_static_libname STREQUAL "SDL3") | ||
338 | message(STATUS "\"pkg-config --static --libs sdl3\" will return invalid information") | ||
339 | endif() | ||
340 | |||
341 | if(SDL_RELOCATABLE) | ||
342 | # Calculate prefix relative to location of sdl3.pc | ||
343 | if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") | ||
344 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") | ||
345 | endif() | ||
346 | file(RELATIVE_PATH SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${CMAKE_INSTALL_PREFIX}/${SDL_PKGCONFIG_INSTALLDIR}" "${CMAKE_INSTALL_PREFIX}") | ||
347 | string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") | ||
348 | set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}") | ||
349 | else() | ||
350 | set(SDL_PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") | ||
351 | endif() | ||
352 | |||
353 | if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") | ||
354 | set(INCLUDEDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_INCLUDEDIR}") | ||
355 | else() | ||
356 | set(INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") | ||
357 | endif() | ||
358 | if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") | ||
359 | set(LIBDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_LIBDIR}") | ||
360 | else() | ||
361 | set(LIBDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_LIBDIR}") | ||
362 | endif() | ||
363 | |||
364 | configure_file("${SDL3_SOURCE_DIR}/cmake/sdl3.pc.in" "${SDL3_BINARY_DIR}/sdl3.pc" @ONLY) | ||
365 | endfunction() | ||
366 | |||
367 | # Write list of dependencies to output. Only visible when configuring with --log-level=DEBUG. | ||
368 | function(debug_show_sdl_deps) | ||
369 | get_property(ids TARGET SDL3-collector PROPERTY SDL3-collector PROPERTY INTERFACE_SDL_DEP_IDS) | ||
370 | |||
371 | foreach(ID IN LISTS ids) | ||
372 | message(DEBUG "- id: ${ID}") | ||
373 | get_property(INCLUDES TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_INCLUDES) | ||
374 | get_property(CMAKE_MODULE TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_CMAKE_MODULE) | ||
375 | get_property(PKG_CONFIG_PREFIX TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_PREFIX) | ||
376 | get_property(PKG_CONFIG_SPECS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_PKG_CONFIG_SPECS) | ||
377 | get_property(LIBS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LIBS) | ||
378 | get_property(LINK_OPTIONS TARGET SDL3-collector PROPERTY INTERFACE_SDL_DEP_${ID}_LINK_OPTIONS) | ||
379 | message(DEBUG " INCLUDES: ${INCLUDES}") | ||
380 | message(DEBUG " CMAKE_MODULE: ${CMAKE_MODULE}") | ||
381 | message(DEBUG " PKG_CONFIG_PREFIX: ${PKG_CONFIG_PREFIX}") | ||
382 | message(DEBUG " PKG_CONFIG_SPECS: ${PKG_CONFIG_SPECS}") | ||
383 | message(DEBUG " LIBS: ${LIBS}") | ||
384 | message(DEBUG " LINK_OPTIONS: ${LINK_OPTIONS}") | ||
385 | endforeach() | ||
386 | endfunction() | ||