2015-06-21 18:33:46 +03:00
|
|
|
macro(FindLibraryAndSONAME _LIB)
|
2023-02-28 06:20:30 +03:00
|
|
|
cmake_parse_arguments(_FLAS "" "" "LIBDIRS" ${ARGN})
|
2022-10-20 02:11:39 +03:00
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
string(TOUPPER ${_LIB} _UPPERLNAME)
|
|
|
|
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
find_library(${_LNAME}_LIB ${_LIB} PATHS ${_FLAS_LIBDIRS})
|
2022-12-12 02:18:06 +03:00
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
# FIXME: fail FindLibraryAndSONAME when library is not shared.
|
2022-12-12 02:18:06 +03:00
|
|
|
if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*")
|
|
|
|
set(${_LNAME}_SHARED TRUE)
|
|
|
|
else()
|
|
|
|
set(${_LNAME}_SHARED FALSE)
|
|
|
|
endif()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
if(${_LNAME}_LIB)
|
|
|
|
# reduce the library name for shared linking
|
|
|
|
|
|
|
|
get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH) # resolves symlinks
|
2023-02-28 06:20:30 +03:00
|
|
|
get_filename_component(_LIB_LIBDIR ${_LIB_REALPATH} DIRECTORY)
|
2015-06-21 18:33:46 +03:00
|
|
|
get_filename_component(_LIB_JUSTNAME ${_LIB_REALPATH} NAME)
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*dylib$" "\\1.dylib" _LIB_REGEXD "${_LIB_JUSTNAME}")
|
|
|
|
else()
|
|
|
|
string(REGEX REPLACE "(\\.[0-9]*)\\.[0-9\\.]*$" "\\1" _LIB_REGEXD "${_LIB_JUSTNAME}")
|
|
|
|
endif()
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
if(NOT EXISTS "${_LIB_LIBDIR}/${_LIB_REGEXD}")
|
|
|
|
set(_LIB_REGEXD "${_LIB_JUSTNAME}")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
set(${_LNAME}_LIBDIR "${_LIB_LIBDIR}")
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}")
|
|
|
|
set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD})
|
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
|
|
|
|
message(DEBUG "DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB")
|
|
|
|
message(DEBUG "DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}")
|
|
|
|
message(DEBUG "DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}")
|
|
|
|
message(DEBUG "DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}")
|
|
|
|
message(DEBUG "DYNLIB SONAME LIB: ${_LIB} ... ${_LIB_REGEXD}")
|
2015-06-21 18:33:46 +03:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(CheckDLOPEN)
|
2022-09-27 02:08:04 +03:00
|
|
|
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC)
|
|
|
|
if(NOT HAVE_DLOPEN_IN_LIBC)
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_push_check_state()
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
|
2022-09-27 02:08:04 +03:00
|
|
|
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL)
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_pop_check_state()
|
2022-09-27 02:08:04 +03:00
|
|
|
if(HAVE_DLOPEN_IN_LIBDL)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(dl LIBS dl)
|
2021-08-10 20:55:50 +03:00
|
|
|
endif()
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2022-09-27 02:08:04 +03:00
|
|
|
if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL)
|
|
|
|
set(HAVE_DLOPEN TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-11-27 19:10:10 +03:00
|
|
|
macro(CheckO_CLOEXEC)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <fcntl.h>
|
|
|
|
int flag = O_CLOEXEC;
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC)
|
2021-11-27 19:10:10 +03:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckOSS)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_OSS)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/soundcard.h>
|
2022-09-27 02:52:28 +03:00
|
|
|
int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" HAVE_OSS_SYS_SOUNDCARD_H)
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2022-10-17 14:23:40 +03:00
|
|
|
if(HAVE_OSS_SYS_SOUNDCARD_H)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_OSS TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources(${SDL3_SOURCE_DIR}/src/audio/dsp/*.c)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_OSS 1)
|
2022-10-17 14:23:40 +03:00
|
|
|
if(NETBSD)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(oss LIBS ossaudio)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_ALSA_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 18:33:46 +03:00
|
|
|
macro(CheckALSA)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_ALSA)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(ALSA_PKG_CONFIG_SPEC "alsa")
|
|
|
|
find_package(ALSA MODULE)
|
2022-12-12 02:18:06 +03:00
|
|
|
if(ALSA_FOUND)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/alsa/*.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_ALSA 1)
|
2022-12-12 02:18:06 +03:00
|
|
|
set(HAVE_ALSA TRUE)
|
|
|
|
set(HAVE_ALSA_SHARED FALSE)
|
|
|
|
if(SDL_ALSA_SHARED)
|
|
|
|
if(HAVE_SDL_LOADSO)
|
|
|
|
FindLibraryAndSONAME("asound")
|
|
|
|
if(ASOUND_LIB AND ASOUND_SHARED)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(alsa INCLUDES $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>)
|
2022-12-12 02:18:06 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
|
|
|
|
set(HAVE_ALSA_SHARED TRUE)
|
|
|
|
else()
|
|
|
|
message(WARNING "Unable to find asound shared object")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading")
|
|
|
|
endif()
|
2021-08-24 06:59:54 +03:00
|
|
|
endif()
|
2022-12-12 02:18:06 +03:00
|
|
|
if(NOT HAVE_ALSA_SHARED)
|
2023-02-28 06:20:30 +03:00
|
|
|
#FIXME: remove this line and property generate sdl3.pc
|
2023-01-07 20:57:56 +03:00
|
|
|
list(APPEND SDL_PC_PRIVATE_REQUIRES alsa)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(alsa LIBS ALSA::ALSA CMAKE_MODULE ALSA PKG_CONFIG_SPECS "${ALSA_PKG_CONFIG_SPEC}")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
2022-12-12 02:18:06 +03:00
|
|
|
else()
|
|
|
|
set(HAVE_ALSA FALSE)
|
|
|
|
message(WARNING "Unable to find the alsa development library")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-02-13 19:56:05 +03:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_PIPEWIRE_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2021-02-13 19:56:05 +03:00
|
|
|
macro(CheckPipewire)
|
2023-02-28 06:20:30 +03:00
|
|
|
if(SDL_PIPEWIRE)
|
|
|
|
set(PipeWire_PKG_CONFIG_SPEC libpipewire-0.3>=0.3.20)
|
|
|
|
pkg_check_modules(PC_PIPEWIRE IMPORTED_TARGET ${PipeWire_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_PIPEWIRE_FOUND)
|
|
|
|
set(HAVE_PIPEWIRE TRUE)
|
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pipewire/*.c")
|
|
|
|
set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
|
|
|
|
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
|
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic PipeWire loading")
|
|
|
|
endif()
|
|
|
|
FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PC_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)
|
|
|
|
sdl_link_dependency(pipewire INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_PIPEWIRE,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
else()
|
|
|
|
sdl_link_dependency(pipewire LIBS PkgConfig::PC_PIPEWIRE PKG_CONFIG_PREFIX PC_PIPEWIRE PKG_CONFIG_SPECS ${PipeWire_PKG_CONFIG_SPEC})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
2021-02-13 19:56:05 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_PULSEAUDIO_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 18:33:46 +03:00
|
|
|
macro(CheckPulseAudio)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_PULSEAUDIO)
|
2023-09-28 17:15:53 +03:00
|
|
|
set(PulseAudio_PKG_CONFIG_SPEC "libpulse>=0.9.15")
|
2023-02-28 06:20:30 +03:00
|
|
|
pkg_check_modules(PC_PULSEAUDIO IMPORTED_TARGET ${PulseAudio_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_PULSEAUDIO_FOUND)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_PULSEAUDIO TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pulseaudio/*.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic PulseAudio loading")
|
2021-08-24 06:59:54 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
FindLibraryAndSONAME("pulse" LIBDIRS ${PC_PULSEAUDIO_LIBRARY_DIRS})
|
2023-07-12 23:40:42 +03:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND PULSE_LIB AND HAVE_SDL_LOADSO)
|
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_LIB_SONAME}\"")
|
2021-08-24 06:59:54 +03:00
|
|
|
set(HAVE_PULSEAUDIO_SHARED TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(pulseaudio INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_PULSEAUDIO,INTERFACE_INCLUDE_DIRECTORIES>)
|
2015-06-21 18:33:46 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(pulseaudio LIBS PkgConfig::PC_PULSEAUDIO PKG_CONFIG_PREFIX PC_PULSEAUDIO PKG_CONFIG_SPECS "${PulseAudio_PKG_CONFIG_SPEC}")
|
2017-06-08 20:27:58 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2022-11-23 06:50:20 +03:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - SDL_JACK_SHARED opt
|
|
|
|
# - HAVE_SDL_LOADSO opt
|
|
|
|
macro(CheckJACK)
|
|
|
|
if(SDL_JACK)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(Jack_PKG_CONFIG_SPEC jack)
|
|
|
|
pkg_check_modules(PC_JACK IMPORTED_TARGET ${Jack_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_JACK_FOUND)
|
2022-11-23 06:50:20 +03:00
|
|
|
set(HAVE_JACK TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/jack/*.c")
|
2022-11-23 06:50:20 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_JACK 1)
|
|
|
|
if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic JACK audio loading")
|
2022-11-23 06:50:20 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
FindLibraryAndSONAME("jack" LIBDIRS ${PC_JACK_LIBRARY_DIRS})
|
2022-11-23 06:50:20 +03:00
|
|
|
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)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(jack INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_JACK,INTERFACE_INCLUDE_DIRECTORIES>)
|
2022-11-23 06:50:20 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(jack LIBS PkgConfig::PC_JACK PKG_CONFIG_PREFIX PC_JACK PKG_CONFIG_SPECS ${Jack_PKG_CONFIG_SPEC})
|
2022-11-23 06:50:20 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2022-12-02 03:01:02 +03:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - SDL_SNDIO_SHARED opt
|
|
|
|
# - HAVE_SDL_LOADSO opt
|
|
|
|
macro(CheckSNDIO)
|
|
|
|
if(SDL_SNDIO)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(SndIO_PKG_CONFIG_SPEC sndio)
|
|
|
|
pkg_check_modules(PC_SNDIO IMPORTED_TARGET ${SndIO_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_SNDIO_FOUND)
|
2022-12-02 03:01:02 +03:00
|
|
|
set(HAVE_SNDIO TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/sndio/*.c")
|
2022-12-02 03:01:02 +03:00
|
|
|
set(SDL_AUDIO_DRIVER_SNDIO 1)
|
|
|
|
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic sndio loading")
|
2022-12-02 03:01:02 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
FindLibraryAndSONAME("sndio" LIBDIRS ${PC_SNDIO_LIBRARY_DIRS})
|
2022-12-02 03:01:02 +03:00
|
|
|
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)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_include_directories(PRIVATE SYSTEM $<TARGET_PROPERTY:PkgConfig::PC_SNDIO,INTERFACE_INCLUDE_DIRECTORIES>)
|
2022-12-02 03:01:02 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(sndio LIBS PkgConfig::PC_SNDIO PKG_CONFIG_PREFIX PC_SNDIO PKG_CONFIG_SPECS ${SndIO_PKG_CONFIG_SPEC})
|
2022-12-02 03:01:02 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_X11_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 18:33:46 +03:00
|
|
|
macro(CheckX11)
|
2022-11-25 00:38:13 +03:00
|
|
|
cmake_push_check_state()
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_X11)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(X11_PKG_CONFIG_SPEC x11)
|
|
|
|
set(Xext_PKG_CONFIG_SPEC xext)
|
|
|
|
set(Xcursor_PKG_CONFIG_SPEC xcursor)
|
|
|
|
set(Xi_PKG_CONFIG_SPEC xi)
|
|
|
|
set(Xfixes_PKG_CONFIG_SPEC xfixes)
|
|
|
|
set(Xrandr_PKG_CONFIG_SPEC xrandr)
|
|
|
|
set(Xrender_PKG_CONFIG_SPEC xrender)
|
|
|
|
set(Xss_PKG_CONFIG_SPEC xscrnsaver)
|
|
|
|
|
|
|
|
find_package(X11)
|
|
|
|
|
2022-04-26 23:41:28 +03:00
|
|
|
foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss)
|
2023-02-28 06:20:30 +03:00
|
|
|
get_filename_component(_libdir "${X11_${_LIB}_LIB}" DIRECTORY)
|
|
|
|
FindLibraryAndSONAME("${_LIB}" LIBDIRS ${_libdir})
|
2015-06-21 18:33:46 +03:00
|
|
|
endforeach()
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
find_path(X11_INCLUDEDIR
|
2022-07-21 19:38:12 +03:00
|
|
|
NAMES X11/Xlib.h
|
|
|
|
PATHS
|
2023-02-28 06:20:30 +03:00
|
|
|
${X11_INCLUDE_DIR}
|
2018-06-24 22:12:18 +03:00
|
|
|
/usr/pkg/xorg/include
|
|
|
|
/usr/X11R6/include
|
|
|
|
/usr/X11R7/include
|
|
|
|
/usr/local/include/X11
|
|
|
|
/usr/include/X11
|
|
|
|
/usr/openwin/include
|
|
|
|
/usr/openwin/share/include
|
|
|
|
/opt/graphics/OpenGL/include
|
|
|
|
/opt/X11/include
|
|
|
|
)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
if(X11_INCLUDEDIR)
|
|
|
|
sdl_include_directories(PRIVATE SYSTEM "${X11_INCLUDEDIR}")
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${X11_INCLUDEDIR})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XINPUT2_H NAMES "X11/extensions/XInput2.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XRANDR_H NAMES "X11/extensions/Xrandr.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XFIXES_H_ NAMES "X11/extensions/Xfixes.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XRENDER_H NAMES "X11/extensions/Xrender.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XSS_H NAMES "X11/extensions/scrnsaver.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XSHAPE_H NAMES "X11/extensions/shape.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XDBE_H NAMES "X11/extensions/Xdbe.h" HINTS "${X11_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XEXT_H NAMES "X11/extensions/Xext.h" HINTS "${X11_INCLUDEDIR}")
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
if(X11_LIB)
|
|
|
|
if(NOT HAVE_XEXT_H)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(FATAL_ERROR "Missing Xext.h, maybe you need to install the libxext-dev package?")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11 TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/x11/*.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11 1)
|
|
|
|
|
2023-11-08 13:33:56 +03:00
|
|
|
# Note: Disabled on Apple because the dynamic mode backend for X11 doesn't
|
|
|
|
# work properly on Apple during several issues like inconsistent paths
|
|
|
|
# among platforms. See #6778 (https://github.com/libsdl-org/SDL/issues/6778)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(APPLE)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(SDL_X11_SHARED OFF)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2022-09-27 02:59:37 +03:00
|
|
|
check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT_IN_LIBC)
|
|
|
|
if(NOT HAVE_SHMAT_IN_LIBC)
|
|
|
|
check_library_exists(ipc shmat "" HAVE_SHMAT_IN_LIBIPC)
|
|
|
|
if(HAVE_SHMAT_IN_LIBIPC)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(x11_ipc LIBS ipc)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2022-09-27 02:59:37 +03:00
|
|
|
if(NOT HAVE_SHMAT_IN_LIBIPC)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_compile_definitions(PRIVATE "NO_SHARED_MEMORY")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_X11_SHARED)
|
2021-08-10 20:55:50 +03:00
|
|
|
if(NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic X11 loading")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_X11_SHARED FALSE)
|
|
|
|
else()
|
|
|
|
set(HAVE_X11_SHARED TRUE)
|
|
|
|
endif()
|
2022-06-16 20:53:58 +03:00
|
|
|
if(X11_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(x11 LIBS X11::X11 CMAKE_MODULE X11 PKG_CONFIG_SPECS ${X11_PKG_CONFIG_SPEC})
|
2022-06-16 20:53:58 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(XEXT_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xext LIBS X11::Xext CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xext_PKG_CONFIG_SPEC})
|
2022-06-16 20:53:58 +03:00
|
|
|
endif()
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2022-03-07 10:54:24 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(x11 LIBS X11::X11 CMAKE_MODULE X11 PKG_CONFIG_SPECS ${X11_PKG_CONFIG_SPEC})
|
|
|
|
sdl_link_dependency(xext LIBS X11::Xext CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xext_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-18 23:48:24 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${X11_LIB})
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
Display *display;
|
|
|
|
XEvent event;
|
|
|
|
XGenericEventCookie *cookie = &event.xcookie;
|
|
|
|
XNextEvent(display, &event);
|
|
|
|
XGetEventData(display, cookie);
|
2022-03-13 19:10:52 +03:00
|
|
|
XFreeEventData(display, cookie);
|
|
|
|
return 0; }" HAVE_XGENERICEVENT)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(HAVE_XGENERICEVENT)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 22:22:09 +03:00
|
|
|
check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2022-07-21 15:38:57 +03:00
|
|
|
if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11_XCURSOR TRUE)
|
2022-07-21 15:38:57 +03:00
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xcursor LIBS X11::Xcursor CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xcursor_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
|
|
|
|
endif()
|
|
|
|
|
2021-11-17 02:59:38 +03:00
|
|
|
if(SDL_X11_XDBE AND HAVE_XDBE_H)
|
|
|
|
set(HAVE_X11_XDBE TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XDBE 1)
|
|
|
|
endif()
|
|
|
|
|
2022-07-21 15:38:57 +03:00
|
|
|
if(SDL_X11_XINPUT AND HAVE_XINPUT2_H AND XI_LIB)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11_XINPUT TRUE)
|
2022-07-21 15:38:57 +03:00
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xi LIBS X11::Xi CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xi_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
|
|
|
|
|
|
|
|
# Check for multitouch
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
int event_type = XI_TouchBegin;
|
|
|
|
XITouchClassInfo *t;
|
2022-03-15 23:10:02 +03:00
|
|
|
Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) {
|
2015-06-21 18:33:46 +03:00
|
|
|
return (Status)0;
|
|
|
|
}
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(HAVE_XINPUT2_MULTITOUCH)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-11-12 12:55:50 +03:00
|
|
|
# check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer
|
2021-12-06 20:37:52 +03:00
|
|
|
if(SDL_X11_XFIXES AND HAVE_XFIXES_H_ AND HAVE_XINPUT2_H)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
BarrierEventID b;
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H)
|
2021-12-06 20:37:52 +03:00
|
|
|
endif()
|
2022-07-21 16:19:19 +03:00
|
|
|
if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H AND XFIXES_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2021-11-08 21:52:48 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xfixes LIBS X11::Xfixes CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xfixes_PKG_CONFIG_SPEC})
|
2021-11-08 21:52:48 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XFIXES 1)
|
2021-11-12 12:55:50 +03:00
|
|
|
set(HAVE_X11_XFIXES TRUE)
|
2021-11-08 21:52:48 +03:00
|
|
|
endif()
|
|
|
|
|
2022-07-21 16:19:19 +03:00
|
|
|
if(SDL_X11_XRANDR AND HAVE_XRANDR_H AND XRANDR_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xrandr LIBS X11::Xrandr CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xrandr_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11_XRANDR TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2022-07-21 16:19:19 +03:00
|
|
|
if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H AND XSS_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
|
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(xss LIBS X11::Xss CMAKE_MODULE X11 PKG_CONFIG_SPECS ${Xss_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11_XSCRNSAVER TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_X11_XSHAPE TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-10-05 17:43:35 +03:00
|
|
|
if(NOT HAVE_X11)
|
2021-05-06 16:43:16 +03:00
|
|
|
# Prevent Mesa from including X11 headers
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_compile_definitions(PRIVATE "MESA_EGL_NO_X11_HEADERS" "EGL_NO_X11")
|
2021-05-06 16:43:16 +03:00
|
|
|
endif()
|
2022-11-24 22:39:55 +03:00
|
|
|
cmake_pop_check_state()
|
2015-06-21 18:33:46 +03:00
|
|
|
endmacro()
|
|
|
|
|
2021-01-15 01:50:15 +03:00
|
|
|
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
|
2016-10-11 23:36:40 +03:00
|
|
|
set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
|
|
|
|
set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${_WAYLAND_PROT_H_CODE}"
|
|
|
|
DEPENDS "${_XML}"
|
|
|
|
COMMAND "${_SCANNER}"
|
|
|
|
ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}"
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${_WAYLAND_PROT_C_CODE}"
|
|
|
|
DEPENDS "${_WAYLAND_PROT_H_CODE}"
|
|
|
|
COMMAND "${_SCANNER}"
|
2021-01-15 01:50:15 +03:00
|
|
|
ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
|
2016-10-11 23:36:40 +03:00
|
|
|
)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources("${_WAYLAND_PROT_C_CODE}")
|
2016-10-11 23:36:40 +03:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_WAYLAND_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 18:33:46 +03:00
|
|
|
macro(CheckWayland)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_WAYLAND)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(WAYLAND_PKG_CONFIG_SPEC "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
|
|
|
|
pkg_check_modules(PC_WAYLAND IMPORTED_TARGET ${WAYLAND_PKG_CONFIG_SPEC})
|
|
|
|
find_program(WAYLAND_SCANNER NAMES wayland-scanner)
|
2016-10-11 23:36:40 +03:00
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
set(WAYLAND_FOUND FALSE)
|
|
|
|
if(PC_WAYLAND_FOUND AND WAYLAND_SCANNER)
|
2016-10-11 23:36:40 +03:00
|
|
|
execute_process(
|
2021-10-25 19:04:07 +03:00
|
|
|
COMMAND ${WAYLAND_SCANNER} --version
|
|
|
|
RESULT_VARIABLE WAYLAND_SCANNER_VERSION_RC
|
2023-02-28 06:20:30 +03:00
|
|
|
ERROR_VARIABLE WAYLAND_SCANNER_VERSION_STDERR
|
2021-10-25 19:04:07 +03:00
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
2016-10-11 23:36:40 +03:00
|
|
|
)
|
2021-10-25 19:04:07 +03:00
|
|
|
if(NOT WAYLAND_SCANNER_VERSION_RC EQUAL 0)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "Failed to get wayland-scanner version")
|
2021-12-18 17:15:08 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
if(WAYLAND_SCANNER_VERSION_STDERR MATCHES [[([0-9.]+)$]])
|
|
|
|
set(WAYLAND_FOUND TRUE)
|
|
|
|
set(WAYLAND_SCANNER_VERSION ${CMAKE_MATCH_1})
|
|
|
|
if(WAYLAND_SCANNER_VERSION VERSION_LESS "1.15.0")
|
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "code")
|
|
|
|
else()
|
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "private-code")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-01-15 01:50:15 +03:00
|
|
|
endif()
|
2021-10-25 19:04:07 +03:00
|
|
|
endif()
|
2021-01-15 01:50:15 +03:00
|
|
|
|
2021-10-25 19:04:07 +03:00
|
|
|
if(WAYLAND_FOUND)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_WAYLAND TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/wayland/*.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2016-10-11 23:36:40 +03:00
|
|
|
# We have to generate some protocol interface code for some unstable Wayland features.
|
2023-02-28 06:20:30 +03:00
|
|
|
file(MAKE_DIRECTORY "${SDL3_BINARY_DIR}/wayland-generated-protocols")
|
|
|
|
# Prepend to include path to make sure they override installed protocol headers
|
|
|
|
sdl_include_directories(PRIVATE SYSTEM BEFORE "${SDL3_BINARY_DIR}/wayland-generated-protocols")
|
2016-10-11 23:36:40 +03:00
|
|
|
|
2022-11-22 07:28:58 +03:00
|
|
|
file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL3_SOURCE_DIR}/wayland-protocols/" "${SDL3_SOURCE_DIR}/wayland-protocols/*.xml")
|
2023-02-28 06:20:30 +03:00
|
|
|
foreach(_XML IN LISTS WAYLAND_PROTOCOLS_XML)
|
2018-06-25 19:37:25 +03:00
|
|
|
string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}")
|
2022-11-22 07:28:58 +03:00
|
|
|
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL3_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
|
2016-10-11 23:36:40 +03:00
|
|
|
endforeach()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic Wayland loading")
|
2021-08-24 06:59:54 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
FindLibraryAndSONAME(wayland-client LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS})
|
|
|
|
FindLibraryAndSONAME(wayland-egl LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS})
|
|
|
|
FindLibraryAndSONAME(wayland-cursor LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS})
|
|
|
|
FindLibraryAndSONAME(xkbcommon LIBDIRS ${PC_WAYLAND_LIBRARY_DIRS})
|
2022-06-15 04:16:28 +03:00
|
|
|
if(SDL_WAYLAND_SHARED AND WAYLAND_CLIENT_LIB AND WAYLAND_EGL_LIB AND WAYLAND_CURSOR_LIB AND XKBCOMMON_LIB AND HAVE_SDL_LOADSO)
|
2021-08-24 06:59:54 +03:00
|
|
|
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_CURSOR "\"${WAYLAND_CURSOR_LIB_SONAME}\"")
|
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "\"${XKBCOMMON_LIB_SONAME}\"")
|
|
|
|
set(HAVE_WAYLAND_SHARED TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(wayland INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_WAYLAND,INTERFACE_INCLUDE_DIRECTORIES>)
|
2015-06-21 18:33:46 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(wayland LIBS PkgConfig::PC_WAYLAND PKG_CONFIG_PREFIX PC_WAYLAND PKG_CONFIG_SPECS ${WAYLAND_PKG_CONFIG_SPEC})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_WAYLAND_LIBDECOR)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(LibDecor_PKG_CONFIG_SPEC libdecor-0)
|
|
|
|
pkg_check_modules(PC_LIBDECOR IMPORTED_TARGET ${LibDecor_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_LIBDECOR_FOUND)
|
2023-12-28 21:04:41 +03:00
|
|
|
|
|
|
|
# Libdecor doesn't provide internal version defines, so generate them here.
|
|
|
|
if (PC_LIBDECOR_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
|
|
|
set(SDL_LIBDECOR_VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
set(SDL_LIBDECOR_VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
set(SDL_LIBDECOR_VERSION_PATCH ${CMAKE_MATCH_3})
|
|
|
|
else()
|
|
|
|
message(WARNING "Failed to parse libdecor version; defaulting to lowest supported (0.1.0)")
|
|
|
|
set(SDL_LIBDECOR_VERSION_MAJOR 0)
|
|
|
|
set(SDL_LIBDECOR_VERSION_MINOR 1)
|
|
|
|
set(SDL_LIBDECOR_VERSION_PATCH 0)
|
|
|
|
endif()
|
|
|
|
|
2023-09-25 19:02:06 +03:00
|
|
|
if(PC_LIBDECOR_VERSION VERSION_GREATER_EQUAL "0.2.0")
|
|
|
|
set(LibDecor_PKG_CONFIG_SPEC "libdecor-0>=0.2.0")
|
2023-02-28 06:20:30 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_WAYLAND_LIBDECOR TRUE)
|
|
|
|
set(HAVE_LIBDECOR_H 1)
|
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
|
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic libdecor loading")
|
|
|
|
endif()
|
|
|
|
FindLibraryAndSONAME(decor-0 LIBDIRS ${PC_LIBDECOR_LIBRARY_DIRS})
|
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
|
|
|
|
set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
|
|
|
|
sdl_link_dependency(libdecor INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBDECOR,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
else()
|
|
|
|
sdl_link_dependency(libdecor LIBS PkgConfig::PC_LIBDECOR PKG_CONFIG_PREFIX PC_LIBDECOR PKG_CONFIG_SPECS ${LibDecor_PKG_CONFIG_SPEC})
|
2021-08-03 14:01:02 +03:00
|
|
|
endif()
|
2021-08-03 10:10:14 +03:00
|
|
|
endif()
|
2020-06-12 00:10:28 +03:00
|
|
|
endif()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
#
|
|
|
|
macro(CheckCOCOA)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_COCOA)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(APPLE) # Apple always has Cocoa.
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_COCOA TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_COCOA)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/cocoa/*.m")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_COCOA 1)
|
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckVivante)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_VIVANTE)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <gc_vdk.h>
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#define LINUX
|
|
|
|
#define EGL_API_FB
|
|
|
|
#include <EGL/eglvivante.h>
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
|
|
|
|
set(HAVE_VIVANTE TRUE)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/vivante/*.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE 1)
|
2023-02-28 06:20:30 +03:00
|
|
|
# FIXME: Use Find module
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_VIVANTE_VDK)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
|
2022-03-23 18:07:52 +03:00
|
|
|
find_library(VIVANTE_LIBRARY REQUIRED NAMES VIVANTE vivante drm_vivante)
|
|
|
|
find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(vivante LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY})
|
2015-06-21 18:33:46 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
# these defines are needed when including the system EGL headers, which SDL does
|
|
|
|
sdl_compile_definitions(PUBLIC "LINUX" "EGL_API_FB")
|
|
|
|
sdl_link_dependency(vivante LIBS EGL)
|
2021-10-05 17:43:35 +03:00
|
|
|
endif(HAVE_VIVANTE_VDK)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
2021-05-06 16:43:16 +03:00
|
|
|
macro(CheckGLX)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <GL/glx.h>
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX)
|
2022-12-26 03:44:40 +03:00
|
|
|
if(HAVE_OPENGL_GLX AND NOT HAVE_ROCKCHIP)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(SDL_VIDEO_OPENGL_GLX 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-03-11 12:10:29 +03:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
macro(CheckEGL)
|
2023-02-28 06:20:30 +03:00
|
|
|
if(SDL_OPENGL OR SDL_OPENGLES)
|
|
|
|
cmake_push_check_state()
|
|
|
|
find_package(OpenGL MODULE)
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
|
2024-01-20 10:55:05 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos")
|
2020-12-22 19:17:30 +03:00
|
|
|
check_c_source_compiles("
|
2021-05-06 16:43:16 +03:00
|
|
|
#define EGL_API_FB
|
|
|
|
#define MESA_EGL_NO_X11_HEADERS
|
|
|
|
#define EGL_NO_X11
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
2022-03-13 19:10:52 +03:00
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
|
2023-02-28 06:20:30 +03:00
|
|
|
cmake_pop_check_state()
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_OPENGL_EGL)
|
2021-05-06 16:43:16 +03:00
|
|
|
set(SDL_VIDEO_OPENGL_EGL 1)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_link_dependency(egl INCLUDES ${OPENGL_EGL_INCLUDE_DIRS})
|
2020-12-22 19:17:30 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
2021-05-06 16:43:16 +03:00
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGL)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
2021-05-06 16:43:16 +03:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
2022-03-13 19:10:52 +03:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_OPENGL)
|
2021-05-06 16:43:16 +03:00
|
|
|
set(SDL_VIDEO_OPENGL 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL 1)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
2021-05-06 16:43:16 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGLES)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_OPENGLES)
|
2024-01-20 10:55:05 +03:00
|
|
|
cmake_push_check_state()
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES "${SDL3_SOURCE_DIR}/src/video/khronos")
|
2022-11-23 18:50:02 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
2023-02-28 06:20:30 +03:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#include <GLES2/gl2ext.h>
|
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2)
|
2024-01-20 10:55:05 +03:00
|
|
|
cmake_pop_check_state()
|
|
|
|
if(HAVE_OPENGLES_V1)
|
|
|
|
set(HAVE_OPENGLES TRUE)
|
|
|
|
set(SDL_VIDEO_OPENGL_ES 1)
|
|
|
|
endif()
|
2021-10-05 17:43:35 +03:00
|
|
|
if(HAVE_OPENGLES_V2)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(HAVE_OPENGLES TRUE)
|
|
|
|
set(SDL_VIDEO_OPENGL_ES2 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL_ES2 1)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
macro(CheckVulkan)
|
|
|
|
if(SDL_VULKAN)
|
|
|
|
set(SDL_VIDEO_VULKAN 1)
|
|
|
|
set(HAVE_VULKAN TRUE)
|
2024-02-26 22:37:07 +03:00
|
|
|
if(SDL_RENDER_VULKAN)
|
|
|
|
set(SDL_VIDEO_RENDER_VULKAN 1)
|
|
|
|
set(HAVE_RENDER_VULKAN TRUE)
|
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2023-01-07 14:29:03 +03:00
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
macro(CheckQNXScreen)
|
|
|
|
if(QNX AND HAVE_OPENGL_EGL)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <screen/screen.h>
|
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_QNX_SCREEN)
|
|
|
|
if(HAVE_QNX_SCREEN)
|
|
|
|
set(SDL_VIDEO_DRIVER_QNX 1)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/qnx/*.c")
|
|
|
|
sdl_link_dependency(qnxscreen LIBS screen EGL)
|
2023-01-07 14:29:03 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - nada
|
|
|
|
# Optional:
|
|
|
|
# - THREADS opt
|
|
|
|
# Sets:
|
|
|
|
# PTHREAD_CFLAGS
|
|
|
|
# PTHREAD_LIBS
|
|
|
|
macro(CheckPTHREAD)
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_push_check_state()
|
2024-01-17 19:36:52 +03:00
|
|
|
if(SDL_PTHREADS)
|
2017-08-10 02:50:18 +03:00
|
|
|
if(ANDROID)
|
|
|
|
# the android libc provides built-in support for pthreads, so no
|
|
|
|
# additional linking or compile flags are necessary
|
|
|
|
elseif(LINUX)
|
2015-06-21 18:33:46 +03:00
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
|
|
|
elseif(BSDI)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
|
|
|
set(PTHREAD_LDFLAGS "")
|
|
|
|
elseif(DARWIN)
|
|
|
|
set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
|
|
|
|
# causes Carbon.p complaints?
|
|
|
|
# set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
|
|
|
set(PTHREAD_LDFLAGS "")
|
|
|
|
elseif(FREEBSD)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
|
|
|
elseif(NETBSD)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
|
|
|
elseif(OPENBSD)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
2022-10-21 11:49:15 +03:00
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
2015-06-21 18:33:46 +03:00
|
|
|
elseif(SOLARIS)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread -lposix4")
|
|
|
|
elseif(SYSV5)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
|
|
|
|
set(PTHREAD_LDFLAGS "")
|
|
|
|
elseif(AIX)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
|
|
|
elseif(HPUX)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
|
|
|
|
elseif(HAIKU)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "")
|
2021-04-04 07:16:30 +03:00
|
|
|
elseif(EMSCRIPTEN)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -pthread")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
2023-01-06 16:24:18 +03:00
|
|
|
elseif(QNX)
|
|
|
|
# pthread support is baked in
|
2015-06-21 18:33:46 +03:00
|
|
|
else()
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Run some tests
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND CMAKE_REQUIRED_FLAGS " ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
|
2021-04-23 01:56:10 +03:00
|
|
|
check_c_source_compiles("
|
2023-02-28 06:20:30 +03:00
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
pthread_attr_t type;
|
|
|
|
pthread_attr_init(&type);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_PTHREADS)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(HAVE_PTHREADS)
|
|
|
|
set(SDL_THREAD_PTHREAD 1)
|
2023-01-13 21:01:36 +03:00
|
|
|
separate_arguments(PTHREAD_CFLAGS)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_compile_options(PRIVATE ${PTHREAD_CFLAGS})
|
|
|
|
sdl_link_dependency(pthread LINK_OPTIONS ${PTHREAD_LDFLAGS})
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
pthread_mutexattr_t attr;
|
|
|
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_RECURSIVE_MUTEXES)
|
|
|
|
if(HAVE_RECURSIVE_MUTEXES)
|
|
|
|
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
|
|
|
|
else()
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
pthread_mutexattr_t attr;
|
2017-07-11 04:40:35 +03:00
|
|
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
2015-06-21 18:33:46 +03:00
|
|
|
return 0;
|
|
|
|
}" HAVE_RECURSIVE_MUTEXES_NP)
|
|
|
|
if(HAVE_RECURSIVE_MUTEXES_NP)
|
|
|
|
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_PTHREADS_SEM)
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("#include <pthread.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
|
|
|
|
if(HAVE_PTHREADS_SEM)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
sem_timedwait(NULL, NULL);
|
|
|
|
return 0;
|
2023-03-30 00:49:01 +03:00
|
|
|
}" COMPILER_HAS_SEM_TIMEDWAIT)
|
|
|
|
set(HAVE_SEM_TIMEDWAIT ${COMPILER_HAS_SEM_TIMEDWAIT})
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-11-26 12:41:46 +03:00
|
|
|
check_include_file(pthread.h HAVE_PTHREAD_H)
|
|
|
|
check_include_file(pthread_np.h HAVE_PTHREAD_NP_H)
|
2020-04-13 22:22:09 +03:00
|
|
|
if (HAVE_PTHREAD_H)
|
2021-11-17 02:59:38 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
2024-01-24 13:40:04 +03:00
|
|
|
#ifdef __APPLE__
|
2023-02-13 11:56:10 +03:00
|
|
|
pthread_setname_np(\"\");
|
2023-02-13 11:55:40 +03:00
|
|
|
#else
|
2023-02-13 11:56:10 +03:00
|
|
|
pthread_setname_np(pthread_self(),\"\");
|
2023-02-13 11:55:40 +03:00
|
|
|
#endif
|
2021-11-17 02:59:38 +03:00
|
|
|
return 0;
|
|
|
|
}" HAVE_PTHREAD_SETNAME_NP)
|
2020-04-13 22:22:09 +03:00
|
|
|
if (HAVE_PTHREAD_NP_H)
|
|
|
|
check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources(
|
|
|
|
"${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c"
|
|
|
|
"${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c" # Can be faked, if necessary
|
|
|
|
"${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c" # Can be faked, if necessary
|
|
|
|
"${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysrwlock.c" # Can be faked, if necessary
|
|
|
|
"${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systls.c"
|
|
|
|
)
|
2015-06-21 18:33:46 +03:00
|
|
|
if(HAVE_PTHREADS_SEM)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources("${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
else()
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources("${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_THREADS TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_pop_check_state()
|
2015-06-21 18:33:46 +03:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires
|
|
|
|
# - nada
|
|
|
|
# Optional:
|
|
|
|
# Sets:
|
|
|
|
# USB_LIBS
|
|
|
|
# USB_CFLAGS
|
|
|
|
macro(CheckUSBHID)
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_push_check_state()
|
2015-06-21 18:33:46 +03:00
|
|
|
check_library_exists(usbhid hid_init "" LIBUSBHID)
|
|
|
|
if(LIBUSBHID)
|
|
|
|
check_include_file(usbhid.h HAVE_USBHID_H)
|
|
|
|
if(HAVE_USBHID_H)
|
|
|
|
set(USB_CFLAGS "-DHAVE_USBHID_H")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
|
|
|
|
if(HAVE_LIBUSBHID_H)
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND USB_CFLAGS " -DHAVE_LIBUSBHID_H")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(USB_LIBS ${USB_LIBS} usbhid)
|
|
|
|
else()
|
|
|
|
check_include_file(usb.h HAVE_USB_H)
|
|
|
|
if(HAVE_USB_H)
|
|
|
|
set(USB_CFLAGS "-DHAVE_USB_H")
|
|
|
|
endif()
|
|
|
|
check_include_file(libusb.h HAVE_LIBUSB_H)
|
|
|
|
if(HAVE_LIBUSB_H)
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND USB_CFLAGS " -DHAVE_LIBUSB_H")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
check_library_exists(usb hid_init "" LIBUSB)
|
|
|
|
if(LIBUSB)
|
2023-01-07 22:38:33 +03:00
|
|
|
list(APPEND USB_LIBS usb)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND CMAKE_REQUIRED_FLAGS " ${USB_CFLAGS}")
|
2022-12-18 23:48:24 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${USB_LIBS})
|
2015-06-21 18:33:46 +03:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#if defined(HAVE_USB_H)
|
|
|
|
#include <usb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef __DragonFly__
|
2020-12-20 23:08:49 +03:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
#else
|
|
|
|
# include <dev/usb/usb.h>
|
|
|
|
# include <dev/usb/usbhid.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_USBHID_H)
|
|
|
|
#include <usbhid.h>
|
|
|
|
#elif defined(HAVE_LIBUSB_H)
|
|
|
|
#include <libusb.h>
|
|
|
|
#elif defined(HAVE_LIBUSBHID_H)
|
|
|
|
#include <libusbhid.h>
|
|
|
|
#endif
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
struct report_desc *repdesc;
|
|
|
|
struct usb_ctl_report *repbuf;
|
|
|
|
hid_kind_t hidkind;
|
|
|
|
return 0;
|
|
|
|
}" HAVE_USBHID)
|
|
|
|
if(HAVE_USBHID)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#if defined(HAVE_USB_H)
|
|
|
|
#include <usb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef __DragonFly__
|
2020-12-20 23:08:49 +03:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
#else
|
|
|
|
# include <dev/usb/usb.h>
|
|
|
|
# include <dev/usb/usbhid.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_USBHID_H)
|
|
|
|
#include <usbhid.h>
|
|
|
|
#elif defined(HAVE_LIBUSB_H)
|
|
|
|
#include <libusb.h>
|
|
|
|
#elif defined(HAVE_LIBUSBHID_H)
|
|
|
|
#include <libusbhid.h>
|
|
|
|
#endif
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
struct usb_ctl_report buf;
|
|
|
|
if (buf.ucr_data) { }
|
|
|
|
return 0;
|
|
|
|
}" HAVE_USBHID_UCR_DATA)
|
|
|
|
if(HAVE_USBHID_UCR_DATA)
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND USB_CFLAGS " -DUSBHID_UCR_DATA")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#if defined(HAVE_USB_H)
|
|
|
|
#include <usb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef __DragonFly__
|
2020-12-20 23:08:49 +03:00
|
|
|
#include <bus/u4b/usb.h>
|
|
|
|
#include <bus/u4b/usbhid.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
#else
|
|
|
|
#include <dev/usb/usb.h>
|
|
|
|
#include <dev/usb/usbhid.h>
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_USBHID_H)
|
|
|
|
#include <usbhid.h>
|
|
|
|
#elif defined(HAVE_LIBUSB_H)
|
|
|
|
#include <libusb.h>
|
|
|
|
#elif defined(HAVE_LIBUSBHID_H)
|
|
|
|
#include <libusbhid.h>
|
|
|
|
#endif
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
report_desc_t d;
|
|
|
|
hid_start_parse(d, 1, 1);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_USBHID_NEW)
|
|
|
|
if(HAVE_USBHID_NEW)
|
2023-02-28 06:20:30 +03:00
|
|
|
string(APPEND USB_CFLAGS " -DUSBHID_NEW")
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <machine/joystick.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
struct joystick t;
|
|
|
|
return 0;
|
|
|
|
}" HAVE_MACHINE_JOYSTICK)
|
|
|
|
if(HAVE_MACHINE_JOYSTICK)
|
2021-01-23 17:24:28 +03:00
|
|
|
set(SDL_HAVE_MACHINE_JOYSTICK_H 1)
|
2015-06-21 18:33:46 +03:00
|
|
|
endif()
|
|
|
|
set(SDL_JOYSTICK_USBHID 1)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/bsd/*.c")
|
2023-01-13 20:40:49 +03:00
|
|
|
separate_arguments(USB_CFLAGS)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_compile_options(PRIVATE ${USB_CFLAGS})
|
|
|
|
#FIXME: properly add usb libs with pkg-config or whatever
|
|
|
|
sdl_link_dependency(usbhid LIBS ${USB_LIBS})
|
2015-06-21 18:33:46 +03:00
|
|
|
set(HAVE_SDL_JOYSTICK TRUE)
|
|
|
|
endif()
|
2022-12-18 23:48:24 +03:00
|
|
|
cmake_pop_check_state()
|
2015-06-21 18:33:46 +03:00
|
|
|
endmacro()
|
|
|
|
|
2021-11-11 20:16:44 +03:00
|
|
|
# Check for HIDAPI support
|
2019-07-08 23:46:52 +03:00
|
|
|
macro(CheckHIDAPI)
|
2022-07-26 03:51:07 +03:00
|
|
|
if(SDL_HIDAPI)
|
2023-08-14 16:48:14 +03:00
|
|
|
set(HAVE_HIDAPI ON)
|
2022-07-26 03:51:07 +03:00
|
|
|
if(SDL_HIDAPI_LIBUSB)
|
|
|
|
set(HAVE_LIBUSB FALSE)
|
2023-02-28 06:20:30 +03:00
|
|
|
|
2023-11-24 23:31:35 +03:00
|
|
|
set(LibUSB_PKG_CONFIG_SPEC libusb-1.0>=1.0.16)
|
2023-02-28 06:20:30 +03:00
|
|
|
pkg_check_modules(PC_LIBUSB IMPORTED_TARGET ${LibUSB_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_LIBUSB_FOUND)
|
|
|
|
cmake_push_check_state()
|
2023-07-28 02:16:06 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUSB_INCLUDE_DIRS})
|
2023-08-26 15:55:50 +03:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES PkgConfig::PC_LIBUSB)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <libusb.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
libusb_close(NULL);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_LIBUSB_H)
|
2023-02-28 06:20:30 +03:00
|
|
|
cmake_pop_check_state()
|
2022-07-26 03:51:07 +03:00
|
|
|
if(HAVE_LIBUSB_H)
|
|
|
|
set(HAVE_LIBUSB TRUE)
|
2023-08-14 16:48:14 +03:00
|
|
|
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PC_LIBUSB_LIBRARY_DIRS})
|
|
|
|
if(SDL_HIDAPI_LIBUSB_SHARED AND USB_1.0_LIB_SONAME)
|
|
|
|
set(HAVE_HIDAPI_LIBUSB_SHARED ON)
|
|
|
|
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
2023-07-28 02:16:06 +03:00
|
|
|
sdl_link_dependency(hidapi INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBUSB,INTERFACE_INCLUDE_DIRECTORIES>)
|
2023-08-14 16:48:14 +03:00
|
|
|
else()
|
|
|
|
sdl_link_dependency(hidapi LIBS PkgConfig::PC_LIBUSB PKG_CONFIG_PREFIX PC_LIBUSB PKG_CONFIG_SPECS ${LibUSB_PKG_CONFIG_SPEC})
|
2022-06-15 04:16:28 +03:00
|
|
|
endif()
|
2019-07-31 19:20:55 +03:00
|
|
|
endif()
|
2019-07-08 23:46:52 +03:00
|
|
|
endif()
|
2022-09-10 16:53:11 +03:00
|
|
|
set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB})
|
2019-07-08 23:46:52 +03:00
|
|
|
endif()
|
2021-11-11 20:16:44 +03:00
|
|
|
|
2022-07-26 03:51:07 +03:00
|
|
|
if(HAVE_HIDAPI)
|
|
|
|
if(ANDROID)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp")
|
2022-07-26 03:51:07 +03:00
|
|
|
endif()
|
|
|
|
if(IOS OR TVOS)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/ios/hid.m")
|
2022-07-26 03:51:07 +03:00
|
|
|
set(SDL_FRAMEWORK_COREBLUETOOTH 1)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_HIDAPI TRUE)
|
|
|
|
|
|
|
|
if(SDL_JOYSTICK AND SDL_HIDAPI_JOYSTICK)
|
|
|
|
set(SDL_JOYSTICK_HIDAPI 1)
|
|
|
|
set(HAVE_SDL_JOYSTICK TRUE)
|
|
|
|
set(HAVE_HIDAPI_JOYSTICK TRUE)
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/hidapi/*.c")
|
2022-07-26 03:51:07 +03:00
|
|
|
endif()
|
2022-09-10 14:41:29 +03:00
|
|
|
else()
|
2022-09-10 15:11:19 +03:00
|
|
|
set(SDL_HIDAPI_DISABLED 1)
|
2021-11-11 20:16:44 +03:00
|
|
|
endif()
|
2022-07-26 03:51:07 +03:00
|
|
|
else()
|
|
|
|
set(SDL_HIDAPI_DISABLED 1)
|
2019-07-08 23:46:52 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 18:33:46 +03:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckRPI)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_RPI)
|
2023-07-28 02:02:12 +03:00
|
|
|
set(BCM_HOST_PKG_CONFIG_SPEC bcm_host)
|
|
|
|
set(BRCMEGL_PKG_CONFIG_SPEC brcmegl)
|
|
|
|
|
|
|
|
set(original_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
|
|
|
|
set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}:/opt/vc/lib/pkgconfig")
|
|
|
|
pkg_check_modules(PC_BCM_HOST IMPORTED_TARGET QUIET ${BCM_HOST_PKG_CONFIG_SPEC})
|
|
|
|
pkg_check_modules(PC_BRCMEGL IMPORTED_TARGET QUIET ${BRCMEGL_PKG_CONFIG_SPEC})
|
|
|
|
set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}")
|
|
|
|
|
|
|
|
if(TARGET PkgConfig::PC_BCM_HOST AND TARGET PkgConfig::PC_BRCMEGL)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(HAVE_RPI TRUE)
|
2023-07-28 02:02:12 +03:00
|
|
|
if(SDL_VIDEO)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_RPI 1)
|
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/raspberry/*.c")
|
2023-07-28 02:02:12 +03:00
|
|
|
sdl_link_dependency(rpi-video LIBS PkgConfig::PC_BCM_HOST PKG_CONFIG_PREFIX PC_BCM_HOST PKG_CONFIG_SPECS ${BCM_HOST_PKG_CONFIG_SPEC})
|
2023-02-28 06:20:30 +03:00
|
|
|
endif()
|
2021-10-05 17:43:35 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2017-08-02 20:22:48 +03:00
|
|
|
|
2022-12-26 03:44:40 +03:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckROCKCHIP)
|
|
|
|
if(SDL_ROCKCHIP)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(MALI_PKG_CONFIG_SPEC mali)
|
|
|
|
pkg_check_modules(PC_MALI QUIET ${MALI_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_MALI_FOUND)
|
2022-12-26 03:44:40 +03:00
|
|
|
set(HAVE_ROCKCHIP TRUE)
|
|
|
|
endif()
|
|
|
|
if(SDL_VIDEO AND HAVE_ROCKCHIP)
|
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_ROCKCHIP 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2017-08-02 20:22:48 +03:00
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 17:43:35 +03:00
|
|
|
# - SDL_KMSDRM_SHARED opt
|
2021-08-10 20:55:50 +03:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-08-02 20:22:48 +03:00
|
|
|
macro(CheckKMSDRM)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_KMSDRM)
|
2023-02-28 06:20:30 +03:00
|
|
|
set(PKG_CONFIG_LIBDRM_SPEC libdrm)
|
|
|
|
set(PKG_CONFIG_GBM_SPEC gbm)
|
|
|
|
pkg_check_modules(PC_LIBDRM IMPORTED_TARGET ${PKG_CONFIG_LIBDRM_SPEC})
|
|
|
|
pkg_check_modules(PC_GBM IMPORTED_TARGET ${PKG_CONFIG_GBM_SPEC})
|
|
|
|
if(PC_LIBDRM_FOUND AND PC_GBM_FOUND AND HAVE_OPENGL_EGL)
|
2021-10-05 17:43:35 +03:00
|
|
|
set(HAVE_KMSDRM TRUE)
|
2017-08-02 20:22:48 +03:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2023-02-28 06:20:30 +03:00
|
|
|
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/kmsdrm/*.c")
|
2017-08-02 20:22:48 +03:00
|
|
|
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM 1)
|
|
|
|
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
message(WARNING "You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
|
2021-08-24 06:59:54 +03:00
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
set(HAVE_KMSDRM_SHARED FALSE)
|
2021-10-05 17:43:35 +03:00
|
|
|
if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
|
2023-02-28 06:20:30 +03:00
|
|
|
FindLibraryAndSONAME(drm LIBDIRS ${PC_LIBDRM_LIBRARY_DIRS})
|
|
|
|
FindLibraryAndSONAME(gbm LIBDIRS ${PC_GBM_LIBRARY_DIRS})
|
|
|
|
if(DRM_LIB AND DRM_SHARED AND GBM_LIB AND GBM_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
|
|
|
|
set(HAVE_KMSDRM_SHARED TRUE)
|
|
|
|
sdl_link_dependency(kmsdrm-drm INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBDRM,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
sdl_link_dependency(kmsdrm-gbm INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_GBM,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT HAVE_KMSDRM_SHARED)
|
|
|
|
sdl_link_dependency(kmsdrm-libdrm LIBS PkgConfig::PC_LIBDRM PKG_CONFIG_PREFIX PC_LIBDRM PKG_CONFIG_SPECS ${PKG_CONFIG_LIBDRM_SPEC})
|
|
|
|
sdl_link_dependency(kmsdrm-gbm LIBS PkgConfig::PC_GBM PKG_CONFIG_PREFIX PC_GBM PKG_CONFIG_SPECS ${PKG_CONFIG_GBM_SPEC})
|
2017-08-02 20:22:48 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2022-11-25 04:57:00 +03:00
|
|
|
|
|
|
|
macro(CheckLibUDev)
|
|
|
|
if(SDL_LIBUDEV)
|
2023-02-28 06:20:30 +03:00
|
|
|
check_include_file("libudev.h" HAVE_LIBUDEV_HEADER)
|
|
|
|
if(HAVE_LIBUDEV_HEADER)
|
2022-11-25 04:57:00 +03:00
|
|
|
set(HAVE_LIBUDEV_H TRUE)
|
|
|
|
FindLibraryAndSONAME(udev)
|
|
|
|
if(UDEV_LIB_SONAME)
|
|
|
|
set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
|
2023-02-28 06:20:30 +03:00
|
|
|
set(HAVE_LIBUDEV TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(CheckLibUnwind)
|
|
|
|
if(TARGET SDL3_test)
|
|
|
|
set(found_libunwind FALSE)
|
|
|
|
set(_libunwind_src "#include <libunwind.h>\nint main() {unw_context_t context; unw_getcontext(&context); return 0;}")
|
|
|
|
|
|
|
|
if(NOT found_libunwind)
|
|
|
|
cmake_push_check_state()
|
|
|
|
check_c_source_compiles("${_libunwind_src}" LIBC_HAS_WORKING_LIBUNWIND)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
if(LIBC_HAS_WORKING_LIBUNWIND)
|
|
|
|
set(found_libunwind TRUE)
|
|
|
|
target_compile_definitions(SDL3_test PRIVATE HAVE_LIBUNWIND_H)
|
2022-11-25 04:57:00 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
2023-02-28 06:20:30 +03:00
|
|
|
|
|
|
|
if(NOT found_libunwind)
|
|
|
|
cmake_push_check_state()
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "unwind")
|
|
|
|
check_c_source_compiles("${_libunwind_src}" LIBUNWIND_HAS_WORKINGLIBUNWIND)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
if(LIBUNWIND_HAS_WORKINGLIBUNWIND)
|
|
|
|
set(found_libunwind TRUE)
|
|
|
|
sdl_test_link_dependency(UNWIND LIBS unwind)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT found_libunwind)
|
|
|
|
set(LibUnwind_PKG_CONFIG_SPEC libunwind libunwind-generic)
|
|
|
|
pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC})
|
|
|
|
if(PC_LIBUNWIND_FOUND)
|
|
|
|
cmake_push_check_state()
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${PC_LIBUNWIND_LIBRARIES})
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS})
|
|
|
|
check_c_source_compiles("${_libunwind_src}" PC_LIBUNWIND_HAS_WORKING_LIBUNWIND)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
if(PC_LIBUNWIND_HAS_WORKING_LIBUNWIND)
|
|
|
|
set(found_libunwind TRUE)
|
|
|
|
sdl_test_link_dependency(UNWIND LIBS PkgConfig::PC_LIBUNWIND PKG_CONFIG_PREFIX PC_LIBUNWIND PKG_CONFIG_SPECS ${LibUnwind_PKG_CONFIG_SPEC})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(found_libunwind)
|
|
|
|
target_compile_definitions(SDL3_test PRIVATE HAVE_LIBUNWIND_H)
|
|
|
|
endif()
|
2022-11-25 04:57:00 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|