Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/libsdl2/, media-libs/libsdl2/files/
Date: Wed, 31 Aug 2022 02:04:36
Message-Id: 1661911246.31d9717391661df9bfc70bd4fb1902730961f115.sam@gentoo
1 commit: 31d9717391661df9bfc70bd4fb1902730961f115
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 31 02:00:17 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 31 02:00:46 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31d97173
7
8 media-libs/libsdl2: backport CMake config file fixes
9
10 Fixes build of consumers/reverse dependencies using CMake
11 to discover SDL2.
12
13 devilutionx failed like:
14 ```
15 -- Configuring done
16 CMake Error at CMakeLists.txt:243 (target_link_libraries):
17 Target "devilutionx" links to:
18
19 SDL2::SDL2main
20
21 but the target was not found. Possible reasons include:
22
23 * There is a typo in the target name.
24 * A find_package call is missing for an IMPORTED target.
25 * An ALIAS target is missing.
26 ```
27
28 See https://forums.gentoo.org/viewtopic-p-8741497.html.
29
30 Signed-off-by: Sam James <sam <AT> gentoo.org>
31
32 .../files/libsdl2-2.24.0-cmake-target-fixes.patch | 145 +++++++++++++
33 media-libs/libsdl2/libsdl2-2.24.0-r1.ebuild | 228 +++++++++++++++++++++
34 2 files changed, 373 insertions(+)
35
36 diff --git a/media-libs/libsdl2/files/libsdl2-2.24.0-cmake-target-fixes.patch b/media-libs/libsdl2/files/libsdl2-2.24.0-cmake-target-fixes.patch
37 new file mode 100644
38 index 000000000000..59353b98e06d
39 --- /dev/null
40 +++ b/media-libs/libsdl2/files/libsdl2-2.24.0-cmake-target-fixes.patch
41 @@ -0,0 +1,145 @@
42 +https://github.com/libsdl-org/SDL/commit/329794daf3f58088b56a64bdfa36b2021903be20
43 +https://github.com/libsdl-org/SDL/commit/62302d08f13ca5303135505c6b355afbbf069745
44 +
45 +From: Anonymous Maarten <anonymous.maarten@×××××.com>
46 +Date: Sun, 21 Aug 2022 04:03:32 +0200
47 +Subject: [PATCH] cmake: add library directories & pthread to imported targets
48 + of sdl2-config.cmake
49 +
50 +This fixes linking to SDL2::SDL2-static on systems where external libraries such as X11 are not in a standard location.
51 +Pthread also needs special care.
52 +--- a/sdl2-config.cmake.in
53 ++++ b/sdl2-config.cmake.in
54 +@@ -39,18 +39,25 @@ unset(bindir)
55 + unset(libdir)
56 + unset(includedir)
57 +
58 +-set(_sdl2_libraries "@SDL_LIBS@")
59 +-set(_sdl2_static_private_libs "@SDL_STATIC_LIBS@")
60 ++set(_sdl2_libraries_in "@SDL_LIBS@")
61 ++set(_sdl2_static_private_libs_in "@SDL_STATIC_LIBS@")
62 +
63 +-# Convert _sdl2_libraries to list and keep only libraries
64 +-string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries}")
65 ++# Convert _sdl2_libraries to list and keep only libraries + library directories
66 ++string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries_in}")
67 + string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}")
68 + string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}")
69 ++string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_libdirs "${_sdl2_libraries_in}")
70 ++string(REGEX REPLACE "^-L" "" _sdl2_libdirs "${_sdl2_libdirs}")
71 ++string(REGEX REPLACE ";-L" ";" _sdl2_libdirs "${_sdl2_libdirs}")
72 ++list(APPEND _sdl2_libdirs "${SDL2_LIBDIR}")
73 +
74 +-# Convert _sdl2_static_private_libs to list and keep only libraries
75 +-string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
76 ++# Convert _sdl2_static_private_libs to list and keep only libraries + library directories
77 ++string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}")
78 + string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
79 + string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
80 ++string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sdl2_static_private_libs_in}")
81 ++string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
82 ++string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
83 +
84 + if(_sdl2_libraries MATCHES ".*SDL2main.*")
85 + list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
86 +@@ -103,6 +110,7 @@ if(WIN32)
87 + set_target_properties(SDL2::SDL2 PROPERTIES
88 + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
89 + INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}"
90 ++ INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
91 + IMPORTED_LINK_INTERFACE_LANGUAGES "C"
92 + IMPORTED_IMPLIB "${_sdl2_implib}"
93 + IMPORTED_LOCATION "${_sdl2_dll}"
94 +@@ -122,6 +130,7 @@ else()
95 + set_target_properties(SDL2::SDL2 PROPERTIES
96 + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
97 + INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries}"
98 ++ INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
99 + IMPORTED_LINK_INTERFACE_LANGUAGES "C"
100 + IMPORTED_LOCATION "${_sdl2_shared}"
101 + )
102 +@@ -142,6 +151,7 @@ if(EXISTS "${_sdl2_static}")
103 + IMPORTED_LOCATION "${_sdl2_static}"
104 + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
105 + INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries};${_sdl2_static_private_libs}"
106 ++ INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs};${_sdl2_static_private_libdirs}"
107 + IMPORTED_LINK_INTERFACE_LANGUAGES "C"
108 + )
109 + endif()
110 +
111 +From: Anonymous Maarten <anonymous.maarten@×××××.com>
112 +Date: Wed, 24 Aug 2022 04:14:52 +0200
113 +Subject: [PATCH] cmake: always create SDL2::SDL2main target in autotools'
114 + cmake config script
115 +
116 +--- a/sdl2-config.cmake.in
117 ++++ b/sdl2-config.cmake.in
118 +@@ -62,38 +62,39 @@ string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_priv
119 + if(_sdl2_libraries MATCHES ".*SDL2main.*")
120 + list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
121 + list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
122 +- set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
123 +- if(EXISTS "${_sdl2main_library}")
124 +- set(SDL2MAIN_LIBRARY SDL2::SDL2main)
125 +- if(NOT TARGET SDL2::SDL2main)
126 +- add_library(SDL2::SDL2main STATIC IMPORTED)
127 +- set_target_properties(SDL2::SDL2main
128 +- PROPERTIES
129 +- IMPORTED_LOCATION "${_sdl2main_library}"
130 +- )
131 +- if(WIN32)
132 +- # INTERFACE_LINK_OPTIONS needs CMake 3.13
133 +- cmake_minimum_required(VERSION 3.13)
134 +- # Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker.
135 +- if(CMAKE_SIZEOF_VOID_P EQUAL 4)
136 +- set_target_properties(SDL2::SDL2main
137 +- PROPERTIES
138 +- INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16"
139 +- )
140 +- else()
141 +- set_target_properties(SDL2::SDL2main
142 +- PROPERTIES
143 +- INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain"
144 +- )
145 +- endif()
146 ++endif()
147 ++
148 ++set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
149 ++if(EXISTS "${_sdl2main_library}")
150 ++ set(SDL2MAIN_LIBRARY SDL2::SDL2main)
151 ++ if(NOT TARGET SDL2::SDL2main)
152 ++ add_library(SDL2::SDL2main STATIC IMPORTED)
153 ++ set_target_properties(SDL2::SDL2main
154 ++ PROPERTIES
155 ++ IMPORTED_LOCATION "${_sdl2main_library}"
156 ++ )
157 ++ if(WIN32)
158 ++ # INTERFACE_LINK_OPTIONS needs CMake 3.13
159 ++ cmake_minimum_required(VERSION 3.13)
160 ++ # Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker.
161 ++ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
162 ++ set_target_properties(SDL2::SDL2main
163 ++ PROPERTIES
164 ++ INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16"
165 ++ )
166 ++ else()
167 ++ set_target_properties(SDL2::SDL2main
168 ++ PROPERTIES
169 ++ INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain"
170 ++ )
171 + endif()
172 + endif()
173 +- set(SDL2_SDL2main_FOUND TRUE)
174 +- else()
175 +- set(SDL2_SDL2main_FOUND FALSE)
176 + endif()
177 +- unset(_sdl2main_library)
178 ++ set(SDL2_SDL2main_FOUND TRUE)
179 ++else()
180 ++ set(SDL2_SDL2main_FOUND FALSE)
181 + endif()
182 ++unset(_sdl2main_library)
183 +
184 + # Remove SDL2 since this is the "central" library
185 + # Remove SDL2main since this will be provided by SDL2::SDL2main (if available)
186 +
187
188 diff --git a/media-libs/libsdl2/libsdl2-2.24.0-r1.ebuild b/media-libs/libsdl2/libsdl2-2.24.0-r1.ebuild
189 new file mode 100644
190 index 000000000000..6d4ad20ae903
191 --- /dev/null
192 +++ b/media-libs/libsdl2/libsdl2-2.24.0-r1.ebuild
193 @@ -0,0 +1,228 @@
194 +# Copyright 1999-2022 Gentoo Authors
195 +# Distributed under the terms of the GNU General Public License v2
196 +
197 +EAPI=8
198 +
199 +inherit autotools flag-o-matic multilib-minimal
200 +
201 +MY_P="SDL2-${PV}"
202 +DESCRIPTION="Simple Direct Media Layer"
203 +HOMEPAGE="https://www.libsdl.org/"
204 +SRC_URI="https://www.libsdl.org/release/${MY_P}.tar.gz"
205 +
206 +LICENSE="ZLIB"
207 +SLOT="0"
208 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
209 +
210 +IUSE="alsa aqua cpu_flags_ppc_altivec cpu_flags_x86_3dnow cpu_flags_x86_mmx cpu_flags_x86_sse cpu_flags_x86_sse2 custom-cflags dbus doc fcitx4 gles1 gles2 haptic ibus jack +joystick kms libsamplerate nas opengl oss pipewire pulseaudio sndio +sound static-libs +threads udev +video video_cards_vc4 vulkan wayland X xscreensaver"
211 +REQUIRED_USE="
212 + alsa? ( sound )
213 + fcitx4? ( dbus )
214 + gles1? ( video )
215 + gles2? ( video )
216 + haptic? ( joystick )
217 + ibus? ( dbus )
218 + jack? ( sound )
219 + nas? ( sound )
220 + opengl? ( video )
221 + pulseaudio? ( sound )
222 + sndio? ( sound )
223 + vulkan? ( video )
224 + wayland? ( gles2 )
225 + xscreensaver? ( X )"
226 +
227 +CDEPEND="
228 + alsa? ( >=media-libs/alsa-lib-1.0.27.2[${MULTILIB_USEDEP}] )
229 + dbus? ( >=sys-apps/dbus-1.6.18-r1[${MULTILIB_USEDEP}] )
230 + fcitx4? ( app-i18n/fcitx:4 )
231 + gles1? ( media-libs/mesa[${MULTILIB_USEDEP},gles1] )
232 + gles2? ( >=media-libs/mesa-9.1.6[${MULTILIB_USEDEP},gles2] )
233 + ibus? ( app-i18n/ibus )
234 + jack? ( virtual/jack[${MULTILIB_USEDEP}] )
235 + kms? (
236 + >=x11-libs/libdrm-2.4.82[${MULTILIB_USEDEP}]
237 + >=media-libs/mesa-9.0.0[${MULTILIB_USEDEP},gbm(+)]
238 + )
239 + libsamplerate? ( media-libs/libsamplerate[${MULTILIB_USEDEP}] )
240 + nas? (
241 + >=media-libs/nas-1.9.4[${MULTILIB_USEDEP}]
242 + >=x11-libs/libXt-1.1.4[${MULTILIB_USEDEP}]
243 + )
244 + opengl? (
245 + >=virtual/opengl-7.0-r1[${MULTILIB_USEDEP}]
246 + >=virtual/glu-9.0-r1[${MULTILIB_USEDEP}]
247 + )
248 + pipewire? ( media-video/pipewire:=[${MULTILIB_USEDEP}] )
249 + pulseaudio? ( >=media-sound/pulseaudio-2.1-r1[${MULTILIB_USEDEP}] )
250 + sndio? ( media-sound/sndio:=[${MULTILIB_USEDEP}] )
251 + udev? ( >=virtual/libudev-208:=[${MULTILIB_USEDEP}] )
252 + wayland? (
253 + >=dev-libs/wayland-1.20[${MULTILIB_USEDEP}]
254 + >=media-libs/mesa-9.1.6[${MULTILIB_USEDEP},egl(+),gles2,wayland]
255 + >=x11-libs/libxkbcommon-0.2.0[${MULTILIB_USEDEP}]
256 + )
257 + X? (
258 + >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
259 + >=x11-libs/libXcursor-1.1.14[${MULTILIB_USEDEP}]
260 + >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
261 + >=x11-libs/libXfixes-6.0.0[${MULTILIB_USEDEP}]
262 + >=x11-libs/libXi-1.7.2[${MULTILIB_USEDEP}]
263 + >=x11-libs/libXrandr-1.4.2[${MULTILIB_USEDEP}]
264 + xscreensaver? ( >=x11-libs/libXScrnSaver-1.2.2-r1[${MULTILIB_USEDEP}] )
265 + )"
266 +RDEPEND="${CDEPEND}
267 + vulkan? ( media-libs/vulkan-loader )"
268 +DEPEND="${CDEPEND}
269 + ibus? ( dev-libs/glib:2[${MULTILIB_USEDEP}] )
270 + vulkan? ( dev-util/vulkan-headers )
271 + X? ( x11-base/xorg-proto )
272 +"
273 +BDEPEND="
274 + virtual/pkgconfig
275 + doc? (
276 + app-doc/doxygen
277 + media-gfx/graphviz
278 + )
279 + wayland? ( >=dev-util/wayland-scanner-1.20 )
280 +"
281 +
282 +MULTILIB_WRAPPED_HEADERS=(
283 + /usr/include/SDL2/SDL_config.h
284 + /usr/include/SDL2/SDL_platform.h
285 + /usr/include/SDL2/begin_code.h
286 + /usr/include/SDL2/close_code.h
287 +)
288 +
289 +PATCHES=(
290 + "${FILESDIR}"/${PN}-2.0.16-static-libs.patch
291 + "${FILESDIR}"/${P}-cmake-target-fixes.patch
292 +)
293 +
294 +S="${WORKDIR}/${MY_P}"
295 +
296 +src_prepare() {
297 + default
298 +
299 + # Unbundle some headers.
300 + rm -r src/video/khronos || die
301 + ln -s "${ESYSROOT}/usr/include" src/video/khronos || die
302 +
303 + # SDL seems to customize SDL_config.h.in to remove macros like
304 + # PACKAGE_NAME. Add AT_NOEAUTOHEADER="yes" to prevent those macros from
305 + # being reintroduced.
306 + # https://bugs.gentoo.org/764959
307 + AT_NOEAUTOHEADER="yes" AT_M4DIR="/usr/share/aclocal acinclude" \
308 + eautoreconf
309 +}
310 +
311 +multilib_src_configure() {
312 + use custom-cflags || strip-flags
313 +
314 + if use ibus; then
315 + local -x IBUS_CFLAGS="-I${ESYSROOT}/usr/include/ibus-1.0 -I${ESYSROOT}/usr/include/glib-2.0 -I${ESYSROOT}/usr/$(get_libdir)/glib-2.0/include"
316 + fi
317 +
318 + # sorted by `./configure --help`
319 + local myeconfargs=(
320 + $(use_enable static-libs static)
321 + --enable-atomic
322 + $(use_enable sound audio)
323 + $(use_enable video)
324 + --enable-render
325 + --enable-events
326 + $(use_enable joystick)
327 + $(use_enable haptic)
328 + --enable-power
329 + --enable-filesystem
330 + $(use_enable threads pthreads)
331 + --enable-timers
332 + --enable-file
333 + --enable-loadso
334 + --enable-cpuinfo
335 + --enable-assembly
336 + $(use_enable cpu_flags_ppc_altivec altivec)
337 + $(use_enable cpu_flags_x86_sse ssemath)
338 + $(use_enable cpu_flags_x86_mmx mmx)
339 + $(use_enable cpu_flags_x86_3dnow 3dnow)
340 + $(use_enable cpu_flags_x86_sse sse)
341 + $(use_enable cpu_flags_x86_sse2 sse2)
342 + $(use_enable oss)
343 + $(use_enable alsa)
344 + --disable-alsa-shared
345 + $(use_enable jack)
346 + --disable-jack-shared
347 + --disable-esd
348 + $(use_enable pipewire)
349 + --disable-pipewire-shared
350 + $(use_enable pulseaudio)
351 + --disable-pulseaudio-shared
352 + --disable-arts
353 + $(use_enable libsamplerate)
354 + $(use_enable nas)
355 + --disable-nas-shared
356 + $(use_enable sndio)
357 + --disable-sndio-shared
358 + $(use_enable sound diskaudio)
359 + $(use_enable sound dummyaudio)
360 + $(use_enable wayland video-wayland)
361 + --disable-wayland-shared
362 + $(use_enable video_cards_vc4 video-rpi)
363 + $(use_enable X video-x11)
364 + --disable-x11-shared
365 + $(use_enable X video-x11-xcursor)
366 + $(use_enable X video-x11-xdbe)
367 + $(use_enable X video-x11-xfixes)
368 + $(use_enable X video-x11-xinput)
369 + $(use_enable X video-x11-xrandr)
370 + $(use_enable xscreensaver video-x11-scrnsaver)
371 + $(use_enable X video-x11-xshape)
372 + $(use_enable aqua video-cocoa)
373 + --disable-video-directfb
374 + --disable-fusionsound
375 + --disable-fusionsound-shared
376 + $(use_enable kms video-kmsdrm)
377 + --disable-kmsdrm-shared
378 + $(use_enable video video-dummy)
379 + $(use_enable opengl video-opengl)
380 + $(use_enable gles1 video-opengles1)
381 + $(use_enable gles2 video-opengles2)
382 + $(use_enable vulkan video-vulkan)
383 + $(use_enable udev libudev)
384 + $(use_enable dbus)
385 + $(use_enable fcitx4 fcitx)
386 + $(use_enable ibus)
387 + --disable-directx
388 + --disable-rpath
389 + --disable-render-d3d
390 + $(use_with X x)
391 + )
392 +
393 + ECONF_SOURCE="${S}" \
394 + econf "${myeconfargs[@]}"
395 +}
396 +
397 +multilib_src_compile() {
398 + emake V=1
399 +}
400 +
401 +src_compile() {
402 + multilib-minimal_src_compile
403 +
404 + if use doc; then
405 + cd docs || die
406 + doxygen || die
407 + fi
408 +}
409 +
410 +multilib_src_install() {
411 + emake DESTDIR="${D}" install
412 +}
413 +
414 +multilib_src_install_all() {
415 + # Do not delete the static .a libraries here as some are
416 + # mandatory. They may be needed even when linking dynamically.
417 + find "${ED}" -type f -name "*.la" -delete || die
418 +
419 + dodoc {BUGS,CREDITS,README-SDL,TODO,WhatsNew}.txt README.md docs/README*.md
420 + use doc && dodoc -r docs/output/html/
421 +}