Fix Catch2 build break on Debian 12
This commit is contained in:
+24
-18
@@ -24,28 +24,34 @@ find_package(PkgConfig REQUIRED)
|
||||
|
||||
find_package(Catch2 QUIET)
|
||||
|
||||
# Catch2 v3 (Arch, newer distros) uses multi-headers under <catch2/>.
|
||||
# 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 <catch/catch.hpp> 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 <catch2/catch_all.hpp>\n"
|
||||
)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch/catch.hpp"
|
||||
"#pragma once\n"
|
||||
"#include <catch2/catch_all.hpp>\n"
|
||||
)
|
||||
# Add the build directory to the global include paths so that
|
||||
# both #include "catch.hpp" (quote) and #include <catch/catch.hpp> (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 <catch2/catch_all.hpp>\n"
|
||||
)
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/catch")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/catch/catch.hpp"
|
||||
"#pragma once\n"
|
||||
"#include <catch2/catch_all.hpp>\n"
|
||||
)
|
||||
# Add the build directory to the global include paths so that
|
||||
# both #include "catch.hpp" (quote) and #include <catch/catch.hpp> (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)
|
||||
|
||||
Reference in New Issue
Block a user