2022-10-19 17:11:39 -06:00
|
|
|
include(CMakeParseArguments)
|
2015-06-21 09:33:46 -06:00
|
|
|
macro(FindLibraryAndSONAME _LIB)
|
2022-10-19 17:11:39 -06:00
|
|
|
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
string(TOUPPER ${_LIB} _UPPERLNAME)
|
|
|
|
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
|
|
|
|
|
2022-10-19 17:11:39 -06:00
|
|
|
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
|
2015-06-21 09:33:46 -06:00
|
|
|
if(${_LNAME}_LIB)
|
|
|
|
# reduce the library name for shared linking
|
|
|
|
|
|
|
|
get_filename_component(_LIB_REALPATH ${${_LNAME}_LIB} REALPATH) # resolves symlinks
|
|
|
|
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()
|
|
|
|
|
|
|
|
SET(_DEBUG_FindSONAME FALSE)
|
|
|
|
if(_DEBUG_FindSONAME)
|
|
|
|
message_warn("DYNLIB OUTPUTVAR: ${_LIB} ... ${_LNAME}_LIB")
|
|
|
|
message_warn("DYNLIB ORIGINAL LIB: ${_LIB} ... ${${_LNAME}_LIB}")
|
|
|
|
message_warn("DYNLIB REALPATH LIB: ${_LIB} ... ${_LIB_REALPATH}")
|
|
|
|
message_warn("DYNLIB JUSTNAME LIB: ${_LIB} ... ${_LIB_JUSTNAME}")
|
|
|
|
message_warn("DYNLIB REGEX'd LIB: ${_LIB} ... ${_LIB_REGEXD}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "dynamic lib${_LIB} -> ${_LIB_REGEXD}")
|
|
|
|
set(${_LNAME}_LIB_SONAME ${_LIB_REGEXD})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(CheckDLOPEN)
|
2022-09-26 17:08:04 -06:00
|
|
|
cmake_push_check_state(RESET)
|
|
|
|
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBC)
|
|
|
|
if(NOT HAVE_DLOPEN_IN_LIBC)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES dl)
|
|
|
|
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN_IN_LIBDL)
|
|
|
|
if(HAVE_DLOPEN_IN_LIBDL)
|
2021-08-10 11:55:50 -06:00
|
|
|
list(APPEND EXTRA_LIBS dl)
|
|
|
|
endif()
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
2022-09-26 17:08:04 -06:00
|
|
|
if(HAVE_DLOPEN_IN_LIBC OR HAVE_DLOPEN_IN_LIBDL)
|
|
|
|
set(HAVE_DLOPEN TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
2022-09-26 17:08:04 -06:00
|
|
|
cmake_pop_check_state()
|
2015-06-21 09:33:46 -06:00
|
|
|
endmacro()
|
|
|
|
|
2021-11-27 09:10:10 -07:00
|
|
|
macro(CheckO_CLOEXEC)
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <fcntl.h>
|
|
|
|
int flag = O_CLOEXEC;
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_O_CLOEXEC)
|
2021-11-27 09:10:10 -07:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckOSS)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_OSS)
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/soundcard.h>
|
2022-09-26 17:52:28 -06:00
|
|
|
int main(int argc, char **argv) { int arg = SNDCTL_DSP_SETFRAGMENT; return 0; }" HAVE_OSS_SYS_SOUNDCARD_H)
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2022-10-17 05:23:40 -06:00
|
|
|
if(HAVE_OSS_SYS_SOUNDCARD_H)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_OSS TRUE)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB OSS_SOURCES ${SDL3_SOURCE_DIR}/src/audio/dsp/*.c)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_OSS 1)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${OSS_SOURCES})
|
2022-10-17 05:23:40 -06:00
|
|
|
if(NETBSD)
|
2015-06-21 09:33:46 -06:00
|
|
|
list(APPEND EXTRA_LIBS ossaudio)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_ALSA_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 09:33:46 -06:00
|
|
|
macro(CheckALSA)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_ALSA)
|
2015-06-21 09:33:46 -06:00
|
|
|
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
|
|
|
|
if(HAVE_ASOUNDLIB_H)
|
2016-10-07 19:03:08 -06:00
|
|
|
CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND)
|
|
|
|
endif()
|
|
|
|
if(HAVE_LIBASOUND)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_ALSA TRUE)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB ALSA_SOURCES ${SDL3_SOURCE_DIR}/src/audio/alsa/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${ALSA_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_ALSA 1)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
|
|
|
|
endif()
|
2022-06-14 19:16:28 -06:00
|
|
|
FindLibraryAndSONAME("asound")
|
|
|
|
if(SDL_ALSA_SHARED AND ASOUND_LIB AND HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
|
|
|
|
set(HAVE_ALSA_SHARED TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS asound)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-02-13 09:56:05 -07:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_PIPEWIRE_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2021-02-13 09:56:05 -07:00
|
|
|
macro(CheckPipewire)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_PIPEWIRE)
|
2021-02-13 09:56:05 -07:00
|
|
|
pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20)
|
|
|
|
if(PKG_PIPEWIRE_FOUND)
|
|
|
|
set(HAVE_PIPEWIRE TRUE)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB PIPEWIRE_SOURCES ${SDL3_SOURCE_DIR}/src/audio/pipewire/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${PIPEWIRE_SOURCES})
|
2021-02-13 09:56:05 -07:00
|
|
|
set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
|
|
|
|
endif()
|
2022-10-19 17:11:39 -06:00
|
|
|
FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS})
|
2022-06-14 19:16:28 -06:00
|
|
|
if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
|
|
|
|
set(HAVE_PIPEWIRE_SHARED TRUE)
|
2021-02-13 09:56:05 -07:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_PULSEAUDIO_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 09:33:46 -06:00
|
|
|
macro(CheckPulseAudio)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_PULSEAUDIO)
|
2015-06-21 09:33:46 -06:00
|
|
|
pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
|
|
|
|
if(PKG_PULSEAUDIO_FOUND)
|
|
|
|
set(HAVE_PULSEAUDIO TRUE)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB PULSEAUDIO_SOURCES ${SDL3_SOURCE_DIR}/src/audio/pulseaudio/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${PULSEAUDIO_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
|
|
|
|
endif()
|
2022-10-19 17:11:39 -06:00
|
|
|
FindLibraryAndSONAME("pulse-simple" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS})
|
2022-06-14 19:16:28 -06:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
|
|
|
|
set(HAVE_PULSEAUDIO_SHARED TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
2022-03-07 00:54:24 -07:00
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
|
2017-06-08 11:27:58 -06:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2022-11-22 12:04:10 -07:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - SDL_SNDIO_SHARED opt
|
|
|
|
# - HAVE_SDL_LOADSO opt
|
|
|
|
macro(CheckSNDIO)
|
|
|
|
if(SDL_SNDIO)
|
|
|
|
pkg_check_modules(PKG_SNDIO sndio)
|
|
|
|
if(PKG_SNDIO_FOUND)
|
|
|
|
set(HAVE_SNDIO TRUE)
|
|
|
|
file(GLOB SNDIO_SOURCES ${SDL3_SOURCE_DIR}/src/audio/sndio/*.c)
|
|
|
|
list(APPEND SOURCE_FILES ${SNDIO_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_SNDIO 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_SNDIO_CFLAGS})
|
|
|
|
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
|
|
|
|
endif()
|
|
|
|
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)
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${PKG_SNDIO_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2022-11-22 20:50:20 -07:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - SDL_JACK_SHARED opt
|
|
|
|
# - HAVE_SDL_LOADSO opt
|
|
|
|
macro(CheckJACK)
|
|
|
|
if(SDL_JACK)
|
|
|
|
pkg_check_modules(PKG_JACK jack)
|
|
|
|
if(PKG_JACK_FOUND)
|
|
|
|
set(HAVE_JACK TRUE)
|
|
|
|
file(GLOB JACK_SOURCES ${SDL3_SOURCE_DIR}/src/audio/jack/*.c)
|
|
|
|
list(APPEND SOURCE_FILES ${JACK_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_JACK 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
|
|
|
|
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" 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)
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2017-01-06 21:43:53 -07:00
|
|
|
# Requires:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_LIBSAMPLERATE
|
2017-01-06 21:43:53 -07:00
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_LIBSAMPLERATE_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-01-06 21:43:53 -07:00
|
|
|
macro(CheckLibSampleRate)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_LIBSAMPLERATE)
|
2022-06-16 11:59:57 -06:00
|
|
|
find_package(SampleRate QUIET)
|
|
|
|
if(SampleRate_FOUND AND TARGET SampleRate::samplerate)
|
2018-02-13 14:25:59 -07:00
|
|
|
set(HAVE_LIBSAMPLERATE TRUE)
|
2022-06-16 11:59:57 -06:00
|
|
|
set(HAVE_LIBSAMPLERATE_H TRUE)
|
|
|
|
if(SDL_LIBSAMPLERATE_SHARED)
|
|
|
|
target_include_directories(sdl-build-options INTERFACE $<TARGET_PROPERTY:SampleRate::samplerate,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
if(NOT HAVE_SDL_LOADSO)
|
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
|
|
|
|
else()
|
|
|
|
get_property(_samplerate_type TARGET SampleRate::samplerate PROPERTY TYPE)
|
|
|
|
if(_samplerate_type STREQUAL "SHARED_LIBRARY")
|
|
|
|
set(HAVE_LIBSAMPLERATE_SHARED TRUE)
|
2022-11-22 09:18:47 -07:00
|
|
|
if(WIN32)
|
2022-06-16 11:59:57 -06:00
|
|
|
set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_FILE_NAME:SampleRate::samplerate>\"")
|
|
|
|
else()
|
|
|
|
set(SDL_LIBSAMPLERATE_DYNAMIC "\"$<TARGET_SONAME_FILE_NAME:SampleRate::samplerate>\"")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-01-06 21:43:53 -07:00
|
|
|
else()
|
2022-06-16 11:59:57 -06:00
|
|
|
target_link_libraries(sdl-build-options INTERFACE SampleRate::samplerate)
|
|
|
|
list(APPEND SDL_REQUIRES_PRIVATE SampleRate::samplerate)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
|
|
|
|
if(HAVE_LIBSAMPLERATE_H)
|
|
|
|
set(HAVE_LIBSAMPLERATE TRUE)
|
|
|
|
if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
|
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
|
|
|
|
endif()
|
|
|
|
FindLibraryAndSONAME("samplerate")
|
|
|
|
if(SDL_LIBSAMPLERATE_SHARED AND SAMPLERATE_LIB AND HAVE_SDL_LOADSO)
|
|
|
|
set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
|
|
|
|
set(HAVE_LIBSAMPLERATE_SHARED TRUE)
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS -lsamplerate)
|
|
|
|
endif()
|
2017-01-06 21:43:53 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_X11_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 09:33:46 -06:00
|
|
|
macro(CheckX11)
|
2022-11-24 12:39:55 -07:00
|
|
|
cmake_push_check_state(RESET)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_X11)
|
2022-04-26 14:41:28 -06:00
|
|
|
foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss)
|
2015-06-21 09:33:46 -06:00
|
|
|
FindLibraryAndSONAME("${_LIB}")
|
|
|
|
endforeach()
|
|
|
|
|
2022-07-21 10:38:12 -06:00
|
|
|
set(X11_dirs)
|
|
|
|
find_path(X_INCLUDEDIR
|
|
|
|
NAMES X11/Xlib.h
|
|
|
|
PATHS
|
2018-06-24 13:12:18 -06: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
|
|
|
|
)
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
if(X_INCLUDEDIR)
|
2018-06-24 13:12:18 -06:00
|
|
|
list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
|
2022-11-24 12:39:55 -07:00
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${X_INCLUDEDIR})
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
2022-07-21 10:38:12 -06:00
|
|
|
find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XINPUT2_H NAMES "X11/extensions/XInput2.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XRANDR_H NAMES "X11/extensions/Xrandr.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XFIXES_H_ NAMES "X11/extensions/Xfixes.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XRENDER_H NAMES "X11/extensions/Xrender.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XSS_H NAMES "X11/extensions/scrnsaver.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XSHAPE_H NAMES "X11/extensions/shape.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XDBE_H NAMES "X11/extensions/Xdbe.h" HINTS "${X_INCLUDEDIR}")
|
|
|
|
find_file(HAVE_XEXT_H NAMES "X11/extensions/Xext.h" HINTS "${X_INCLUDEDIR}")
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
if(X11_LIB)
|
|
|
|
if(NOT HAVE_XEXT_H)
|
|
|
|
message_error("Missing Xext.h, maybe you need to install the libxext-dev package?")
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11 TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB X11_SOURCES ${SDL3_SOURCE_DIR}/src/video/x11/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${X11_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11 1)
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
# !!! FIXME: why is this disabled for Apple?
|
2015-06-21 09:33:46 -06:00
|
|
|
if(APPLE)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(SDL_X11_SHARED OFF)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
2022-09-26 17:59:37 -06: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)
|
2015-06-21 09:33:46 -06:00
|
|
|
list(APPEND EXTRA_LIBS ipc)
|
|
|
|
endif()
|
2022-09-26 17:59:37 -06:00
|
|
|
if(NOT HAVE_SHMAT_IN_LIBIPC)
|
2018-06-24 13:12:18 -06:00
|
|
|
list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY")
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_X11_SHARED)
|
2021-08-10 11:55:50 -06:00
|
|
|
if(NOT HAVE_SDL_LOADSO)
|
2015-06-21 09:33:46 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
|
|
|
|
set(HAVE_X11_SHARED FALSE)
|
|
|
|
else()
|
|
|
|
set(HAVE_X11_SHARED TRUE)
|
|
|
|
endif()
|
2022-06-16 11:53:58 -06:00
|
|
|
if(X11_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${X11_LIB})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(XEXT_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XEXT_LIB_SONAME})
|
|
|
|
endif()
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
2022-03-07 00:54:24 -07:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
|
|
|
|
|
|
|
|
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 10:10:52 -06:00
|
|
|
XFreeEventData(display, cookie);
|
|
|
|
return 0; }" HAVE_XGENERICEVENT)
|
2015-06-21 09:33:46 -06:00
|
|
|
if(HAVE_XGENERICEVENT)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 13:22:09 -06:00
|
|
|
check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2022-07-21 06:38:57 -06:00
|
|
|
if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11_XCURSOR TRUE)
|
2022-07-21 06:38:57 -06:00
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
|
|
|
|
endif()
|
|
|
|
|
2021-11-16 16:59:38 -07: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 06:38:57 -06:00
|
|
|
if(SDL_X11_XINPUT AND HAVE_XINPUT2_H AND XI_LIB)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11_XINPUT TRUE)
|
2022-07-21 06:38:57 -06:00
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XI_LIB})
|
|
|
|
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 14:10:02 -06:00
|
|
|
Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) {
|
2015-06-21 09:33:46 -06:00
|
|
|
return (Status)0;
|
|
|
|
}
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT2_MULTITOUCH)
|
2015-06-21 09:33:46 -06:00
|
|
|
if(HAVE_XINPUT2_MULTITOUCH)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-11-12 02:55:50 -07:00
|
|
|
# check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer
|
2021-12-06 10:37:52 -07: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 10:10:52 -06:00
|
|
|
int main(int argc, char **argv) { return 0; }" HAVE_XFIXES_H)
|
2021-12-06 10:37:52 -07:00
|
|
|
endif()
|
2022-07-21 07:19:19 -06:00
|
|
|
if(SDL_X11_XFIXES AND HAVE_XFIXES_H AND HAVE_XINPUT2_H AND XFIXES_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2021-11-08 11:52:48 -07:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XFIXES_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XFIXES 1)
|
2021-11-12 02:55:50 -07:00
|
|
|
set(HAVE_X11_XFIXES TRUE)
|
2021-11-08 11:52:48 -07:00
|
|
|
endif()
|
|
|
|
|
2022-07-21 07:19:19 -06:00
|
|
|
if(SDL_X11_XRANDR AND HAVE_XRANDR_H AND XRANDR_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XRANDR_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11_XRANDR TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
2022-07-21 07:19:19 -06:00
|
|
|
if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H AND XSS_LIB)
|
|
|
|
if(HAVE_X11_SHARED)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XSS_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11_XSCRNSAVER TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_X11_XSHAPE TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-10-05 08:43:35 -06:00
|
|
|
if(NOT HAVE_X11)
|
2021-05-06 07:43:16 -06:00
|
|
|
# Prevent Mesa from including X11 headers
|
|
|
|
list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11")
|
|
|
|
endif()
|
2022-11-24 12:39:55 -07:00
|
|
|
cmake_pop_check_state()
|
2015-06-21 09:33:46 -06:00
|
|
|
endmacro()
|
|
|
|
|
2021-01-14 15:50:15 -07:00
|
|
|
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
|
2016-10-11 14:36:40 -06: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-14 15:50:15 -07:00
|
|
|
ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
|
2016-10-11 14:36:40 -06:00
|
|
|
)
|
|
|
|
|
2022-06-26 15:34:30 -06:00
|
|
|
list(APPEND SDL_GENERATED_HEADERS "${_WAYLAND_PROT_H_CODE}")
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES "${_WAYLAND_PROT_C_CODE}")
|
2016-10-11 14:36:40 -06:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_WAYLAND_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 09:33:46 -06:00
|
|
|
macro(CheckWayland)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_WAYLAND)
|
2022-10-19 17:11:39 -06:00
|
|
|
set(WAYLAND_FOUND FALSE)
|
|
|
|
pkg_check_modules(PKG_WAYLAND "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
|
2016-10-11 14:36:40 -06:00
|
|
|
|
2022-10-19 17:11:39 -06:00
|
|
|
if(PKG_WAYLAND_FOUND)
|
|
|
|
set(WAYLAND_FOUND TRUE)
|
2021-10-25 10:04:07 -06:00
|
|
|
find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)
|
2016-10-11 14:36:40 -06:00
|
|
|
execute_process(
|
2021-10-25 10:04:07 -06:00
|
|
|
COMMAND ${WAYLAND_SCANNER} --version
|
|
|
|
RESULT_VARIABLE WAYLAND_SCANNER_VERSION_RC
|
|
|
|
ERROR_VARIABLE WAYLAND_SCANNER_VERSION
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
2016-10-11 14:36:40 -06:00
|
|
|
)
|
2021-10-25 10:04:07 -06:00
|
|
|
if(NOT WAYLAND_SCANNER_VERSION_RC EQUAL 0)
|
|
|
|
message(FATAL "Failed to get wayland-scanner version")
|
2016-10-11 14:36:40 -06:00
|
|
|
set(WAYLAND_FOUND FALSE)
|
|
|
|
endif()
|
2021-10-25 10:04:07 -06:00
|
|
|
string(REPLACE "wayland-scanner " "" WAYLAND_SCANNER_VERSION ${WAYLAND_SCANNER_VERSION})
|
2016-10-11 14:36:40 -06:00
|
|
|
|
2021-12-18 13:56:10 -07:00
|
|
|
string(COMPARE LESS ${WAYLAND_SCANNER_VERSION} "1.15.0" WAYLAND_SCANNER_PRE_1_15)
|
|
|
|
if(WAYLAND_SCANNER_PRE_1_15)
|
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "code")
|
2021-12-18 07:15:08 -07:00
|
|
|
else()
|
2021-01-14 15:50:15 -07:00
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "private-code")
|
|
|
|
endif()
|
2021-10-25 10:04:07 -06:00
|
|
|
endif()
|
2021-01-14 15:50:15 -07:00
|
|
|
|
2021-10-25 10:04:07 -06:00
|
|
|
if(WAYLAND_FOUND)
|
2022-10-19 17:11:39 -06:00
|
|
|
target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}")
|
|
|
|
target_include_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}")
|
2021-10-05 10:34:29 -06:00
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_WAYLAND TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB WAYLAND_SOURCES ${SDL3_SOURCE_DIR}/src/video/wayland/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${WAYLAND_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2016-10-11 14:36:40 -06:00
|
|
|
# We have to generate some protocol interface code for some unstable Wayland features.
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols")
|
2021-10-05 10:34:29 -06:00
|
|
|
target_include_directories(sdl-build-options INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols")
|
2016-10-11 14:36:40 -06:00
|
|
|
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL3_SOURCE_DIR}/wayland-protocols/" "${SDL3_SOURCE_DIR}/wayland-protocols/*.xml")
|
2018-06-25 10:37:25 -06:00
|
|
|
foreach(_XML ${WAYLAND_PROTOCOLS_XML})
|
|
|
|
string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}")
|
2022-11-21 21:28:58 -07:00
|
|
|
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL3_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
|
2016-10-11 14:36:40 -06:00
|
|
|
endforeach()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_WAYLAND_QT_TOUCH)
|
|
|
|
set(HAVE_WAYLAND_QT_TOUCH TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
|
|
|
|
endif()
|
2022-10-19 17:11:39 -06:00
|
|
|
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})
|
2022-06-14 19:16:28 -06: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-23 21:59:54 -06: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)
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
2022-10-19 17:11:39 -06:00
|
|
|
list(APPEND EXTRA_LIBS ${PKG_WAYLAND_LIBRARIES})
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_WAYLAND_LIBDECOR)
|
2022-10-19 17:11:39 -06:00
|
|
|
pkg_check_modules(PKG_LIBDECOR libdecor-0)
|
2022-10-21 07:31:43 -06:00
|
|
|
if(PKG_LIBDECOR_FOUND)
|
2021-08-03 01:10:14 -06:00
|
|
|
set(HAVE_WAYLAND_LIBDECOR TRUE)
|
2021-08-03 05:01:02 -06:00
|
|
|
set(HAVE_LIBDECOR_H 1)
|
2022-10-19 17:11:39 -06:00
|
|
|
target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}")
|
|
|
|
target_include_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}")
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-03 05:01:02 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
|
2021-08-23 21:59:54 -06:00
|
|
|
endif()
|
2022-10-19 17:11:39 -06:00
|
|
|
FindLibraryAndSONAME(decor-0 LIBDIRS ${PKG_LIBDECOR_LIBRARY_DIRS})
|
2022-06-14 19:16:28 -06:00
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND DECOR_0_LIB AND HAVE_SDL_LOADSO)
|
2022-10-21 07:31:43 -06:00
|
|
|
set(HAVE_WAYLAND_LIBDECOR_SHARED TRUE)
|
2021-08-03 05:01:02 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
|
|
|
|
else()
|
2022-10-19 17:11:39 -06:00
|
|
|
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
|
2021-08-03 05:01:02 -06:00
|
|
|
endif()
|
2021-08-03 01:10:14 -06:00
|
|
|
endif()
|
2020-06-11 15:10:28 -06:00
|
|
|
endif()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
#
|
|
|
|
macro(CheckCOCOA)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_COCOA)
|
2015-06-21 09:33:46 -06:00
|
|
|
if(APPLE) # Apple always has Cocoa.
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_COCOA TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_COCOA)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB COCOA_SOURCES ${SDL3_SOURCE_DIR}/src/video/cocoa/*.m)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${COCOA_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_COCOA 1)
|
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckVivante)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_VIVANTE)
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <gc_vdk.h>
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_VDK)
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#define LINUX
|
|
|
|
#define EGL_API_FB
|
|
|
|
#include <EGL/eglvivante.h>
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_VIVANTE_EGL_FB)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
|
|
|
|
set(HAVE_VIVANTE TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB VIVANTE_SOURCES ${SDL3_SOURCE_DIR}/src/video/vivante/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${VIVANTE_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE 1)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_VIVANTE_VDK)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
|
2022-03-23 09:07:52 -06:00
|
|
|
find_library(VIVANTE_LIBRARY REQUIRED NAMES VIVANTE vivante drm_vivante)
|
|
|
|
find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED)
|
|
|
|
list(APPEND EXTRA_LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY})
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
2022-06-15 09:10:31 -06:00
|
|
|
list(APPEND SDL_CFLAGS -DLINUX -DEGL_API_FB)
|
2015-06-21 09:33:46 -06:00
|
|
|
list(APPEND EXTRA_LIBS EGL)
|
2021-10-05 08:43:35 -06:00
|
|
|
endif(HAVE_VIVANTE_VDK)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
2021-05-06 07:43:16 -06:00
|
|
|
macro(CheckGLX)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <GL/glx.h>
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL_GLX)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_OPENGL_GLX)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_OPENGL_GLX 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-03-11 02:10:29 -07:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
macro(CheckEGL)
|
2021-10-05 08:43:35 -06:00
|
|
|
if (SDL_OPENGL OR SDL_OPENGLES)
|
2021-05-06 07:43:16 -06:00
|
|
|
pkg_check_modules(EGL egl)
|
2022-01-10 14:52:02 -07:00
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${EGL_CFLAGS}")
|
2020-12-22 09:17:30 -07:00
|
|
|
check_c_source_compiles("
|
2021-05-06 07:43:16 -06: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 10:10:52 -06:00
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGL_EGL)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_OPENGL_EGL)
|
2021-05-06 07:43:16 -06:00
|
|
|
set(SDL_VIDEO_OPENGL_EGL 1)
|
2020-12-22 09:17:30 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
2021-05-06 07:43:16 -06:00
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGL)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
2021-05-06 07:43:16 -06:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
2022-03-13 10:10:52 -06:00
|
|
|
int main(int argc, char** argv) { return 0; }" HAVE_OPENGL)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_OPENGL)
|
2021-05-06 07:43:16 -06:00
|
|
|
set(SDL_VIDEO_OPENGL 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL 1)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
2021-05-06 07:43:16 -06:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGLES)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_OPENGLES)
|
2022-11-23 08:50:02 -07:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V1)
|
|
|
|
if(HAVE_OPENGLES_V1)
|
|
|
|
set(HAVE_OPENGLES TRUE)
|
|
|
|
set(SDL_VIDEO_OPENGL_ES 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL_ES 1)
|
|
|
|
endif()
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
2021-05-06 07:43:16 -06:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#include <GLES2/gl2ext.h>
|
2022-03-13 10:10:52 -06:00
|
|
|
int main (int argc, char** argv) { return 0; }" HAVE_OPENGLES_V2)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(HAVE_OPENGLES_V2)
|
|
|
|
set(HAVE_OPENGLES TRUE)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(SDL_VIDEO_OPENGL_ES2 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL_ES2 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
|
|
|
# Optional:
|
|
|
|
# - THREADS opt
|
|
|
|
# Sets:
|
|
|
|
# PTHREAD_CFLAGS
|
|
|
|
# PTHREAD_LIBS
|
|
|
|
macro(CheckPTHREAD)
|
2021-11-14 21:34:41 -07:00
|
|
|
if(SDL_THREADS AND SDL_PTHREADS)
|
2017-08-09 17:50:18 -06: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 09:33:46 -06: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 02:49:15 -06:00
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
2015-06-21 09:33:46 -06: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-03 22:16:30 -06:00
|
|
|
elseif(EMSCRIPTEN)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -pthread")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Run some tests
|
2016-09-13 01:03:50 -06:00
|
|
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
|
2021-04-22 16:56:10 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
pthread_attr_t type;
|
|
|
|
pthread_attr_init(&type);
|
|
|
|
return 0;
|
|
|
|
}" HAVE_PTHREADS)
|
2015-06-21 09:33:46 -06:00
|
|
|
if(HAVE_PTHREADS)
|
|
|
|
set(SDL_THREAD_PTHREAD 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
|
2022-06-15 09:10:31 -06:00
|
|
|
list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS})
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
check_c_source_compiles("
|
2021-04-22 16:56:10 -06:00
|
|
|
#define _GNU_SOURCE 1
|
2015-06-21 09:33:46 -06:00
|
|
|
#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("
|
2021-04-22 16:56:10 -06:00
|
|
|
#define _GNU_SOURCE 1
|
2015-06-21 09:33:46 -06:00
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
pthread_mutexattr_t attr;
|
2017-07-10 19:40:35 -06:00
|
|
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
2015-06-21 09:33:46 -06: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 08:43:35 -06:00
|
|
|
if(SDL_PTHREADS_SEM)
|
2015-06-21 09:33:46 -06: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;
|
|
|
|
}" HAVE_SEM_TIMEDWAIT)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 13:22:09 -06:00
|
|
|
check_include_files("pthread.h" HAVE_PTHREAD_H)
|
|
|
|
check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
|
|
|
|
if (HAVE_PTHREAD_H)
|
2021-11-16 16:59:38 -07:00
|
|
|
check_c_source_compiles("
|
|
|
|
#define _GNU_SOURCE 1
|
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
pthread_setname_np(pthread_self(), \"\");
|
|
|
|
return 0;
|
|
|
|
}" HAVE_PTHREAD_SETNAME_NP)
|
2020-04-13 13:22:09 -06: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 09:33:46 -06:00
|
|
|
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
2022-11-21 21:28:58 -07:00
|
|
|
${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_systls.c
|
2015-06-21 09:33:46 -06:00
|
|
|
)
|
|
|
|
if(HAVE_PTHREADS_SEM)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
2022-11-21 21:28:58 -07:00
|
|
|
${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
|
2015-06-21 09:33:46 -06:00
|
|
|
else()
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
2022-11-21 21:28:58 -07:00
|
|
|
${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_THREADS TRUE)
|
|
|
|
endif()
|
2017-07-10 19:40:35 -06:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires
|
|
|
|
# - nada
|
|
|
|
# Optional:
|
|
|
|
# Sets:
|
|
|
|
# USB_LIBS
|
|
|
|
# USB_CFLAGS
|
|
|
|
macro(CheckUSBHID)
|
|
|
|
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)
|
|
|
|
set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
|
|
|
|
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)
|
|
|
|
set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
|
|
|
|
endif()
|
|
|
|
check_library_exists(usb hid_init "" LIBUSB)
|
|
|
|
if(LIBUSB)
|
|
|
|
set(USB_LIBS ${USB_LIBS} usb)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-13 01:03:50 -06:00
|
|
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}")
|
2015-06-21 09:33:46 -06:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#if defined(HAVE_USB_H)
|
|
|
|
#include <usb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef __DragonFly__
|
2020-12-20 13:08:49 -07:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 09:33:46 -06: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 13:08:49 -07:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 09:33:46 -06: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)
|
|
|
|
set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/types.h>
|
|
|
|
#if defined(HAVE_USB_H)
|
|
|
|
#include <usb.h>
|
|
|
|
#endif
|
|
|
|
#ifdef __DragonFly__
|
2020-12-20 13:08:49 -07:00
|
|
|
#include <bus/u4b/usb.h>
|
|
|
|
#include <bus/u4b/usbhid.h>
|
2015-06-21 09:33:46 -06: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)
|
|
|
|
set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
|
|
|
|
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 07:24:28 -07:00
|
|
|
set(SDL_HAVE_MACHINE_JOYSTICK_H 1)
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
set(SDL_JOYSTICK_USBHID 1)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB BSD_JOYSTICK_SOURCES ${SDL3_SOURCE_DIR}/src/joystick/bsd/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${BSD_JOYSTICK_SOURCES})
|
2015-06-21 09:33:46 -06:00
|
|
|
list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
|
|
|
|
list(APPEND EXTRA_LIBS ${USB_LIBS})
|
|
|
|
set(HAVE_SDL_JOYSTICK TRUE)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
2016-09-13 01:03:50 -06:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 09:33:46 -06:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-11-11 10:16:44 -07:00
|
|
|
# Check for HIDAPI support
|
2019-07-08 14:46:52 -06:00
|
|
|
macro(CheckHIDAPI)
|
2021-11-11 10:16:44 -07:00
|
|
|
set(HAVE_HIDAPI TRUE)
|
2022-07-25 18:51:07 -06:00
|
|
|
if(SDL_HIDAPI)
|
|
|
|
if(SDL_HIDAPI_LIBUSB)
|
|
|
|
set(HAVE_LIBUSB FALSE)
|
2022-10-19 17:11:39 -06:00
|
|
|
pkg_check_modules(PKG_LIBUSB libusb-1.0)
|
|
|
|
if(PKG_LIBUSB_FOUND)
|
|
|
|
check_include_file(libusb.h HAVE_LIBUSB_H ${PKG_LIBUSB_CFLAGS})
|
2022-07-25 18:51:07 -06:00
|
|
|
if(HAVE_LIBUSB_H)
|
|
|
|
set(HAVE_LIBUSB TRUE)
|
2022-10-19 17:11:39 -06:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PKG_LIBUSB_CFLAGS}")
|
2022-07-25 18:51:07 -06:00
|
|
|
if(HIDAPI_ONLY_LIBUSB)
|
2022-10-19 17:11:39 -06:00
|
|
|
list(APPEND EXTRA_LIBS ${PKG_LIBUSB_LIBRARIES})
|
2022-07-25 18:51:07 -06:00
|
|
|
else()
|
|
|
|
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
|
2022-10-19 17:11:39 -06:00
|
|
|
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PKG_LIBUSB_LIBRARY_DIRS})
|
2022-07-25 18:51:07 -06:00
|
|
|
if(USB_1.0_LIB)
|
|
|
|
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
|
|
|
endif()
|
2022-06-14 19:16:28 -06:00
|
|
|
endif()
|
2019-07-31 10:20:55 -06:00
|
|
|
endif()
|
2019-07-08 14:46:52 -06:00
|
|
|
endif()
|
2022-07-25 18:51:07 -06:00
|
|
|
if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
|
|
|
|
set(HAVE_HIDAPI FALSE)
|
|
|
|
endif()
|
2022-09-10 07:53:11 -06:00
|
|
|
set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB})
|
2019-07-08 14:46:52 -06:00
|
|
|
endif()
|
2021-11-11 10:16:44 -07:00
|
|
|
|
2022-07-25 18:51:07 -06:00
|
|
|
if(HAVE_HIDAPI)
|
|
|
|
if(ANDROID)
|
2022-11-21 21:28:58 -07:00
|
|
|
list(APPEND SOURCE_FILES ${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp)
|
2022-07-25 18:51:07 -06:00
|
|
|
endif()
|
|
|
|
if(IOS OR TVOS)
|
2022-11-21 21:28:58 -07:00
|
|
|
list(APPEND SOURCE_FILES ${SDL3_SOURCE_DIR}/src/hidapi/ios/hid.m)
|
2022-07-25 18:51:07 -06: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)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB HIDAPI_JOYSTICK_SOURCES ${SDL3_SOURCE_DIR}/src/joystick/hidapi/*.c)
|
2022-07-25 18:51:07 -06:00
|
|
|
list(APPEND SOURCE_FILES ${HIDAPI_JOYSTICK_SOURCES})
|
|
|
|
endif()
|
2022-09-10 05:41:29 -06:00
|
|
|
else()
|
2022-09-10 06:11:19 -06:00
|
|
|
set(SDL_HIDAPI_DISABLED 1)
|
2021-11-11 10:16:44 -07:00
|
|
|
endif()
|
2022-07-25 18:51:07 -06:00
|
|
|
else()
|
|
|
|
set(SDL_HIDAPI_DISABLED 1)
|
2019-07-08 14:46:52 -06:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckRPI)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_RPI)
|
2018-01-17 14:17:10 -07:00
|
|
|
pkg_check_modules(VIDEO_RPI bcm_host brcmegl)
|
|
|
|
if (NOT VIDEO_RPI_FOUND)
|
|
|
|
set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
|
|
|
|
set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
|
|
|
|
set(VIDEO_RPI_LIBRARIES bcm_host )
|
2018-02-07 15:12:26 -07:00
|
|
|
set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
|
2018-01-17 14:17:10 -07:00
|
|
|
endif()
|
2015-06-21 09:33:46 -06:00
|
|
|
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
|
|
|
|
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
|
|
|
|
|
2016-09-13 01:03:50 -06:00
|
|
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
2018-01-17 14:17:10 -07:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
|
2015-06-21 09:33:46 -06:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <bcm_host.h>
|
2022-01-05 19:02:38 -07:00
|
|
|
#include <EGL/eglplatform.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
EGL_DISPMANX_WINDOW_T window;
|
|
|
|
bcm_host_init();
|
|
|
|
}" HAVE_RPI)
|
2016-09-13 01:03:50 -06:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 09:33:46 -06:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_VIDEO AND HAVE_RPI)
|
2015-06-21 09:33:46 -06:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_RPI 1)
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB VIDEO_RPI_SOURCES ${SDL3_SOURCE_DIR}/src/video/raspberry/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${VIDEO_RPI_SOURCES})
|
2018-01-17 14:17:10 -07:00
|
|
|
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
|
2021-10-05 10:34:29 -06:00
|
|
|
# !!! FIXME: shouldn't be using CMAKE_C_FLAGS, right?
|
2015-06-21 09:33:46 -06:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
2018-02-07 15:12:26 -07:00
|
|
|
list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
|
2021-10-05 08:43:35 -06:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2017-08-02 11:22:48 -06:00
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 08:43:35 -06:00
|
|
|
# - SDL_KMSDRM_SHARED opt
|
2021-08-10 11:55:50 -06:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-08-02 11:22:48 -06:00
|
|
|
macro(CheckKMSDRM)
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_KMSDRM)
|
2022-10-19 17:11:39 -06:00
|
|
|
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}")
|
2021-10-05 08:43:35 -06:00
|
|
|
set(HAVE_KMSDRM TRUE)
|
2017-08-02 11:22:48 -06:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
2022-11-21 21:28:58 -07:00
|
|
|
file(GLOB KMSDRM_SOURCES ${SDL3_SOURCE_DIR}/src/video/kmsdrm/*.c)
|
2022-06-14 19:03:33 -06:00
|
|
|
list(APPEND SOURCE_FILES ${KMSDRM_SOURCES})
|
2017-08-02 11:22:48 -06:00
|
|
|
|
2022-10-19 17:11:39 -06:00
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_KMSDRM_CFLAGS})
|
2017-08-02 11:22:48 -06:00
|
|
|
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM 1)
|
|
|
|
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-23 21:59:54 -06:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
|
|
|
|
endif()
|
2021-10-05 08:43:35 -06:00
|
|
|
if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
|
2022-10-19 17:11:39 -06:00
|
|
|
FindLibraryAndSONAME(drm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
|
|
|
|
FindLibraryAndSONAME(gbm LIBDIRS ${PKG_KMSDRM_LIBRARY_DIRS})
|
2021-08-23 21:59:54 -06:00
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "\"${DRM_LIB_SONAME}\"")
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "\"${GBM_LIB_SONAME}\"")
|
|
|
|
set(HAVE_KMSDRM_SHARED TRUE)
|
2017-08-02 11:22:48 -06:00
|
|
|
else()
|
2022-10-19 17:11:39 -06:00
|
|
|
list(APPEND EXTRA_LIBS ${PKG_KMSDRM_LIBRARIES})
|
2017-08-02 11:22:48 -06:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|