From b1f89d78c3fe15b1ce1baa322722e29ad144777a Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 25 Nov 2023 23:14:36 +0100 Subject: [PATCH] Allow building without CppUnit-based tests --- cmake/modules/TestTarget.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/modules/TestTarget.cmake b/cmake/modules/TestTarget.cmake index e7bea2f..47ca7c1 100644 --- a/cmake/modules/TestTarget.cmake +++ b/cmake/modules/TestTarget.cmake @@ -14,13 +14,21 @@ endif () # find and link against CppUnit if required (used by all my projects, so it is required by default) if (NOT META_NO_CPP_UNIT) - # make cppunit library/include dir configurable + # allow disabling CppUnit-based tests completely + option(ENABLE_CPP_UNIT "whether CppUnit-based tests should be enabled" ON) + if (NOT ENABLE_CPP_UNIT) + set(META_HAVE_TESTS NO) + set(TEST_CONFIG_DONE YES) + return () + endif () + + # make CppUnit library/include dir configurable set(CPP_UNIT_LIB NOTFOUND - CACHE FILEPATH "cppunit lib") + CACHE FILEPATH "CppUnit lib") set(CPP_UNIT_INCLUDE_DIR NOTFOUND - CACHE FILEPATH "cppunit include dir") + CACHE FILEPATH "CppUnit include dir") if (CPP_UNIT_LIB) set(DETECTED_CPP_UNIT_LIB "${CPP_UNIT_LIB}") endif ()