Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Initial prototype of PCH support

Related to #1061
Commit
9796a77a37133d1cac3e45749fa636b6dd57e135
Author
Martin Hořeňovský ·
Parents
98d4c49d1c97

Files · Download .tar.gz

Changes

 docs/build-systems.md | 11 +++++++++++
 include/catch.hpp     | 13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/docs/build-systems.md b/docs/build-systems.md
index 20711d37..45a7c206 100644
--- a/docs/build-systems.md
+++ b/docs/build-systems.md
@@ -55,6 +55,17 @@ Because of the incremental nature of Catch's test suites and ability to run spec
 
 ## Low-level tools
 
+### Precompiled headers (PCHs)
+
+Catch offers prototypal support for being included in precompiled headers, but because of its single-header nature it does need some actions by the user:
+* The precompiled header needs to define `CATCH_CONFIG_ALL_PARTS`
+* The implementation file needs to
+  * undefine `TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED`
+  * define `CATCH_CONFIG_IMPL_ONLY`
+  * define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`
+  * include "catch.hpp" again
+
+
 ### CMake
 
 In general we recommend "vendoring" Catch's single-include releases inside your own repository. If you do this, the following example shows a minimal CMake project:
diff --git a/include/catch.hpp b/include/catch.hpp
index 118337c9..ef141d8f 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -9,6 +9,7 @@
 #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_HPP_INCLUDED
 
+
 #ifdef __clang__
 #    pragma clang system_header
 #elif defined __GNUC__
@@ -19,12 +20,19 @@
 
 #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
 #  define CATCH_IMPL
+#  define CATCH_CONFIG_ALL_PARTS
+#endif
+
+// In the impl file, we want to have access to all parts of the headers
+// Can also be used to sanely support PCHs
+#if defined(CATCH_CONFIG_ALL_PARTS)
 #  define CATCH_CONFIG_EXTERNAL_INTERFACES
 #  if defined(CATCH_CONFIG_DISABLE_MATCHERS)
 #    undef CATCH_CONFIG_DISABLE_MATCHERS
 #  endif
 #endif
 
+#if !defined(CATCH_CONFIG_IMPL_ONLY)
 #include "internal/catch_platform.h"
 
 #ifdef CATCH_IMPL
@@ -61,6 +69,8 @@
 #include "internal/catch_external_interfaces.h"
 #endif
 
+#endif // ! CATCH_CONFIG_IMPL_ONLY
+
 #ifdef CATCH_IMPL
 #include "internal/catch_impl.hpp"
 #endif
@@ -69,6 +79,7 @@
 #include "internal/catch_default_main.hpp"
 #endif
 
+#if !defined(CATCH_CONFIG_IMPL_ONLY)
 
 #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
 #  undef CLARA_CONFIG_MAIN
@@ -327,6 +338,8 @@ using Catch::Detail::Approx;
 
 #endif
 
+#endif // ! CATCH_CONFIG_IMPL_ONLY
+
 #include "internal/catch_reenable_warnings.h"
 
 #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED