cmake: fix configuration with -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON

This commit is contained in:
Anonymous Maarten 2024-10-15 19:09:36 +02:00
parent cdaaabb978
commit 4162bddca7

View File

@ -135,7 +135,10 @@ endmacro()
macro(CheckPipewire)
if(SDL_PIPEWIRE)
set(PipeWire_PKG_CONFIG_SPEC libpipewire-0.3>=0.3.44)
pkg_check_modules(PC_PIPEWIRE IMPORTED_TARGET ${PipeWire_PKG_CONFIG_SPEC})
set(PC_PIPEWIRE_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_PIPEWIRE IMPORTED_TARGET ${PipeWire_PKG_CONFIG_SPEC})
endif()
if(PC_PIPEWIRE_FOUND)
set(HAVE_PIPEWIRE TRUE)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pipewire/*.c")
@ -167,7 +170,10 @@ endmacro()
macro(CheckPulseAudio)
if(SDL_PULSEAUDIO)
set(PulseAudio_PKG_CONFIG_SPEC "libpulse>=0.9.15")
pkg_check_modules(PC_PULSEAUDIO IMPORTED_TARGET ${PulseAudio_PKG_CONFIG_SPEC})
set(PC_PULSEAUDIO_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_PULSEAUDIO IMPORTED_TARGET ${PulseAudio_PKG_CONFIG_SPEC})
endif()
if(PC_PULSEAUDIO_FOUND)
set(HAVE_PULSEAUDIO TRUE)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/pulseaudio/*.c")
@ -196,7 +202,10 @@ endmacro()
macro(CheckJACK)
if(SDL_JACK)
set(Jack_PKG_CONFIG_SPEC jack)
pkg_check_modules(PC_JACK IMPORTED_TARGET ${Jack_PKG_CONFIG_SPEC})
set(PC_JACK_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_JACK IMPORTED_TARGET ${Jack_PKG_CONFIG_SPEC})
endif()
if(PC_JACK_FOUND)
set(HAVE_JACK TRUE)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/jack/*.c")
@ -225,7 +234,10 @@ endmacro()
macro(CheckSNDIO)
if(SDL_SNDIO)
set(SndIO_PKG_CONFIG_SPEC sndio)
pkg_check_modules(PC_SNDIO IMPORTED_TARGET ${SndIO_PKG_CONFIG_SPEC})
set(PC_SNDIO_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_SNDIO IMPORTED_TARGET ${SndIO_PKG_CONFIG_SPEC})
endif()
if(PC_SNDIO_FOUND)
set(HAVE_SNDIO TRUE)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/sndio/*.c")
@ -496,7 +508,10 @@ endmacro()
macro(CheckWayland)
if(SDL_WAYLAND)
set(WAYLAND_PKG_CONFIG_SPEC "wayland-client>=1.18" wayland-egl wayland-cursor egl "xkbcommon>=0.5.0")
pkg_check_modules(PC_WAYLAND IMPORTED_TARGET ${WAYLAND_PKG_CONFIG_SPEC})
set(PC_WAYLAND_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_WAYLAND IMPORTED_TARGET ${WAYLAND_PKG_CONFIG_SPEC})
endif()
find_program(WAYLAND_SCANNER NAMES wayland-scanner)
set(WAYLAND_FOUND FALSE)
@ -1104,8 +1119,12 @@ macro(CheckRPI)
set(original_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}:/opt/vc/lib/pkgconfig")
pkg_check_modules(PC_BCM_HOST IMPORTED_TARGET QUIET ${BCM_HOST_PKG_CONFIG_SPEC})
pkg_check_modules(PC_BRCMEGL IMPORTED_TARGET QUIET ${BRCMEGL_PKG_CONFIG_SPEC})
set(PC_BCM_HOST_FOUND FALSE)
set(PC_BRCMEGL_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_BCM_HOST IMPORTED_TARGET QUIET ${BCM_HOST_PKG_CONFIG_SPEC})
pkg_check_modules(PC_BRCMEGL IMPORTED_TARGET QUIET ${BRCMEGL_PKG_CONFIG_SPEC})
endif()
set(ENV{PKG_CONFIG_PATH} "${original_PKG_CONFIG_PATH}")
if(TARGET PkgConfig::PC_BCM_HOST AND TARGET PkgConfig::PC_BRCMEGL)
@ -1125,7 +1144,10 @@ endmacro()
macro(CheckROCKCHIP)
if(SDL_ROCKCHIP)
set(MALI_PKG_CONFIG_SPEC mali)
pkg_check_modules(PC_MALI QUIET ${MALI_PKG_CONFIG_SPEC})
set(PC_MALI_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_MALI QUIET ${MALI_PKG_CONFIG_SPEC})
endif()
if(PC_MALI_FOUND)
set(HAVE_ROCKCHIP TRUE)
endif()
@ -1146,8 +1168,12 @@ macro(CheckKMSDRM)
if(SDL_KMSDRM)
set(PKG_CONFIG_LIBDRM_SPEC libdrm)
set(PKG_CONFIG_GBM_SPEC gbm)
pkg_check_modules(PC_LIBDRM IMPORTED_TARGET ${PKG_CONFIG_LIBDRM_SPEC})
pkg_check_modules(PC_GBM IMPORTED_TARGET ${PKG_CONFIG_GBM_SPEC})
set(PC_LIBDRM_FOUND FALSE)
set(PC_GBM_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBDRM IMPORTED_TARGET ${PKG_CONFIG_LIBDRM_SPEC})
pkg_check_modules(PC_GBM IMPORTED_TARGET ${PKG_CONFIG_GBM_SPEC})
endif()
if(PC_LIBDRM_FOUND AND PC_GBM_FOUND AND HAVE_OPENGL_EGL)
set(HAVE_KMSDRM TRUE)
set(HAVE_SDL_VIDEO TRUE)
@ -1221,7 +1247,10 @@ macro(CheckLibUnwind)
if(NOT found_libunwind)
set(LibUnwind_PKG_CONFIG_SPEC libunwind libunwind-generic)
pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC})
set(PC_LIBUNWIND_FOUND FALSE)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC})
endif()
if(PC_LIBUNWIND_FOUND)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES ${PC_LIBUNWIND_LIBRARIES})