From 859500a8ac6f0ba62c739e6755b95470c79f2a3e Mon Sep 17 00:00:00 2001 From: "Robin E. R. Davies" Date: Wed, 17 Jun 2026 10:35:57 -0400 Subject: [PATCH] Fix Catch2 build break on Debian 12 --- src/CMakeLists.txt | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 968960e..0a42a32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,28 +24,34 @@ find_package(PkgConfig REQUIRED) find_package(Catch2 QUIET) -# Catch2 v3 (Arch, newer distros) uses multi-headers under . -# Catch2 v2 (Debian/Ubuntu) provides a single catch.hpp at system level. +# Catch2 Arch and Debian13 provide catch2 v3, with multi-headers under catch2 +# Catch2 Debian12 provides catch2 v2, with a single header. # When Catch2 v3 is found via CMake, generate compatibility wrappers so # old-style #include "catch.hpp" and #include still work. if(Catch2_FOUND) - # Generate catch.hpp wrapper in the build directory. - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch.hpp" - "#pragma once\n" - "#include \n" - ) - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch/catch.hpp" - "#pragma once\n" - "#include \n" - ) - # Add the build directory to the global include paths so that - # both #include "catch.hpp" (quote) and #include (angle) - # can find the compatibility wrappers. - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - message(STATUS "Catch2 v3 found. Generated compatibility wrappers in ${CMAKE_CURRENT_BINARY_DIR}") + if(Catch2_VERSION VERSION_GREATER_EQUAL "3.0.0") # Generate catch.hpp wrapper in the build directory. + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch.hpp" + "#pragma once\n" + "#include \n" + ) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch/catch.hpp" + "#pragma once\n" + "#include \n" + ) + # Add the build directory to the global include paths so that + # both #include "catch.hpp" (quote) and #include (angle) + # can find the compatibility wrappers. + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + message(STATUS "Catch2 v3 found. Generated compatibility wrappers in ${CMAKE_CURRENT_BINARY_DIR}") + elseif(Catch2_VERSION VERSION_GREATER_EQUAL "2.0.0") # Generate catch.hpp wrapper in the build directory. + # Just use the system version directly. + message(STATUS "Catch2 v2 found. Using system catch2/catch.hpp directly.") + else() + message(ERROR "Catch2: Unsupported Catch2 version: ${Catch2_VERSION}. Expecting Catch2 v2 or v3.") + endif() else() - message(STATUS "Catch2 CMake package not found. Expecting system catch.hpp (Catch2 v2 style).") + message(ERROR "Catch2 CMake package not found. Expecting system catch.hpp (Catch2 v2 style).") endif() pkg_check_modules(PipeWire REQUIRED libpipewire-0.3)