From b514621a085473df7e8720905b0c4277b19f0e86 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Fri, 9 Aug 2024 04:07:58 +0200 Subject: [PATCH] tests: simplify detection of Catch v3 for tests --- tests/CMakeLists.txt | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 29a514e..d1e07c0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,25 +1,13 @@ cmake_minimum_required (VERSION 3.8) -# MSYS2 / MinGW uses Catch 3.x. -if (MINGW) +include (CheckIncludeFileCXX) +check_include_file_cxx (catch2/catch_test_macros.hpp HAS_CATCH_V3_HEADER) +check_include_file_cxx (catch2/catch.hpp HAS_CATCH_V2_HEADER) + +if (HAS_CATCH_V3_HEADER AND NOT HAS_CATCH_V2_HEADER) set(HAS_CATCH_V3 ON) else () set(HAS_CATCH_V3 OFF) endif () -# Some newer distros like Fedora 38+ or Ubuntu 24.04+ also use Catch 3.x. -if (UNIX AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0") - cmake_host_system_information(RESULT DIST_NAME QUERY DISTRIB_NAME) - cmake_host_system_information(RESULT DIST_VERSION_ID QUERY DISTRIB_VERSION_ID) - - if (DIST_NAME STREQUAL "Fedora Linux" AND DIST_VERSION_ID VERSION_GREATER_EQUAL "38") - # Fedora 38 or later detected, set flag for Catch 3.x. - set(HAS_CATCH_V3 ON) - endif () - if (DIST_NAME STREQUAL "Ubuntu" AND DIST_VERSION_ID VERSION_GREATER_EQUAL "24.04") - # Ubuntu 24.04 or later detected, set flag for Catch 3.x. - set(HAS_CATCH_V3 ON) - endif () -endif() - add_subdirectory (webp-viewer-tests)