mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Add the static library Catch2WithMain
It should provide a shared impl for all targets that need to link against Catch2's implementation. However, due to limitations of C++ linking and Catch2's v2 implementation, this is only experimental and might not work under some circumstances.
This commit is contained in:

committed by
Martin Hořeňovský

parent
dc7e705672
commit
92f8b01dfa
@@ -5,6 +5,7 @@
|
||||
[Short answer](#short-answer)<br>
|
||||
[Long answer](#long-answer)<br>
|
||||
[Practical example](#practical-example)<br>
|
||||
[Using the static library Catch2WithMain](#using-the-static-library-catch2withmain)<br>
|
||||
[Other possible solutions](#other-possible-solutions)<br>
|
||||
|
||||
Several people have reported that test code written with Catch takes much longer to compile than they would expect. Why is that?
|
||||
@@ -64,6 +65,24 @@ tests-factorial.cpp:11: failed: Factorial(0) == 1 for: 0 == 1
|
||||
Failed 1 test case, failed 1 assertion.
|
||||
```
|
||||
|
||||
|
||||
## Using the static library Catch2WithMain
|
||||
|
||||
Catch2 also provides a static library that implements the runner. Note
|
||||
that this support is experimental, due to interactions between Catch2 v2
|
||||
implementation and C++ linking limitations.
|
||||
|
||||
As with the `Catch2` target, the `Catch2WithMain` CMake target can be used
|
||||
either from a subdirectory, or from installed build.
|
||||
|
||||
### CMake
|
||||
```cmake
|
||||
add_executable(tests-factorial tests-factorial.cpp)
|
||||
|
||||
target_link_libraries(tests-factorial Catch2::Catch2WithMain)
|
||||
```
|
||||
|
||||
|
||||
## Other possible solutions
|
||||
You can also opt to sacrifice some features in order to speed-up Catch's compilation times. For details see the [documentation on Catch's compile-time configuration](configuration.md#other-toggles).
|
||||
|
||||
|
Reference in New Issue
Block a user