Skip to content

Commit

Permalink
tests: simplify detection of Catch v3 for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
striezel committed Aug 9, 2024
1 parent 4f87450 commit b514621
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b514621

Please sign in to comment.