From 6f21a3609cea360846a0ca93be55877cca14c86d Mon Sep 17 00:00:00 2001 From: Vishesh Yadav Date: Sun, 27 Jun 2021 02:20:17 -0700 Subject: [PATCH] Update CMake doc for automatic test registration `FetchContent` doesn't include `contrib` directory as part of `CMAKE_MODULE_PATH`. This results into `include(Catch)` to fail. This patch just updates the documentation describing how to do include the path, so the new users don't have to figure this out themselves. Source: https://github.com/catchorg/Catch2/issues/2103#issuecomment-730626324 --- docs/cmake-integration.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index 4faa9bda..0414f44c 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -88,6 +88,18 @@ include(Catch) catch_discover_tests(foo) ``` +When using `FetchContent`, `include(Catch)` will fail unless +`CMAKE_MODULE_PATH` is explicitly updated to include the contrib +directory. + +```cmake +# ... FetchContent ... +# +list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib) +include(CTest) +include(Catch) +catch_discover_tests() +``` #### Customization `catch_discover_tests` can be given several extra argumets: