Catch2::Catch2Main CMake target in v3 preview seems to create lots of work for users
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
I think that lots of Catch2 v2 users are going to have to make lots of repetitive edits to their CMakeLists.txt files....
I have a dozens of projects that use use Catch2 and ApprovalTests...
Their CMake `target_link_libraries` used to look like this:
```cmake
target_link_libraries(${PROJECT_NAME} PRIVATE ApprovalTests::ApprovalTests Catch2::Catch2)
```
These all use `CATCH_CONFIG_MAIN`, or occasionally `CATCH_CONFIG_RUNNER`...
I'm guessing that the vast majority of Catch2 users will use `CATCH_CONFIG_MAIN`.
In order to work with the Catch2 v3 preview release, I have had to change all of them to this:
```cmake
target_link_libraries(${PROJECT_NAME} PRIVATE ApprovalTests::ApprovalTests Catch2::Catch2)
if (TARGET Catch2::Catch2Main)
# link Catch2::Catch2Main only if it exists (so probably catch2 v3)
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2Main)
endif()
```
Am I right in assuming that every project that uses `CATCH_CONFIG_MAIN` will have to add `Catch2::Catch2Main` in v3 - and that if they wish to support v2 and v3 for a period, they will need the `if` block above as well?
**Expected behavior**
That v3 should ideally use the same CMake as v2...
**Idea**
Is it possible to make the CMake target that includes the main() be `Catch2::Catch2` - and to have the library one be something like `Catch2::Catch2WithoutMain`?
Contributor guide
Assessment
This issue has not been assessed yet.