Skip to content

Update Catch2 library settings for MSVC and C++ standard#3066

Open
AbhishekkSaini wants to merge 1 commit intocatchorg:develfrom
AbhishekkSaini:patch-2
Open

Update Catch2 library settings for MSVC and C++ standard#3066
AbhishekkSaini wants to merge 1 commit intocatchorg:develfrom
AbhishekkSaini:patch-2

Conversation

@AbhishekkSaini
Copy link

Description

Improves Catch2 compilation times by enabling some standard build optimizations that were previously disabled.

The main changes are:

  • Turn on MSVC's /MP flag to compile files in parallel across CPU cores
  • Use C++17 instead of defaulting to C++20 (MSVC wastes time scanning for modules in C++20 mode even though we don't use them)
  • Enable unity builds with a batch size of 8 files per unit

I tested a few different batch sizes and found that 8 works well - higher values like 25 caused some operator overload ambiguity issues during compilation, but 8 seems to avoid those while still giving good speedup.

On my machine (8 cores, MSVC), build time went from about 70 seconds down to around 10-15 seconds, so it's a pretty substantial improvement. The /MP flag only affects MSVC builds, so other compilers shouldn't see any difference there, but they should still benefit from the unity build settings.

GitHub Issues

Fixes #2894

@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.09%. Comparing base (de7e863) to head (94ef6c4).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3066      +/-   ##
==========================================
- Coverage   91.14%   91.09%   -0.06%     
==========================================
  Files         202      202              
  Lines        8831     8840       +9     
==========================================
+ Hits         8049     8052       +3     
- Misses        782      788       +6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile Time Improvements

1 participant