cmake: Fix static linking to dependencies with "-" in library name

When SDL is built with Wayland support on Linux, and Wayland libraries
are linked as dependencies instead of being loaded with dlopen(), its
dependencies will include libraries whose names contain a dash, like
`-lwayland-client` and `-ldecor-0`. Don't replace such libraries with
`-lwayland` and `-ldecor`: those don't exist and linking them will fail.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2022-06-13 11:51:41 +01:00 committed by Sam Lantinga
parent bdf141335c
commit 7321537971
1 changed files with 2 additions and 2 deletions

View File

@ -53,12 +53,12 @@ set(_sdl2_libraries "@SDL_LIBS@")
set(_sdl2_static_private_libs "@SDL_STATIC_LIBS@") set(_sdl2_static_private_libs "@SDL_STATIC_LIBS@")
# Convert _sdl2_libraries to list and keep only libraries # Convert _sdl2_libraries to list and keep only libraries
string(REGEX MATCHALL "-[lm]([a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries}") string(REGEX MATCHALL "-[lm]([-a-zA-Z0-9._]+)" _sdl2_libraries "${_sdl2_libraries}")
string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}") string(REGEX REPLACE "^-l" "" _sdl2_libraries "${_sdl2_libraries}")
string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}") string(REGEX REPLACE ";-l" ";" _sdl2_libraries "${_sdl2_libraries}")
# Convert _sdl2_static_private_libs to list and keep only libraries # Convert _sdl2_static_private_libs to list and keep only libraries
string(REGEX MATCHALL "(-[lm]([a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2_static_private_libs "${_sdl2_static_private_libs}") string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}") string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}")
string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}") string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}")