2015-06-21 15:33:46 +00:00
|
|
|
macro(FindLibraryAndSONAME _LIB)
|
|
|
|
string(TOUPPER ${_LIB} _UPPERLNAME)
|
|
|
|
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
|
|
|
|
|
|
|
|
find_library(${_LNAME}_LIB ${_LIB})
|
|
|
|
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)
|
2020-04-13 19:22:09 +00:00
|
|
|
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(NOT HAVE_DLOPEN)
|
2021-08-10 17:55:50 +00:00
|
|
|
check_library_exists(dl dlopen "" DLOPEN_LIB)
|
|
|
|
if(DLOPEN_LIB)
|
|
|
|
list(APPEND EXTRA_LIBS dl)
|
|
|
|
set(_DLLIB dl)
|
|
|
|
set(HAVE_DLOPEN TRUE)
|
|
|
|
endif()
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_DLOPEN)
|
|
|
|
if(_DLLIB)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
|
|
|
|
endif()
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <dlfcn.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
void *handle = dlopen(\"\", RTLD_NOW);
|
|
|
|
const char *loaderror = (char *) dlerror();
|
|
|
|
}" HAVE_DLOPEN)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckOSS)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_OSS)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(OSS_HEADER_FILE "sys/soundcard.h")
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <sys/soundcard.h>
|
|
|
|
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
|
|
|
|
if(NOT OSS_FOUND)
|
|
|
|
set(OSS_HEADER_FILE "soundcard.h")
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <soundcard.h>
|
|
|
|
int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OSS_FOUND)
|
|
|
|
set(HAVE_OSS TRUE)
|
|
|
|
file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
|
|
|
|
if(OSS_HEADER_FILE STREQUAL "soundcard.h")
|
|
|
|
set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
|
|
|
|
endif()
|
|
|
|
set(SDL_AUDIO_DRIVER_OSS 1)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
|
|
|
|
if(NETBSD OR OPENBSD)
|
|
|
|
list(APPEND EXTRA_LIBS ossaudio)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_ALSA_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckALSA)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ALSA)
|
2015-06-21 15:33:46 +00:00
|
|
|
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
|
|
|
|
if(HAVE_ASOUNDLIB_H)
|
2016-10-08 01:03:08 +00:00
|
|
|
CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND)
|
|
|
|
endif()
|
|
|
|
if(HAVE_LIBASOUND)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(HAVE_ALSA TRUE)
|
|
|
|
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_ALSA 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ALSA_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("asound")
|
|
|
|
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
|
|
|
|
set(HAVE_ALSA_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS asound)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-02-13 16:56:05 +00:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_PIPEWIRE_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2021-02-13 16:56:05 +00:00
|
|
|
macro(CheckPipewire)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PIPEWIRE)
|
2021-02-13 16:56:05 +00:00
|
|
|
pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20)
|
|
|
|
if(PKG_PIPEWIRE_FOUND)
|
|
|
|
set(HAVE_PIPEWIRE TRUE)
|
|
|
|
file(GLOB PIPEWIRE_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pipewire/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PIPEWIRE_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("pipewire-0.3")
|
|
|
|
set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
|
|
|
|
set(HAVE_PIPEWIRE_SHARED TRUE)
|
2021-02-13 16:56:05 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_PULSEAUDIO_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckPulseAudio)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PULSEAUDIO)
|
2015-06-21 15:33:46 +00:00
|
|
|
pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
|
|
|
|
if(PKG_PULSEAUDIO_FOUND)
|
|
|
|
set(HAVE_PULSEAUDIO TRUE)
|
|
|
|
file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_PULSEAUDIO_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("pulse-simple")
|
|
|
|
set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"")
|
|
|
|
set(HAVE_PULSEAUDIO_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
2021-10-05 14:43:35 +00:00
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_sPULSEAUDIO_LDFLAGS})
|
2017-06-08 17:27:58 +00:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_JACK_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-06-08 17:27:58 +00:00
|
|
|
macro(CheckJACK)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_JACK)
|
2017-06-08 17:27:58 +00:00
|
|
|
pkg_check_modules(PKG_JACK jack)
|
|
|
|
if(PKG_JACK_FOUND)
|
|
|
|
set(HAVE_JACK TRUE)
|
|
|
|
file(GLOB JACK_SOURCES ${SDL2_SOURCE_DIR}/src/audio/jack/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_JACK 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_JACK_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_JACK_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("jack")
|
|
|
|
set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
|
|
|
|
set(HAVE_JACK_SHARED TRUE)
|
2017-06-08 17:27:58 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_ESD_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckESD)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ESD)
|
2015-06-21 15:33:46 +00:00
|
|
|
pkg_check_modules(PKG_ESD esound)
|
|
|
|
if(PKG_ESD_FOUND)
|
|
|
|
set(HAVE_ESD TRUE)
|
|
|
|
file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_ESD 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ESD_SHARED AND NOT HAVE_SDL_LOADSO)
|
2015-06-21 15:33:46 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
|
2021-08-24 03:59:54 +00:00
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ESD_SHARED AND HAVE_SDL_LOADSO)
|
2015-06-21 15:33:46 +00:00
|
|
|
FindLibraryAndSONAME(esd)
|
|
|
|
set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${ESD_LIB_SONAME}\"")
|
|
|
|
set(HAVE_ESD_SHARED TRUE)
|
|
|
|
else()
|
2021-08-24 03:59:54 +00:00
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_ARTS_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckARTS)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ARTS)
|
2015-06-21 15:33:46 +00:00
|
|
|
find_program(ARTS_CONFIG arts-config)
|
|
|
|
if(ARTS_CONFIG)
|
|
|
|
execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
|
|
|
|
OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
|
|
|
|
execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
|
|
|
|
OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_ARTS 1)
|
|
|
|
set(HAVE_ARTS TRUE)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ARTS_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_ARTS_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
# TODO
|
|
|
|
FindLibraryAndSONAME(artsc)
|
|
|
|
set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${ARTSC_LIB_SONAME}\"")
|
|
|
|
set(HAVE_ARTS_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_NAS_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckNAS)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_NAS)
|
2015-06-21 15:33:46 +00:00
|
|
|
# TODO: set include paths properly, so the NAS headers are found
|
|
|
|
check_include_file(audio/audiolib.h HAVE_NAS_H)
|
|
|
|
find_library(D_NAS_LIB audio)
|
|
|
|
if(HAVE_NAS_H AND D_NAS_LIB)
|
|
|
|
set(HAVE_NAS TRUE)
|
|
|
|
file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_NAS 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_NAS_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_NAS_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("audio")
|
|
|
|
set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${AUDIO_LIB_SONAME}\"")
|
|
|
|
set(HAVE_NAS_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${D_NAS_LIB})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_SNDIO_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckSNDIO)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_SNDIO)
|
2015-06-21 15:33:46 +00:00
|
|
|
# TODO: set include paths properly, so the sndio headers are found
|
|
|
|
check_include_file(sndio.h HAVE_SNDIO_H)
|
|
|
|
find_library(D_SNDIO_LIB sndio)
|
|
|
|
if(HAVE_SNDIO_H AND D_SNDIO_LIB)
|
|
|
|
set(HAVE_SNDIO TRUE)
|
|
|
|
file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_SNDIO 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_SNDIO_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_SNDIO_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("sndio")
|
|
|
|
set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
|
|
|
|
set(HAVE_SNDIO_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - FUSIONSOUND_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckFusionSound)
|
|
|
|
if(FUSIONSOUND)
|
|
|
|
pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
|
|
|
|
if(PKG_FUSIONSOUND_FOUND)
|
|
|
|
set(HAVE_FUSIONSOUND TRUE)
|
|
|
|
file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
|
|
|
|
set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
|
2021-08-24 03:59:54 +00:00
|
|
|
if(FUSIONSOUND_SHARED AND NOT HAVE_SDL_LOADSO)
|
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
|
|
|
|
endif()
|
|
|
|
if(FUSIONSOUND_SHARED AND HAVE_SDL_LOADSO)
|
|
|
|
FindLibraryAndSONAME("fusionsound")
|
|
|
|
set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${FUSIONSOUND_LIB_SONAME}\"")
|
|
|
|
set(HAVE_FUSIONSOUND_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_AUDIO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2017-01-07 04:43:53 +00:00
|
|
|
# Requires:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_LIBSAMPLERATE
|
2017-01-07 04:43:53 +00:00
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_LIBSAMPLERATE_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-01-07 04:43:53 +00:00
|
|
|
macro(CheckLibSampleRate)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_LIBSAMPLERATE)
|
2017-01-07 04:43:53 +00:00
|
|
|
check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
|
|
|
|
if(HAVE_LIBSAMPLERATE_H)
|
2018-02-13 21:25:59 +00:00
|
|
|
set(HAVE_LIBSAMPLERATE TRUE)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_LIBSAMPLERATE_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_LIBSAMPLERATE_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("samplerate")
|
|
|
|
set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
|
|
|
|
set(HAVE_LIBSAMPLERATE_SHARED TRUE)
|
2017-01-07 04:43:53 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS -lsamplerate)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_X11_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckX11)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11)
|
2015-06-21 15:33:46 +00:00
|
|
|
foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
|
|
|
|
FindLibraryAndSONAME("${_LIB}")
|
|
|
|
endforeach()
|
|
|
|
|
2018-06-24 19:12:18 +00:00
|
|
|
find_path(X_INCLUDEDIR X11/Xlib.h
|
|
|
|
/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 15:33:46 +00:00
|
|
|
if(X_INCLUDEDIR)
|
2018-06-24 19:12:18 +00:00
|
|
|
list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
|
|
|
|
list(APPEND CMAKE_REQUIRED_INCLUDES "${X_INCLUDEDIR}")
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
|
|
|
|
check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
|
2021-01-29 20:11:13 +00:00
|
|
|
check_include_file(X11/extensions/XInput2.h HAVE_XINPUT2_H)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
|
|
|
|
check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
|
|
|
|
check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
|
|
|
|
check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
|
|
|
|
check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
|
|
|
|
check_include_files("X11/Xlib.h;X11/Xproto.h;X11/extensions/Xext.h" HAVE_XEXT_H)
|
|
|
|
|
|
|
|
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 14:43:35 +00:00
|
|
|
set(HAVE_X11 TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
|
|
|
file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
|
|
|
|
set(SDL_VIDEO_DRIVER_X11 1)
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
# !!! FIXME: why is this disabled for Apple?
|
2015-06-21 15:33:46 +00:00
|
|
|
if(APPLE)
|
2021-10-05 14:43:35 +00:00
|
|
|
set(SDL_X11_SHARED OFF)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2020-04-13 19:22:09 +00:00
|
|
|
check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(NOT HAVE_SHMAT)
|
|
|
|
check_library_exists(ipc shmat "" HAVE_SHMAT)
|
|
|
|
if(HAVE_SHMAT)
|
|
|
|
list(APPEND EXTRA_LIBS ipc)
|
|
|
|
endif()
|
|
|
|
if(NOT HAVE_SHMAT)
|
2018-06-24 19:12:18 +00:00
|
|
|
list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY")
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_SHARED)
|
2021-08-10 17:55:50 +00:00
|
|
|
if(NOT HAVE_SDL_LOADSO)
|
2015-06-21 15:33:46 +00: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()
|
|
|
|
if(HAVE_X11_SHARED)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB_SONAME}\"")
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
|
|
|
|
endif()
|
|
|
|
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);
|
|
|
|
XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
|
|
|
|
if(HAVE_XGENERICEVENT)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 19:22:09 +00:00
|
|
|
check_symbol_exists(XkbKeycodeToKeysym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
|
2015-06-21 15:33:46 +00:00
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H)
|
|
|
|
set(HAVE_X11_XCURSOR TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XCURSOR_LIB)
|
|
|
|
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-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XINERAMA AND HAVE_XINERAMA_H)
|
|
|
|
set(HAVE_X11_XINERAMA TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XINERAMA_LIB)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XINPUT AND HAVE_XINPUT2_H)
|
|
|
|
set(HAVE_X11_XINPUT TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XI_LIB)
|
|
|
|
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;
|
|
|
|
Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
|
|
|
|
{
|
|
|
|
return (Status)0;
|
|
|
|
}
|
|
|
|
int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
|
|
|
|
if(HAVE_XINPUT2_MULTITOUCH)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XRANDR AND HAVE_XRANDR_H)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XRANDR_LIB)
|
|
|
|
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 14:43:35 +00:00
|
|
|
set(HAVE_X11_XRANDR TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XSCRNSAVER AND HAVE_XSS_H)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XSS_LIB)
|
|
|
|
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 14:43:35 +00:00
|
|
|
set(HAVE_X11_XSCRNSAVER TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XSHAPE AND HAVE_XSHAPE_H)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_X11_XSHAPE TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_X11_XVM AND HAVE_XF86VM_H)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(HAVE_X11_SHARED AND XXF86VM_LIB)
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XXF86VM_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LIBS ${XXF86VM_LIB})
|
|
|
|
endif()
|
|
|
|
set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_X11_XVM TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(NOT HAVE_X11)
|
2021-05-06 13:43:16 +00:00
|
|
|
# Prevent Mesa from including X11 headers
|
|
|
|
list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11")
|
|
|
|
endif()
|
2015-06-21 15:33:46 +00:00
|
|
|
endmacro()
|
|
|
|
|
2021-01-14 22:50:15 +00:00
|
|
|
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
|
2016-10-11 20:36:40 +00: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 22:50:15 +00:00
|
|
|
ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
|
2016-10-11 20:36:40 +00:00
|
|
|
)
|
|
|
|
|
2018-02-07 18:07:59 +00:00
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}")
|
2016-10-11 20:36:40 +00:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_WAYLAND_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckWayland)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND)
|
2021-09-23 21:43:53 +00:00
|
|
|
pkg_check_modules(WAYLAND wayland-client wayland-scanner wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
|
2021-01-14 22:50:15 +00:00
|
|
|
pkg_check_modules(WAYLAND_SCANNER_1_15 "wayland-scanner>=1.15")
|
2016-10-11 20:36:40 +00:00
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(WAYLAND_FOUND AND HAVE_OPENGL_EGL)
|
2016-10-11 20:36:40 +00:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=wayland_scanner wayland-scanner
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
RESULT_VARIABLE WAYLAND_SCANNER_RC
|
|
|
|
OUTPUT_VARIABLE WAYLAND_SCANNER
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
if(NOT WAYLAND_SCANNER_RC EQUAL 0)
|
|
|
|
set(WAYLAND_FOUND FALSE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
if(WAYLAND_FOUND)
|
2021-01-14 22:50:15 +00:00
|
|
|
if(WAYLAND_SCANNER_1_15_FOUND)
|
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "private-code")
|
|
|
|
else()
|
|
|
|
set(WAYLAND_SCANNER_CODE_MODE "code")
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 16:34:29 +00:00
|
|
|
target_link_directories(sdl-build-options INTERFACE "${WAYLAND_LIBRARY_DIRS}")
|
|
|
|
target_include_directories(sdl-build-options INTERFACE "${WAYLAND_INCLUDE_DIRS}")
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_WAYLAND TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
|
|
|
file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
|
|
|
|
|
2016-10-11 20:36:40 +00: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 16:34:29 +00:00
|
|
|
target_include_directories(sdl-build-options INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols")
|
2016-10-11 20:36:40 +00:00
|
|
|
|
2018-06-25 16:37:25 +00:00
|
|
|
file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml")
|
|
|
|
foreach(_XML ${WAYLAND_PROTOCOLS_XML})
|
|
|
|
string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}")
|
2021-01-14 22:50:15 +00:00
|
|
|
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
|
2016-10-11 20:36:40 +00:00
|
|
|
endforeach()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_QT_TOUCH)
|
|
|
|
set(HAVE_WAYLAND_QT_TOUCH TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1)
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic Wayland loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME(wayland-client)
|
|
|
|
FindLibraryAndSONAME(wayland-egl)
|
|
|
|
FindLibraryAndSONAME(wayland-cursor)
|
|
|
|
FindLibraryAndSONAME(xkbcommon)
|
|
|
|
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 15:33:46 +00:00
|
|
|
else()
|
|
|
|
set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
|
|
|
|
endif()
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_LIBDECOR)
|
2021-08-03 08:33:50 +00:00
|
|
|
pkg_check_modules(LIBDECOR libdecor-0)
|
|
|
|
if(LIBDECOR_FOUND)
|
2021-08-03 07:10:14 +00:00
|
|
|
set(HAVE_WAYLAND_LIBDECOR TRUE)
|
2021-08-03 11:01:02 +00:00
|
|
|
set(HAVE_LIBDECOR_H 1)
|
2021-10-05 16:34:29 +00:00
|
|
|
target_link_directories(sdl-build-options INTERFACE "${LIBDECOR_LIBRARY_DIRS}")
|
|
|
|
target_include_directories(sdl-build-options INTERFACE "${LIBDECOR_INCLUDE_DIRS}")
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-03 11:01:02 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading")
|
2021-08-24 03:59:54 +00:00
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_WAYLAND_LIBDECOR_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-03 11:01:02 +00:00
|
|
|
set(HAVE_LIBDECOR_SHARED TRUE)
|
|
|
|
FindLibraryAndSONAME(decor-0)
|
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "\"${DECOR_0_LIB_SONAME}\"")
|
|
|
|
else()
|
|
|
|
set(EXTRA_LIBS ${LIBDECOR_LIBRARIES} ${EXTRA_LIBS})
|
|
|
|
endif()
|
2021-08-03 07:10:14 +00:00
|
|
|
endif()
|
2020-06-11 21:10:28 +00:00
|
|
|
endif()
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_DRIVER_WAYLAND 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
#
|
|
|
|
macro(CheckCOCOA)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_COCOA)
|
2015-06-21 15:33:46 +00:00
|
|
|
if(APPLE) # Apple always has Cocoa.
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_COCOA TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(HAVE_COCOA)
|
2015-06-21 15:33:46 +00:00
|
|
|
file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
|
|
|
|
set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
|
|
|
|
set(SDL_VIDEO_DRIVER_COCOA 1)
|
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
|
|
|
# - DIRECTFB_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2015-06-21 15:33:46 +00:00
|
|
|
macro(CheckDirectFB)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_DIRECTFB)
|
2015-06-21 15:33:46 +00:00
|
|
|
pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
|
|
|
|
if(PKG_DIRECTFB_FOUND)
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_DIRECTFB TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
|
|
|
|
set(SDL_VIDEO_DRIVER_DIRECTFB 1)
|
|
|
|
set(SDL_VIDEO_RENDER_DIRECTFB 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_DIRECTFB_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME("directfb")
|
|
|
|
set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${DIRECTFB_LIB_SONAME}\"")
|
|
|
|
set(HAVE_DIRECTFB_SHARED TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckVivante)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_VIVANTE)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <gc_vdk.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main(int argc, char** argv) {}" HAVE_VIVANTE_VDK)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#define LINUX
|
|
|
|
#define EGL_API_FB
|
|
|
|
#include <EGL/eglvivante.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main(int argc, char** argv) {}" HAVE_VIVANTE_EGL_FB)
|
|
|
|
if(HAVE_VIVANTE_VDK OR HAVE_VIVANTE_EGL_FB)
|
|
|
|
set(HAVE_VIVANTE TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
|
|
|
file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
|
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE 1)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(HAVE_VIVANTE_VDK)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
|
|
|
|
list(APPEND EXTRA_LIBS VDK VIVANTE)
|
|
|
|
else()
|
|
|
|
set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
|
|
|
|
list(APPEND EXTRA_LIBS EGL)
|
2021-10-05 14:43:35 +00:00
|
|
|
endif(HAVE_VIVANTE_VDK)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2015-06-21 15:33:46 +00:00
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
2021-05-06 13:43:16 +00:00
|
|
|
macro(CheckGLX)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <GL/glx.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main(int argc, char** argv) {}" HAVE_OPENGL_GLX)
|
|
|
|
if(HAVE_OPENGL_GLX)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_OPENGL_GLX 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-03-11 09:10:29 +00:00
|
|
|
# Requires:
|
|
|
|
# - PkgCheckModules
|
|
|
|
macro(CheckEGL)
|
2021-10-05 14:43:35 +00:00
|
|
|
if (SDL_OPENGL OR SDL_OPENGLES)
|
2021-05-06 13:43:16 +00:00
|
|
|
pkg_check_modules(EGL egl)
|
|
|
|
string(REPLACE "-D_THREAD_SAFE;" "-D_THREAD_SAFE=1;" EGL_CFLAGS "${EGL_CFLAGS}")
|
2020-12-22 16:17:30 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}")
|
|
|
|
check_c_source_compiles("
|
2021-05-06 13:43:16 +00:00
|
|
|
#define EGL_API_FB
|
|
|
|
#define MESA_EGL_NO_X11_HEADERS
|
|
|
|
#define EGL_NO_X11
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main (int argc, char** argv) {}" HAVE_OPENGL_EGL)
|
|
|
|
if(HAVE_OPENGL_EGL)
|
2021-05-06 13:43:16 +00:00
|
|
|
set(SDL_VIDEO_OPENGL_EGL 1)
|
2020-12-22 16:17:30 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
# Requires:
|
2021-05-06 13:43:16 +00:00
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGL)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_OPENGL)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
2021-05-06 13:43:16 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main(int argc, char** argv) {}" HAVE_OPENGL)
|
|
|
|
if(HAVE_OPENGL)
|
2021-05-06 13:43:16 +00:00
|
|
|
set(SDL_VIDEO_OPENGL 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL 1)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
2021-05-06 13:43:16 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - nada
|
|
|
|
macro(CheckOpenGLES)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_OPENGLES)
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
2021-05-06 13:43:16 +00:00
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main (int argc, char** argv) {}" HAVE_OPENGLES_V1)
|
|
|
|
if(HAVE_OPENGLES_V1)
|
|
|
|
set(HAVE_OPENGLES TRUE)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(SDL_VIDEO_OPENGL_ES 1)
|
|
|
|
set(SDL_VIDEO_RENDER_OGL_ES 1)
|
|
|
|
endif()
|
|
|
|
check_c_source_compiles("
|
2021-05-06 13:43:16 +00:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#include <GLES2/gl2ext.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main (int argc, char** argv) {}" HAVE_OPENGLES_V2)
|
|
|
|
if(HAVE_OPENGLES_V2)
|
|
|
|
set(HAVE_OPENGLES TRUE)
|
2015-06-21 15:33:46 +00: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-10-05 14:43:35 +00:00
|
|
|
if(SDL_PTHREADS)
|
2017-08-09 23:50:18 +00: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 15:33:46 +00: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")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
|
|
|
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 04:16:30 +00:00
|
|
|
elseif(EMSCRIPTEN)
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT -pthread")
|
|
|
|
set(PTHREAD_LDFLAGS "-pthread")
|
2015-06-21 15:33:46 +00:00
|
|
|
else()
|
|
|
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
|
|
|
set(PTHREAD_LDFLAGS "-lpthread")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Run some tests
|
2016-09-13 07:03:50 +00:00
|
|
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
|
2021-04-22 22:56:10 +00: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 15:33:46 +00:00
|
|
|
if(HAVE_PTHREADS)
|
|
|
|
set(SDL_THREAD_PTHREAD 1)
|
|
|
|
list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
|
|
|
|
list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
|
|
|
|
set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
|
|
|
|
list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
2021-04-22 22:56:10 +00:00
|
|
|
#define _GNU_SOURCE 1
|
2015-06-21 15:33:46 +00: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 22:56:10 +00:00
|
|
|
#define _GNU_SOURCE 1
|
2015-06-21 15:33:46 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
pthread_mutexattr_t attr;
|
2017-07-11 01:40:35 +00:00
|
|
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
2015-06-21 15:33:46 +00: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 14:43:35 +00:00
|
|
|
if(SDL_PTHREADS_SEM)
|
2015-06-21 15:33:46 +00: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 19:22:09 +00:00
|
|
|
check_include_files("pthread.h" HAVE_PTHREAD_H)
|
|
|
|
check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
|
|
|
|
if (HAVE_PTHREAD_H)
|
|
|
|
check_symbol_exists(pthread_setname_np "pthread.h" HAVE_PTHREAD_SETNAME_NP)
|
|
|
|
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 15:33:46 +00:00
|
|
|
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c # Can be faked, if necessary
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c # Can be faked, if necessary
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systls.c
|
|
|
|
)
|
|
|
|
if(HAVE_PTHREADS_SEM)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
|
|
|
|
else()
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES}
|
|
|
|
${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
|
|
|
|
endif()
|
|
|
|
set(HAVE_SDL_THREADS TRUE)
|
|
|
|
endif()
|
2017-07-11 01:40:35 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 15:33:46 +00: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 07:03:50 +00:00
|
|
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${USB_CFLAGS}")
|
2015-06-21 15:33:46 +00: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 20:08:49 +00:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 15:33:46 +00: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 20:08:49 +00:00
|
|
|
# include <bus/u4b/usb.h>
|
|
|
|
# include <bus/u4b/usbhid.h>
|
2015-06-21 15:33:46 +00: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 20:08:49 +00:00
|
|
|
#include <bus/u4b/usb.h>
|
|
|
|
#include <bus/u4b/usbhid.h>
|
2015-06-21 15:33:46 +00: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 14:24:28 +00:00
|
|
|
set(SDL_HAVE_MACHINE_JOYSTICK_H 1)
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
set(SDL_JOYSTICK_USBHID 1)
|
|
|
|
file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
|
|
|
|
list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
|
|
|
|
list(APPEND EXTRA_LIBS ${USB_LIBS})
|
|
|
|
set(HAVE_SDL_JOYSTICK TRUE)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
2016-09-13 07:03:50 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 15:33:46 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2019-07-08 20:46:52 +00:00
|
|
|
# Check for HIDAPI joystick drivers. This is currently a Unix thing, not Windows or macOS!
|
|
|
|
macro(CheckHIDAPI)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_HIDAPI)
|
2019-07-08 20:46:52 +00:00
|
|
|
if(HIDAPI_SKIP_LIBUSB)
|
|
|
|
set(HAVE_HIDAPI TRUE)
|
|
|
|
else()
|
|
|
|
set(HAVE_HIDAPI FALSE)
|
2020-12-09 15:26:59 +00:00
|
|
|
pkg_check_modules(LIBUSB libusb-1.0)
|
2019-07-08 20:46:52 +00:00
|
|
|
if (LIBUSB_FOUND)
|
2019-07-31 16:34:00 +00:00
|
|
|
check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS})
|
2019-07-08 20:46:52 +00:00
|
|
|
if (HAVE_LIBUSB_H)
|
|
|
|
set(HAVE_HIDAPI TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_HIDAPI)
|
|
|
|
set(SDL_JOYSTICK_HIDAPI 1)
|
|
|
|
set(HAVE_SDL_JOYSTICK TRUE)
|
|
|
|
file(GLOB HIDAPI_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${HIDAPI_SOURCES})
|
2020-03-20 19:13:26 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} \"-I${SDL2_SOURCE_DIR}/src/hidapi/hidapi\"")
|
2019-07-08 20:46:52 +00:00
|
|
|
if(NOT HIDAPI_SKIP_LIBUSB)
|
2019-07-31 16:20:55 +00:00
|
|
|
if(HIDAPI_ONLY_LIBUSB)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/libusb/hid.c)
|
|
|
|
list(APPEND EXTRA_LIBS ${LIBUSB_LIBS})
|
|
|
|
else()
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/SDL_hidapi.c)
|
|
|
|
# libusb is loaded dynamically, so don't add it to EXTRA_LIBS
|
|
|
|
FindLibraryAndSONAME("usb-1.0")
|
|
|
|
set(SDL_LIBUSB_DYNAMIC "\"${USB_LIB_SONAME}\"")
|
|
|
|
endif()
|
2019-07-08 20:46:52 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
2015-06-21 15:33:46 +00:00
|
|
|
# Requires:
|
|
|
|
# - n/a
|
|
|
|
macro(CheckRPI)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_RPI)
|
2018-01-17 21:17:10 +00: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 22:12:26 +00:00
|
|
|
set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
|
2018-01-17 21:17:10 +00:00
|
|
|
endif()
|
2015-06-21 15:33:46 +00:00
|
|
|
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
|
|
|
|
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
|
|
|
|
|
2016-09-13 07:03:50 +00: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 21:17:10 +00:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
|
2015-06-21 15:33:46 +00:00
|
|
|
check_c_source_compiles("
|
|
|
|
#include <bcm_host.h>
|
2021-10-05 14:43:35 +00:00
|
|
|
int main(int argc, char **argv) {}" HAVE_RPI)
|
2016-09-13 07:03:50 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
2015-06-21 15:33:46 +00:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_VIDEO AND HAVE_RPI)
|
2015-06-21 15:33:46 +00:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
set(SDL_VIDEO_DRIVER_RPI 1)
|
|
|
|
file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
|
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
|
2018-01-17 21:17:10 +00:00
|
|
|
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
|
2021-10-05 16:34:29 +00:00
|
|
|
# !!! FIXME: shouldn't be using CMAKE_C_FLAGS, right?
|
2015-06-21 15:33:46 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
2018-02-07 22:12:26 +00:00
|
|
|
list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
|
2021-10-05 14:43:35 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2017-08-02 17:22:48 +00:00
|
|
|
|
|
|
|
# Requires:
|
|
|
|
# - EGL
|
|
|
|
# - PkgCheckModules
|
|
|
|
# Optional:
|
2021-10-05 14:43:35 +00:00
|
|
|
# - SDL_KMSDRM_SHARED opt
|
2021-08-10 17:55:50 +00:00
|
|
|
# - HAVE_SDL_LOADSO opt
|
2017-08-02 17:22:48 +00:00
|
|
|
macro(CheckKMSDRM)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_KMSDRM)
|
2017-08-02 17:22:48 +00:00
|
|
|
pkg_check_modules(KMSDRM libdrm gbm egl)
|
2021-10-05 14:43:35 +00:00
|
|
|
if(KMSDRM_FOUND AND HAVE_OPENGL_EGL)
|
2017-08-02 17:22:48 +00:00
|
|
|
link_directories(
|
|
|
|
${KMSDRM_LIBRARY_DIRS}
|
|
|
|
)
|
2021-10-05 16:34:29 +00:00
|
|
|
target_include_directories(sdl-build-options INTERFACE "${KMSDRM_INCLUDE_DIRS}")
|
2021-10-05 14:43:35 +00:00
|
|
|
set(HAVE_KMSDRM TRUE)
|
2017-08-02 17:22:48 +00:00
|
|
|
set(HAVE_SDL_VIDEO TRUE)
|
|
|
|
|
|
|
|
file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c)
|
2021-01-08 17:57:12 +00:00
|
|
|
set(SOURCE_FILES ${SOURCE_FILES} ${KMSDRM_SOURCES})
|
2017-08-02 17:22:48 +00:00
|
|
|
|
2017-08-10 01:47:33 +00:00
|
|
|
list(APPEND EXTRA_CFLAGS ${KMSDRM_CFLAGS})
|
2017-08-02 17:22:48 +00:00
|
|
|
|
|
|
|
set(SDL_VIDEO_DRIVER_KMSDRM 1)
|
|
|
|
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_KMSDRM_SHARED AND NOT HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
message_warn("You must have SDL_LoadObject() support for dynamic KMS/DRM loading")
|
|
|
|
endif()
|
2021-10-05 14:43:35 +00:00
|
|
|
if(SDL_KMSDRM_SHARED AND HAVE_SDL_LOADSO)
|
2021-08-24 03:59:54 +00:00
|
|
|
FindLibraryAndSONAME(drm)
|
|
|
|
FindLibraryAndSONAME(gbm)
|
|
|
|
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 17:22:48 +00:00
|
|
|
else()
|
|
|
|
set(EXTRA_LIBS ${KMSDRM_LIBRARIES} ${EXTRA_LIBS})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|