catchorg / catchorg/Catch2

FetchContent doesn't seem to work as described in the documentation with Catch2

Open
#2,103 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

I am trying to use `FetchContent` to include Catch2 into a CMake project I am working on, but it does not seem to work. After using `FetchContent` as described in the documentation the `catch_discover_tests()` function is still not found.

Following the documentation it states that `FetchContent` should be usable for including Catch2 into a project as follows:

```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)
```

But after following these steps, I am still unable to call `catch_discover_tests()` within my CMake files.

I even tried adding `find_package(Catch2 REQUIRED)` and `include(Catch)` but both of those commands fail as well.

**Platform information:**

- OS: **Windows 10**
- Compiler+version: **Visual Studio 2019 16.19.0 Preview 1.0**
- Catch version: **v2.13.3**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.