cmake: fix a bunch of things to properly link without LOADSO enabled.

The wrong logic, copy/pasted to a bunch of places, would correctly disable
the dynamic loading but fail to specify the libraries that SDL would now need
to explicitly link against.
This commit is contained in:
Ryan C. Gordon 2021-08-23 23:59:54 -04:00
parent abba181118
commit fff421f4b8
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 100 additions and 114 deletions

View File

@ -101,14 +101,13 @@ macro(CheckALSA)
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c) file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
set(SDL_AUDIO_DRIVER_ALSA 1) set(SDL_AUDIO_DRIVER_ALSA 1)
if(ALSA_SHARED) if(ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading") message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
else() endif()
if(ALSA_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("asound") FindLibraryAndSONAME("asound")
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
set(HAVE_ALSA_SHARED TRUE) set(HAVE_ALSA_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LIBS asound) list(APPEND EXTRA_LIBS asound)
endif() endif()
@ -131,14 +130,13 @@ macro(CheckPipewire)
set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES})
set(SDL_AUDIO_DRIVER_PIPEWIRE 1) set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
if(PIPEWIRE_SHARED) if(PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading") message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
else() endif()
if(PIPEWIRE_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("pipewire-0.3") FindLibraryAndSONAME("pipewire-0.3")
set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
set(HAVE_PIPEWIRE_SHARED TRUE) set(HAVE_PIPEWIRE_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
endif() endif()
@ -162,14 +160,13 @@ macro(CheckPulseAudio)
set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1) set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
if(PULSEAUDIO_SHARED) if(PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading") message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
else() endif()
if(PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("pulse-simple") FindLibraryAndSONAME("pulse-simple")
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
set(HAVE_PULSEAUDIO_SHARED TRUE) set(HAVE_PULSEAUDIO_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
endif() endif()
@ -192,14 +189,13 @@ macro(CheckJACK)
set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES})
set(SDL_AUDIO_DRIVER_JACK 1) set(SDL_AUDIO_DRIVER_JACK 1)
list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
if(JACK_SHARED) if(JACK_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading") message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
else() endif()
if(JACK_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("jack") FindLibraryAndSONAME("jack")
set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
set(HAVE_JACK_SHARED TRUE) set(HAVE_JACK_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
endif() endif()
@ -222,14 +218,13 @@ macro(CheckESD)
set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
set(SDL_AUDIO_DRIVER_ESD 1) set(SDL_AUDIO_DRIVER_ESD 1)
list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
if(ESD_SHARED) if(ESD_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading") message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
else() endif()
if(ESD_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(esd) FindLibraryAndSONAME(esd)
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
set(HAVE_ESD_SHARED TRUE) set(HAVE_ESD_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
endif() endif()
@ -256,15 +251,14 @@ macro(CheckARTS)
set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
set(SDL_AUDIO_DRIVER_ARTS 1) set(SDL_AUDIO_DRIVER_ARTS 1)
set(HAVE_ARTS TRUE) set(HAVE_ARTS TRUE)
if(ARTS_SHARED) if(ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading") message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
else() endif()
if(ARTS_SHARED AND HAVE_SDL_LOADSO)
# TODO # TODO
FindLibraryAndSONAME(artsc) FindLibraryAndSONAME(artsc)
set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
set(HAVE_ARTS_SHARED TRUE) set(HAVE_ARTS_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS}) list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
endif() endif()
@ -288,14 +282,13 @@ macro(CheckNAS)
file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c) file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
set(SDL_AUDIO_DRIVER_NAS 1) set(SDL_AUDIO_DRIVER_NAS 1)
if(NAS_SHARED) if(NAS_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic NAS loading") message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
else() endif()
if(NAS_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("audio") FindLibraryAndSONAME("audio")
set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
set(HAVE_NAS_SHARED TRUE) set(HAVE_NAS_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LIBS ${D_NAS_LIB}) list(APPEND EXTRA_LIBS ${D_NAS_LIB})
endif() endif()
@ -319,14 +312,13 @@ macro(CheckSNDIO)
file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c) file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
set(SDL_AUDIO_DRIVER_SNDIO 1) set(SDL_AUDIO_DRIVER_SNDIO 1)
if(SNDIO_SHARED) if(SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic sndio loading") message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
else() endif()
if(SNDIO_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("sndio") FindLibraryAndSONAME("sndio")
set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
set(HAVE_SNDIO_SHARED TRUE) set(HAVE_SNDIO_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LIBS ${D_SNDIO_LIB}) list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
endif() endif()
@ -349,14 +341,13 @@ macro(CheckFusionSound)
set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES}) set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
set(SDL_AUDIO_DRIVER_FUSIONSOUND 1) set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
if(FUSIONSOUND_SHARED) if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading") message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
else() endif()
if(FUSIONSOUND_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("fusionsound") FindLibraryAndSONAME("fusionsound")
set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
set(HAVE_FUSIONSOUND_SHARED TRUE) set(HAVE_FUSIONSOUND_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
endif() endif()
@ -375,14 +366,13 @@ macro(CheckLibSampleRate)
check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H) check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
if(HAVE_LIBSAMPLERATE_H) if(HAVE_LIBSAMPLERATE_H)
set(HAVE_LIBSAMPLERATE TRUE) set(HAVE_LIBSAMPLERATE TRUE)
if(LIBSAMPLERATE_SHARED) if(LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading") message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
else() endif()
if(LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("samplerate") FindLibraryAndSONAME("samplerate")
set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"") set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
set(HAVE_LIBSAMPLERATE_SHARED TRUE) set(HAVE_LIBSAMPLERATE_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS -lsamplerate) list(APPEND EXTRA_LDFLAGS -lsamplerate)
endif() endif()
@ -668,10 +658,10 @@ macro(CheckWayland)
set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1) set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
endif() endif()
if(WAYLAND_SHARED) if(WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading") message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
else() endif()
if(WAYLAND_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(wayland-client) FindLibraryAndSONAME(wayland-client)
FindLibraryAndSONAME(wayland-egl) FindLibraryAndSONAME(wayland-egl)
FindLibraryAndSONAME(wayland-cursor) FindLibraryAndSONAME(wayland-cursor)
@ -681,7 +671,6 @@ macro(CheckWayland)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
set(HAVE_WAYLAND_SHARED TRUE) set(HAVE_WAYLAND_SHARED TRUE)
endif()
else() else()
set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS}) set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
endif() endif()
@ -693,14 +682,13 @@ macro(CheckWayland)
set(HAVE_LIBDECOR_H 1) set(HAVE_LIBDECOR_H 1)
link_directories(${LIBDECOR_LIBRARY_DIRS}) link_directories(${LIBDECOR_LIBRARY_DIRS})
include_directories(${LIBDECOR_INCLUDE_DIRS}) include_directories(${LIBDECOR_INCLUDE_DIRS})
if(LIBDECOR_SHARED) if(LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading") message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
else() endif()
if(LIBDECOR_SHARED AND HAVE_SDL_LOADSO)
set(HAVE_LIBDECOR_SHARED TRUE) set(HAVE_LIBDECOR_SHARED TRUE)
FindLibraryAndSONAME(decor-0) FindLibraryAndSONAME(decor-0)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
endif()
else() else()
set(EXTRA_LIBS ${LIBDECOR_LIBRARIES} ${EXTRA_LIBS}) set(EXTRA_LIBS ${LIBDECOR_LIBRARIES} ${EXTRA_LIBS})
endif() endif()
@ -745,14 +733,13 @@ macro(CheckDirectFB)
set(SDL_VIDEO_DRIVER_DIRECTFB 1) set(SDL_VIDEO_DRIVER_DIRECTFB 1)
set(SDL_VIDEO_RENDER_DIRECTFB 1) set(SDL_VIDEO_RENDER_DIRECTFB 1)
list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS}) list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
if(DIRECTFB_SHARED) if(DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading") message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
else() endif()
if(DIRECTFB_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME("directfb") FindLibraryAndSONAME("directfb")
set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
set(HAVE_DIRECTFB_SHARED TRUE) set(HAVE_DIRECTFB_SHARED TRUE)
endif()
else() else()
list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS}) list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
endif() endif()
@ -1242,16 +1229,15 @@ macro(CheckKMSDRM)
set(SDL_VIDEO_DRIVER_KMSDRM 1) set(SDL_VIDEO_DRIVER_KMSDRM 1)
if(KMSDRM_SHARED) if(KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
if(NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading") message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
else() endif()
if(KMSDRM_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(drm) FindLibraryAndSONAME(drm)
FindLibraryAndSONAME(gbm) FindLibraryAndSONAME(gbm)
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
set(HAVE_KMSDRM_SHARED TRUE) set(HAVE_KMSDRM_SHARED TRUE)
endif()
else() else()
set(EXTRA_LIBS ${KMSDRM_LIBRARIES} ${EXTRA_LIBS}) set(EXTRA_LIBS ${KMSDRM_LIBRARIES} ${EXTRA_LIBS})
endif() endif()