Merge commit '11d53c84a7663d5a5861f3672990ca4b32376e3e' into main

This commit is contained in:
Sam Lantinga 2022-10-23 16:34:42 -07:00
commit b5712c1bea
1 changed files with 42 additions and 39 deletions

View File

@ -1,8 +1,11 @@
include(CMakeParseArguments)
macro(FindLibraryAndSONAME _LIB)
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
string(TOUPPER ${_LIB} _UPPERLNAME)
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
find_library(${_LNAME}_LIB ${_LIB})
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
if(${_LNAME}_LIB)
# reduce the library name for shared linking
@ -121,7 +124,7 @@ macro(CheckPipewire)
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
endif()
FindLibraryAndSONAME("pipewire-0.3")
FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS})
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(HAVE_PIPEWIRE_SHARED TRUE)
@ -150,7 +153,7 @@ macro(CheckPulseAudio)
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
endif()
FindLibraryAndSONAME("pulse-simple")
FindLibraryAndSONAME("pulse-simple" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS})
if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
set(HAVE_PULSEAUDIO_SHARED TRUE)
@ -179,7 +182,7 @@ macro(CheckJACK)
if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
endif()
FindLibraryAndSONAME("jack")
FindLibraryAndSONAME("jack" LIBDIRS ${PKG_JACK_LIBRARY_DIRS})
if(SDL_JACK_SHARED AND JACK_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
set(HAVE_JACK_SHARED TRUE)
@ -208,7 +211,7 @@ macro(CheckESD)
if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
endif()
FindLibraryAndSONAME(esd)
FindLibraryAndSONAME(esd LIBDIRS ${PKG_ESD_LIBRARY_DIRS})
if(SDL_ESD_SHARED AND ESD_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
set(HAVE_ESD_SHARED TRUE)
@ -301,7 +304,7 @@ macro(CheckSNDIO)
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
endif()
FindLibraryAndSONAME("sndio")
FindLibraryAndSONAME("sndio" LIBDIRS ${PKG_SNDIO_LIBRARY_DIRS})
if(SDL_SNDIO_SHARED AND SNDIO_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
set(HAVE_SNDIO_SHARED TRUE)
@ -330,7 +333,7 @@ macro(CheckFusionSound)
if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
endif()
FindLibraryAndSONAME("fusionsound")
FindLibraryAndSONAME("fusionsound" LIBDIRS ${PKG_FUSIONSOUND_LIBRARY_DIRS})
if(FUSIONSOUND_SHARED AND FUSIONSOUND_LIB AND HAVE_SDL_LOADSO)
set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
set(HAVE_FUSIONSOUND_SHARED TRUE)
@ -626,9 +629,11 @@ endmacro()
# - HAVE_SDL_LOADSO opt
macro(CheckWayland)
if(SDL_WAYLAND)
pkg_check_modules(WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
set(WAYLAND_FOUND FALSE)
pkg_check_modules(PKG_WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
if(WAYLAND_FOUND)
if(PKG_WAYLAND_FOUND)
set(WAYLAND_FOUND TRUE)
find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)
execute_process(
COMMAND ${WAYLAND_SCANNER} --version
@ -651,8 +656,8 @@ macro(CheckWayland)
endif()
if(WAYLAND_FOUND)
target_link_directories(sdl-build-options INTERFACE "${WAYLAND_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${WAYLAND_INCLUDE_DIRS}")
target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}")
set(HAVE_WAYLAND TRUE)
set(HAVE_SDL_VIDEO TRUE)
@ -678,10 +683,10 @@ macro(CheckWayland)
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
endif()
FindLibraryAndSONAME(wayland-client)
FindLibraryAndSONAME(wayland-egl)
FindLibraryAndSONAME(wayland-cursor)
FindLibraryAndSONAME(xkbcommon)
FindLibraryAndSONAME(wayland-client LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(wayland-egl LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
FindLibraryAndSONAME(xkbcommon LIBDIRS ${PKG_WAYLAND_LIBRARY_DIRS})
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_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
@ -689,25 +694,25 @@ macro(CheckWayland)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
set(HAVE_WAYLAND_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${WAYLAND_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_WAYLAND_LIBRARIES})
endif()
if(SDL_WAYLAND_LIBDECOR)
pkg_check_modules(LIBDECOR libdecor-0)
if(LIBDECOR_FOUND)
pkg_check_modules(PKG_LIBDECOR libdecor-0)
if(PKG_LIBDECOR)
set(HAVE_WAYLAND_LIBDECOR TRUE)
set(HAVE_LIBDECOR_H 1)
target_link_directories(sdl-build-options INTERFACE "${LIBDECOR_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${LIBDECOR_INCLUDE_DIRS}")
target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}")
target_include_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}")
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
endif()
FindLibraryAndSONAME(decor-0)
FindLibraryAndSONAME(decor-0 LIBDIRS ${PKG_LIBDECOR_LIBRARY_DIRS})
if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
set(HAVE_LIBDECOR_SHARED TRUE)
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
else()
list(APPEND EXTRA_LIBS ${LIBDECOR_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
endif()
endif()
endif()
@ -753,7 +758,7 @@ macro(CheckDirectFB)
if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
endif()
FindLibraryAndSONAME("directfb")
FindLibraryAndSONAME("directfb" LIBDIRS ${PKG_DIRECTFB_LIBRARY_DIRS})
if(SDL_DIRECTFB_SHARED AND DIRECTFB_LIB AND HAVE_SDL_LOADSO)
set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
set(HAVE_DIRECTFB_SHARED TRUE)
@ -1159,19 +1164,19 @@ macro(CheckHIDAPI)
if(SDL_HIDAPI)
if(SDL_HIDAPI_LIBUSB)
set(HAVE_LIBUSB FALSE)
pkg_check_modules(LIBUSB libusb-1.0)
if(LIBUSB_FOUND)
check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS})
pkg_check_modules(PKG_LIBUSB libusb-1.0)
if(PKG_LIBUSB_FOUND)
check_include_file(libusb.h HAVE_LIBUSB_H ${PKG_LIBUSB_CFLAGS})
if(HAVE_LIBUSB_H)
set(HAVE_LIBUSB TRUE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_LIBUSB_CFLAGS}")
if(HIDAPI_ONLY_LIBUSB)
list(APPEND EXTRA_LIBS ${LIBUSB_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_LIBUSB_LIBRARIES})
elseif(OS2)
set(SDL_LIBUSB_DYNAMIC "\"usb100.dll\"")
else()
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
FindLibraryAndSONAME("usb-1.0")
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PKG_LIBUSB_LIBRARY_DIRS})
if(USB_1.0_LIB)
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
endif()
@ -1257,19 +1262,17 @@ endmacro()
# - HAVE_SDL_LOADSO opt
macro(CheckKMSDRM)
if(SDL_KMSDRM)
pkg_check_modules(KMSDRM libdrm gbm egl)
if(KMSDRM_FOUND AND HAVE_OPENGL_EGL)
link_directories(
${KMSDRM_LIBRARY_DIRS}
)
target_include_directories(sdl-build-options INTERFACE "${KMSDRM_INCLUDE_DIRS}")
pkg_check_modules(PKG_KMSDRM libdrm gbm egl)
if(PKG_KMSDRM_FOUND AND HAVE_OPENGL_EGL)
target_link_directories(sdl-build-options INTERFACE ${PKG_KMSDRM_LIBRARY_DIRS})
target_include_directories(sdl-build-options INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}")
set(HAVE_KMSDRM TRUE)
set(HAVE_SDL_VIDEO TRUE)
file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
list(APPEND SOURCE_FILES ${KMSDRM_SOURCES})
list(APPEND EXTRA_CFLAGS ${KMSDRM_CFLAGS})
list(APPEND EXTRA_CFLAGS ${PKG_KMSDRM_CFLAGS})
set(SDL_VIDEO_DRIVER_KMSDRM 1)
@ -1277,13 +1280,13 @@ macro(CheckKMSDRM)
message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
endif()
if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
FindLibraryAndSONAME(drm)
FindLibraryAndSONAME(gbm)
FindLibraryAndSONAME(drm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
FindLibraryAndSONAME(gbm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
set(HAVE_KMSDRM_SHARED TRUE)
else()
list(APPEND EXTRA_LIBS ${KMSDRM_LIBRARIES})
list(APPEND EXTRA_LIBS ${PKG_KMSDRM_LIBRARIES})
endif()
endif()
endif()