From f9620d11bee620bff58ebb9ab82da40abcc6a20f Mon Sep 17 00:00:00 2001 From: Florian Berchtold Date: Sun, 20 Sep 2020 18:09:33 +0200 Subject: [PATCH] Docu/Show how to use CMake FetchContent (#2028) --- docs/cmake-integration.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index fda922ae..1c51ae07 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -36,6 +36,20 @@ add_subdirectory(lib/Catch2) target_link_libraries(tests Catch2::Catch2) ``` +Another possibility is to use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html): +```cmake +Include(FetchContent) + +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v2.13.1) + +FetchContent_MakeAvailable(Catch2) + +target_link_libraries(tests Catch2::Catch2) +``` + ## Automatic test registration Catch2's repository also contains two CMake scripts that help users