build: reject an SDL2 without HIDAPI and fall back to shared SPIRV-Tools
A system SDL2 that does not define SDL_JOYSTICK_HIDAPI (sdl2-compat over SDL3 ships no such macro, and neither does a build with the driver disabled) fails pad_sdl and makes the disk audio driver open the port with a different channel count, so ANYPS5_USE_SYSTEM_DEPS=ON now rejects it with a named error, like the VK_KHR_maintenance8 check. Ubuntu's real SDL2 defines the macro through its SDL_config.h indirection and is unaffected. SPIRV-Tools only exports SPIRV-Tools-static when built with SPIRV_TOOLS_BUILD_STATIC=ON; distributions that ship it shared expose SPIRV-Tools instead, so a shared target is aliased to the static name.
This commit is contained in:
parent
6ad5c61f1a
commit
ce6edc5a00
|
|
@ -9,6 +9,8 @@ if(NOT ANYPS5_USE_SYSTEM_DEPS)
|
|||
return()
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
if(NOT TARGET SDL2::SDL2)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: SDL2 was found but does not provide SDL2::SDL2")
|
||||
|
|
@ -19,6 +21,17 @@ get_target_property(ANYPS5_SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTO
|
|||
if(NOT ANYPS5_SDL2_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: SDL2::SDL2 exposes no INTERFACE_INCLUDE_DIRECTORIES")
|
||||
endif()
|
||||
set(ANYPS5_SDL2_PROBE_INCLUDES ${ANYPS5_SDL2_INCLUDE_DIR})
|
||||
foreach(_dir IN LISTS ANYPS5_SDL2_INCLUDE_DIR)
|
||||
list(APPEND ANYPS5_SDL2_PROBE_INCLUDES "${_dir}/SDL2")
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES ANYPS5_SDL2_PROBE_INCLUDES)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ANYPS5_SDL2_PROBE_INCLUDES})
|
||||
check_cxx_source_compiles("#include \"SDL_config.h\"\n#ifndef SDL_JOYSTICK_HIDAPI\n#error SDL_JOYSTICK_HIDAPI is not defined\n#endif\nint main() { return 0; }" ANYPS5_SDL2_HAS_HIDAPI)
|
||||
unset(CMAKE_REQUIRED_INCLUDES)
|
||||
if(NOT ANYPS5_SDL2_HAS_HIDAPI)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: the system SDL2 does not define SDL_JOYSTICK_HIDAPI, so a DualSense gets no light bar, touchpad or trigger effects and the disk audio driver does not preserve the requested format; sdl2-compat (SDL3 underneath) and SDL2 builds with HIDAPI disabled both fail the pad and audio tests; install a real SDL2 2.x built with HIDAPI")
|
||||
endif()
|
||||
|
||||
find_package(Freetype REQUIRED)
|
||||
if(NOT TARGET Freetype::Freetype)
|
||||
|
|
@ -35,7 +48,6 @@ get_target_property(ANYPS5_VULKAN_HEADERS_INCLUDE_DIR Vulkan::Headers INTERFACE_
|
|||
if(NOT ANYPS5_VULKAN_HEADERS_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: Vulkan::Headers exposes no INTERFACE_INCLUDE_DIRECTORIES")
|
||||
endif()
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ANYPS5_VULKAN_HEADERS_INCLUDE_DIR})
|
||||
check_cxx_source_compiles("#include <vulkan/vulkan.h>\nint main() { VkPhysicalDeviceMaintenance8FeaturesKHR features{}; (void)features; return 0; }" ANYPS5_VULKAN_HAS_MAINTENANCE8)
|
||||
unset(CMAKE_REQUIRED_INCLUDES)
|
||||
|
|
@ -79,8 +91,16 @@ set_target_properties(glslang-standalone PROPERTIES IMPORTED_LOCATION "${ANYPS5_
|
|||
|
||||
if(ANYPS5_ENABLE_SPIRV_TOOLS)
|
||||
find_package(SPIRV-Tools-opt CONFIG REQUIRED)
|
||||
if(NOT TARGET SPIRV-Tools-opt OR NOT TARGET SPIRV-Tools-static)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: SPIRV-Tools was found but does not provide SPIRV-Tools-opt and SPIRV-Tools-static")
|
||||
if(NOT TARGET SPIRV-Tools-opt)
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: SPIRV-Tools was found but does not provide SPIRV-Tools-opt")
|
||||
endif()
|
||||
if(NOT TARGET SPIRV-Tools-static)
|
||||
if(TARGET SPIRV-Tools)
|
||||
add_library(SPIRV-Tools-static INTERFACE)
|
||||
target_link_libraries(SPIRV-Tools-static INTERFACE SPIRV-Tools)
|
||||
else()
|
||||
message(FATAL_ERROR "ANYPS5_USE_SYSTEM_DEPS: SPIRV-Tools was found but provides neither SPIRV-Tools-static nor SPIRV-Tools")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ Build configuration parameters:
|
|||
|
||||
SDL and FreeType settings forced by the root `CMakeLists.txt` cannot be overridden with `-D`.
|
||||
|
||||
With `ANYPS5_USE_SYSTEM_DEPS=ON` those libraries come from the system (on Debian and Ubuntu: `libsdl2-dev`, `libfreetype-dev`, `libvulkan-dev`, `spirv-headers`, `glslang-dev`, `glslang-tools` and `spirv-tools`). A missing package, or Vulkan-Headers older than 1.4.310 (the agc driver uses `VK_KHR_maintenance8`), fails the configure with an error and never falls back to the submodule. The prx libraries are shared objects, so SDL2 is linked from the system as a shared library; the default build keeps its own static SDL2. `ffmpeg-core`, `libjpeg-turbo`, `stb`, `VulkanMemoryAllocator` and `LibAtrac9` always stay bundled and still need `git submodule update --init`.
|
||||
With `ANYPS5_USE_SYSTEM_DEPS=ON` those libraries come from the system (on Debian and Ubuntu: `libsdl2-dev`, `libfreetype-dev`, `libvulkan-dev`, `spirv-headers`, `glslang-dev`, `glslang-tools` and `spirv-tools`). A missing package, Vulkan-Headers older than 1.4.310 (the agc driver uses `VK_KHR_maintenance8`), or an SDL2 without the HIDAPI joystick driver (sdl2-compat over SDL3, or a build with HIDAPI disabled, which breaks the pad and disk-audio tests), fails the configure with an error and never falls back to the submodule. The forced SDL and FreeType settings from the root `CMakeLists.txt` do not apply with the flag ON: the system SDL2 comes with whatever its distribution enabled. The prx libraries are shared objects, so SDL2 is linked from the system as a shared library; the default build keeps its own static SDL2. `ffmpeg-core`, `libjpeg-turbo`, `stb`, `VulkanMemoryAllocator` and `LibAtrac9` always stay bundled and still need `git submodule update --init`.
|
||||
|
||||
## Write watch tests
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue