From a4ac07d1049e8cafdd5b9ab551055a6bddcc132d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 1 Aug 2020 19:09:18 +0200 Subject: [PATCH] Split out default CATCH_CONFIG_CONSOLE_WIDTH into its own header This means that code that uses it no longer has to include all of catch_config.hpp, which seems to provide significant reduction in size of unoptimized compilation of the final static library. --- src/CMakeLists.txt | 1 + src/catch2/catch_all.hpp | 1 + src/catch2/catch_config.hpp | 4 ---- src/catch2/interfaces/catch_interfaces_reporter.cpp | 2 ++ src/catch2/internal/catch_clara.hpp | 3 +-- src/catch2/internal/catch_console_width.hpp | 8 ++++++++ src/catch2/reporters/catch_reporter_bases.cpp | 1 + src/catch2/reporters/catch_reporter_console.cpp | 2 ++ src/catch2/reporters/catch_reporter_junit.cpp | 1 + 9 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 src/catch2/internal/catch_console_width.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1be01da7..47e151df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,6 +36,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/generators/catch_generators_all.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_all.hpp ${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp + ${SOURCES_DIR}/internal/catch_console_width.hpp ${SOURCES_DIR}/internal/catch_container_nonmembers.hpp ${SOURCES_DIR}/catch_approx.hpp ${SOURCES_DIR}/internal/catch_assertion_handler.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index fab323bd..5f8d32dc 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index 57ec1fff..3aa8b210 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -15,10 +15,6 @@ #include #include -#ifndef CATCH_CONFIG_CONSOLE_WIDTH -#define CATCH_CONFIG_CONSOLE_WIDTH 80 -#endif - namespace Catch { struct IStream; diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp index fb1d6d18..3d1a01c5 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.cpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp @@ -6,6 +6,8 @@ */ #include +#include +#include #include #include #include diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 2420a1d8..19db5492 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -9,8 +9,7 @@ #ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED #define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED -// For CATCH_CONFIG_CONSOLE_WIDTH. We should refactor this out somewhere else. -#include +#include // Use Catch's value for console width (store Clara's off to the side, if present) #ifdef CLARA_CONFIG_CONSOLE_WIDTH diff --git a/src/catch2/internal/catch_console_width.hpp b/src/catch2/internal/catch_console_width.hpp new file mode 100644 index 00000000..8bb3b83a --- /dev/null +++ b/src/catch2/internal/catch_console_width.hpp @@ -0,0 +1,8 @@ +#ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED +#define CATCH_CONSOLE_WIDTH_HPP_INCLUDED + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +#endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED \ No newline at end of file diff --git a/src/catch2/reporters/catch_reporter_bases.cpp b/src/catch2/reporters/catch_reporter_bases.cpp index 49b582c3..c8ec9490 100644 --- a/src/catch2/reporters/catch_reporter_bases.cpp +++ b/src/catch2/reporters/catch_reporter_bases.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index f7eabde8..3169d95a 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -8,6 +8,8 @@ #include +#include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 55f2e0aa..0f171e05 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include