Repository navigation
Closed
Labels
Description
Since Catch2 v3.13.0, building Catch2 itself fails if CATCH_CONFIG_PREFIX_ALL is set:
Building CXX object Catch2/src/CMakeFiles/Catch2.dir/catch2/internal/catch_run_context.cpp.o
FAILED: Catch2/src/CMakeFiles/Catch2.dir/catch2/internal/catch_run_context.cpp.o
/usr/bin/ccache /bin/g++ -DCATCH_CONFIG_PREFIX_ALL -I/Catch2/src/catch2/.. -I/CMakeFiles/Catch2/generated-includes -std=gnu++17 -fmessage-length=0 -fPIC -m64 -D__64BIT__ -O2 -ffile-prefix-map=/Catch2/= -MD -MT Catch2/src/CMakeFiles/Catch2.dir/catch2/internal/catch_run_context.cpp.o -MF Catch2/src/CMakeFiles/Catch2.dir/catch2/internal/catch_run_context.cpp.o.d -o Catch2/src/CMakeFiles/Catch2.dir/catch2/internal/catch_run_context.cpp.o -c /Catch2/src/catch2/internal/catch_run_context.cpp
/src/catch2/internal/catch_run_context.cpp: In constructor ‘Catch::Generators::{anonymous}::GeneratorTracker::GeneratorTracker(Catch::TestCaseTracking::NameAndLocation&&, Catch::TestCaseTracking::TrackerContext&, Catch::TestCaseTracking::ITracker*, Catch::Generators::GeneratorBasePtr&&)’:
/src/catch2/internal/catch_run_context.cpp:65:29: error: ‘SKIP’ was not declared in this scope
SKIP();
^~~~
/src/catch2/internal/catch_run_context.cpp: In member function ‘virtual Catch::IGeneratorTracker* Catch::RunContext::createGeneratorTracker(Catch::StringRef, Catch::SourceLineInfo, Catch::Generators::GeneratorBasePtr&&)’:
/src/catch2/internal/catch_run_context.cpp:523:13: error: ‘FAIL’ was not declared in this scope
FAIL( "GENERATE() would run infinitely" );
^~~~
/src/catch2/internal/catch_run_context.cpp:523:13: note: suggested alternative: ‘FILE’
FAIL( "GENERATE() would run infinitely" );
^~~~
FILE
This change in behavior was introduced recently:
- Support filtering on both sections and generators #3069 introduced
SKIP()intocatch_run_context.cpp. FAIL()was introduced in daadf42
In our cmake setup, we had CATCH_CONFIG_PREFIX_ALL set before including Catch2 and that always worked -- now it doesn't. Unfortunately, there's (as far as I can tell) no version of the FAIL and SKIP macros that's always available, no matter what prefixing option the user chose.
I'm happy to prepare a PR, but I'd like to know from the maintainers:
- Do you prefer to inline the functionality of FAIL and SKIP into
catch_run_context.cpp(the comments above it seem to indicate that was thought of)? - Do you want to explicitly spell out that defines
CATCH_CONFIG_PREFIX_ALLand friends need to be set after Catch2 is built.
Activity
horenmar commentedon Apr 1, 2026
No, it should be fine to have it always enabled.
My original reason to go through the macros was to avoid problems if the macro definitions later change. However, this shouldn't happen too often and I think it will still end up cleaner than using preprocessor check for
CATCH_CONFIG_PREFIX_ALLand picking which of the two variants to use.Inline SKIP/FAIL in RunContext to fix build failure with prefixed macros