Skip to content

Commit

Permalink
Initial prototype of PCH support
Browse files Browse the repository at this point in the history
Related to #1061
  • Loading branch information
horenmar committed Nov 14, 2017
1 parent 98d4c49 commit 9796a77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/build-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions include/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_HPP_INCLUDED


#ifdef __clang__
# pragma clang system_header
#elif defined __GNUC__
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 9796a77

Please sign in to comment.