Check result of FindLibraryAndSONAME before use

This commit is contained in:
Anonymous Maarten 2022-06-15 03:16:28 +02:00 committed by Ozkan Sezer
parent 8a2c6b604c
commit 32df5aeb3d
1 changed files with 33 additions and 31 deletions

View File

@ -111,8 +111,8 @@ macro(CheckALSA)
if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_ALSA_SHARED AND 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")
endif() endif()
if(SDL_ALSA_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("asound")
FindLibraryAndSONAME("asound") if(SDL_ALSA_SHARED AND ASOUND_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -140,8 +140,8 @@ macro(CheckPipewire)
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_PIPEWIRE_SHARED AND 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")
endif() endif()
if(SDL_PIPEWIRE_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("pipewire-0.3")
FindLibraryAndSONAME("pipewire-0.3") if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -169,8 +169,8 @@ macro(CheckPulseAudio)
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_PULSEAUDIO_SHARED AND 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")
endif() endif()
if(SDL_PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("pulse-simple")
FindLibraryAndSONAME("pulse-simple") if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -198,8 +198,8 @@ macro(CheckJACK)
if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_JACK_SHARED AND 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")
endif() endif()
if(SDL_JACK_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("jack")
FindLibraryAndSONAME("jack") if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -227,8 +227,8 @@ macro(CheckESD)
if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_ESD_SHARED AND 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")
endif() endif()
if(SDL_ESD_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME(esd)
FindLibraryAndSONAME(esd) if(SDL_ESD_SHARED AND ESD_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -260,9 +260,9 @@ macro(CheckARTS)
if(SDL_ARTS_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_ARTS_SHARED AND 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")
endif() endif()
if(SDL_ARTS_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME(artsc)
if(SDL_ARTS_SHARED AND ARTSC_LIB AND HAVE_SDL_LOADSO)
# TODO # TODO
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)
else() else()
@ -291,8 +291,8 @@ macro(CheckNAS)
if(SDL_NAS_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_NAS_SHARED AND 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")
endif() endif()
if(SDL_NAS_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("audio")
FindLibraryAndSONAME("audio") if(SDL_NAS_SHARED AND AUDIO_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -321,8 +321,8 @@ macro(CheckSNDIO)
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_SNDIO_SHARED AND 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")
endif() endif()
if(SDL_SNDIO_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("sndio")
FindLibraryAndSONAME("sndio") if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -350,8 +350,8 @@ macro(CheckFusionSound)
if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO) if(FUSIONSOUND_SHARED AND 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")
endif() endif()
if(FUSIONSOUND_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("fusionsound")
FindLibraryAndSONAME("fusionsound") if(FUSIONSOUND_SHARED AND FUSIONSOUND_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -375,8 +375,8 @@ macro(CheckLibSampleRate)
if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_LIBSAMPLERATE_SHARED AND 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")
endif() endif()
if(SDL_LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("samplerate")
FindLibraryAndSONAME("samplerate") if(SDL_LIBSAMPLERATE_SHARED AND SAMPLERATE_LIB AND HAVE_SDL_LOADSO)
set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"") set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
set(HAVE_LIBSAMPLERATE_SHARED TRUE) set(HAVE_LIBSAMPLERATE_SHARED TRUE)
else() else()
@ -459,7 +459,7 @@ macro(CheckX11)
else() else()
set(HAVE_X11_SHARED TRUE) set(HAVE_X11_SHARED TRUE)
endif() endif()
if(HAVE_X11_SHARED) if(HAVE_X11_SHARED AND X11_LIB AND XEXT_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
else() else()
@ -662,11 +662,11 @@ macro(CheckWayland)
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_WAYLAND_SHARED AND 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")
endif() endif()
if(SDL_WAYLAND_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME(wayland-client)
FindLibraryAndSONAME(wayland-client) FindLibraryAndSONAME(wayland-egl)
FindLibraryAndSONAME(wayland-egl) FindLibraryAndSONAME(wayland-cursor)
FindLibraryAndSONAME(wayland-cursor) FindLibraryAndSONAME(xkbcommon)
FindLibraryAndSONAME(xkbcommon) if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"") set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
@ -686,9 +686,9 @@ macro(CheckWayland)
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_WAYLAND_LIBDECOR_SHARED AND 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")
endif() endif()
if(SDL_WAYLAND_LIBDECOR_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME(decor-0)
if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
set(HAVE_LIBDECOR_SHARED TRUE) set(HAVE_LIBDECOR_SHARED TRUE)
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}\"")
else() else()
list(APPEND EXTRA_LIBS ${LIBDECOR_LIBRARIES}) list(APPEND EXTRA_LIBS ${LIBDECOR_LIBRARIES})
@ -736,8 +736,8 @@ macro(CheckDirectFB)
if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO) if(SDL_DIRECTFB_SHARED AND 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")
endif() endif()
if(SDL_DIRECTFB_SHARED AND HAVE_SDL_LOADSO) FindLibraryAndSONAME("directfb")
FindLibraryAndSONAME("directfb") if(SDL_DIRECTFB_SHARED AND DIRECTFB_LIB AND HAVE_SDL_LOADSO)
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)
else() else()
@ -1155,7 +1155,9 @@ macro(CheckHIDAPI)
else() else()
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS # libusb is loaded dynamically, so don't add it to EXTRA_LIBS
FindLibraryAndSONAME("usb-1.0") FindLibraryAndSONAME("usb-1.0")
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"") if(USB_1.0_LIB)
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
endif()
endif() endif()
endif() endif()
endif() endif()