Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFlorian Berchtold2020-12-28 13:41:55 +0100
committerGitHub2020-12-28 13:41:55 +0100
commit045feff834dbdc4af85bc5423416e294aa4a1e88 (patch)
tree9deac52dea2433dfe2d5efb88f4c0a14400ad367
parent965afc4b2ea519f339e249392c54f544f77ed3f5 (diff)
downloadcatch3-045feff834dbdc4af85bc5423416e294aa4a1e88.tar.gz
Update cmake-integration.md (#2115)
* Update cmake-integration.md CMake related, mainly more modern and provide an executable to be correct Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
-rw-r--r--docs/cmake-integration.md13
1 files changed, 8 insertions, 5 deletions
diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md
index cecba2ab..59e06842 100644
--- a/docs/cmake-integration.md
+++ b/docs/cmake-integration.md
@@ -25,7 +25,8 @@ This means that if Catch2 has been installed on the system, it should be
enough to do:
```cmake
find_package(Catch2 REQUIRED)
-target_link_libraries(tests Catch2::Catch2)
+add_executable(tests test.cpp)
+target_link_libraries(tests PRIVATE Catch2::Catch2)
```
@@ -33,7 +34,8 @@ This target is also provided when Catch2 is used as a subdirectory.
Assuming that Catch2 has been cloned to `lib/Catch2`:
```cmake
add_subdirectory(lib/Catch2)
-target_link_libraries(tests Catch2::Catch2)
+add_executable(tests test.cpp)
+target_link_libraries(tests PRIVATE Catch2::Catch2)
```
Another possibility is to use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html):
@@ -47,7 +49,8 @@ FetchContent_Declare(
FetchContent_MakeAvailable(Catch2)
-target_link_libraries(tests Catch2::Catch2)
+add_executable(tests test.cpp)
+target_link_libraries(tests PRIVATE Catch2::Catch2)
```
## Automatic test registration
@@ -78,7 +81,7 @@ project(baz LANGUAGES CXX VERSION 0.0.1)
find_package(Catch2 REQUIRED)
add_executable(foo test.cpp)
-target_link_libraries(foo Catch2::Catch2)
+target_link_libraries(foo PRIVATE Catch2::Catch2)
include(CTest)
include(Catch)
@@ -191,7 +194,7 @@ project(baz LANGUAGES CXX VERSION 0.0.1)
find_package(Catch2 REQUIRED)
add_executable(foo test.cpp)
-target_link_libraries(foo Catch2::Catch2)
+target_link_libraries(foo PRIVATE Catch2::Catch2)
include(CTest)
include(ParseAndAddCatchTests)