From a39f55627b0c53cd80fe01d7c0faeecf2ccc0f6a Mon Sep 17 00:00:00 2001 From: Armin Penz Date: Wed, 4 Mar 2026 06:49:57 +0100 Subject: [PATCH 1/3] fix test/CMakeLists.txt --- test/CMakeLists.txt | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f09e124..52633b7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,13 +18,25 @@ if(NOT TARGET mstd) endif() if(NOT TARGET Catch2::Catch2WithMain) - add_subdirectory( - "${MSTD_ROOT_DIR}/external/Catch2" - "${CMAKE_CURRENT_BINARY_DIR}/external/Catch2" - ) + set(MSTD_CATCH2_SOURCE_DIR "${MSTD_ROOT_DIR}/external/Catch2") + if(EXISTS "${MSTD_CATCH2_SOURCE_DIR}/CMakeLists.txt") + add_subdirectory( + "${MSTD_CATCH2_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/external/Catch2" + ) + else() + include(FetchContent) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.13.0 + ) + FetchContent_MakeAvailable(Catch2) + set(MSTD_CATCH2_SOURCE_DIR "${catch2_SOURCE_DIR}") + endif() endif() -list(APPEND CMAKE_MODULE_PATH "${MSTD_ROOT_DIR}/external/Catch2/extras") +list(APPEND CMAKE_MODULE_PATH "${MSTD_CATCH2_SOURCE_DIR}/extras") if(NOT TARGET mstd_test_support) add_library(mstd_test_support INTERFACE) From 2111f1f77cafa0623badf043cf5c66a5697e3ed9 Mon Sep 17 00:00:00 2001 From: Armin Penz Date: Sat, 7 Mar 2026 09:03:23 +0100 Subject: [PATCH 2/3] fix: improve Catch2 submodule initialization in CMakeLists.txt --- test/CMakeLists.txt | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52633b7..ce80b74 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,14 +25,34 @@ if(NOT TARGET Catch2::Catch2WithMain) "${CMAKE_CURRENT_BINARY_DIR}/external/Catch2" ) else() - include(FetchContent) - FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.13.0 - ) - FetchContent_MakeAvailable(Catch2) - set(MSTD_CATCH2_SOURCE_DIR "${catch2_SOURCE_DIR}") + find_package(Git QUIET) + if(GIT_FOUND) + message(STATUS "Catch2 submodule missing. Attempting initialization via git...") + execute_process( + COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive -- external/Catch2 + WORKING_DIRECTORY "${MSTD_ROOT_DIR}" + RESULT_VARIABLE MSTD_CATCH2_SUBMODULE_RESULT + ERROR_VARIABLE MSTD_CATCH2_SUBMODULE_ERROR + ) + else() + set(MSTD_CATCH2_SUBMODULE_RESULT 1) + set(MSTD_CATCH2_SUBMODULE_ERROR "Git executable was not found.") + endif() + + if(EXISTS "${MSTD_CATCH2_SOURCE_DIR}/CMakeLists.txt") + add_subdirectory( + "${MSTD_CATCH2_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/external/Catch2" + ) + else() + message(FATAL_ERROR + "Catch2 submodule is missing at '${MSTD_CATCH2_SOURCE_DIR}'.\n" + "Automatic submodule initialization failed (code: ${MSTD_CATCH2_SUBMODULE_RESULT}).\n" + "Details: ${MSTD_CATCH2_SUBMODULE_ERROR}\n" + "Please run manually and re-run CMake:\n" + " git submodule update --init --recursive" + ) + endif() endif() endif() From 58851d31c63f65c4e441c3d719b79dc4c17a1478 Mon Sep 17 00:00:00 2001 From: Armin Penz Date: Sat, 7 Mar 2026 09:11:38 +0100 Subject: [PATCH 3/3] Update changelog to reflect CMakeLists.txt changes for Catch2 submodule inclusion --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e03203..9cbbcec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## Next Release +- Update test/CMakeLists.txt to implicitly take care of including the Catch2 submodule + ## [0.1.0](https://github.com/repo/owner/releases/tag/0.1.0) - 2026-02-27