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
This commit is contained in:
Vishesh Yadav 2021-06-27 02:20:17 -07:00 committed by Martin Hořeňovský
parent bf61a418cb
commit 6f21a3609c

View File

@ -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: