Make fmt, std::format optional#263
Open
K20shores wants to merge 11 commits into
Open
Conversation
Introduces a CMake option (default OFF) to use the {fmt} library instead
of std::format, dropping the C++ requirement from 20 to 17. A shim header
(format_compat.hpp) aliases fmt or std into mc_fmt so call sites are
unchanged. The NodeInfo struct gains an explicit constructor to support
C++17 aggregate initialization rules. Packaging conditionally installs
fmt when built from source and emits find_dependency(fmt) when found
via the system.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #263 +/- ##
=======================================
Coverage 70.00% 70.00%
=======================================
Files 5 5
Lines 10 10
=======================================
Hits 7 7
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in build path to support C++17 by routing formatting calls through a compatibility shim that uses either {fmt} or std::format, and updates CMake/packaging to conditionally bring in {fmt}.
Changes:
- Introduce
MECH_CONFIG_USE_FMT(default OFF) to build with C++17 +{fmt}instead of C++20 +std::format. - Add
format_compat.hppshim and migrate call sites fromstd::format(...)tomc_fmt::format(...). - Update packaging/config generation to optionally install/declare
{fmt}as a dependency; adjustErrorLocationformatter specialization andNodeInfoconstruction for C++17 compatibility.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/validate_schema.cpp | Switch formatting calls to mc_fmt::format via shim include. |
| src/parser.cpp | Replace std::format usage with mc_fmt::format. |
| src/development/utils.cpp | Replace std::format usage with mc_fmt::format. |
| src/development/type_validators.cpp | Replace std::format usage with mc_fmt::format. |
| src/development/reactions/validators/wet_deposition.cpp | Replace <format> include with shim include. |
| src/development/reactions/validators/user_defined.cpp | Replace <format> include with shim include. |
| src/development/reactions/validators/taylor_series.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/surface.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/simpol_phase_transfer.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/photolysis.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/lambda_rate_constant.cpp | Replace <format> include with shim include. |
| src/development/reactions/validators/henrys_law.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/first_order_loss.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/emission.cpp | Replace <format> include with shim include. |
| src/development/reactions/validators/condensed_phase_photolysis.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/condensed_phase_arrhenius.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/branched.cpp | Replace <format> include with shim include. |
| src/development/reactions/validators/arrhenius.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/development/reactions/validators/aqueous_equilibrium.cpp | Replace <format> include with shim include. |
| src/development/models/validators/modal.cpp | Replace formatting calls with mc_fmt::format. |
| src/development/mechanism.cpp | Replace formatting calls with mc_fmt::format and include shim. |
| src/CMakeLists.txt | Conditionally set C++17 + {fmt} vs C++20 + std::format. |
| packaging/CMakeLists.txt | Conditionally install/export {fmt} target and set config-time dependency flag. |
| include/mechanism_configuration/format_compat.hpp | New shim header selecting {fmt} or std::format under mc_fmt. |
| include/mechanism_configuration/error_location.hpp | Use shim include and provide {fmt} vs std::formatter specialization. |
| include/mechanism_configuration/development/utils.hpp | Add NodeInfo constructor to support C++17 (non-parenthesized aggregate init). |
| cmake/mechanism_configurationConfig.cmake.in | Conditionally find_dependency(fmt) for consumers. |
| cmake/dependencies.cmake | Add optional {fmt} FetchContent dependency when enabled. |
| CMakeLists.txt | Add MECH_CONFIG_USE_FMT option; remove global C++20 standard setting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds fmt-variant jobs to the Mac, Ubuntu, and Windows workflows that mirror the existing jobs but configure with -D MECH_CONFIG_USE_FMT=ON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the duplicate fmt/non-fmt jobs with a single job per runner that includes use_fmt: [false, true] in the matrix. On Ubuntu, use_fmt also controls whether CMAKE_CXX_STANDARD=20 is passed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Passes the value directly to CMake rather than using boolean conditionals. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MSVC rejects designated initializers in C++17 mode (C7555). GCC/Clang accept them as an extension but MSVC is strict. Replace all five occurrences in the v0 parsers with positional brace-init. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MECH_CONFIG_USE_FMT still allows swapping std::format for fmt::format, but the C++ standard stays at 20 regardless. Reverts the cxx_std_17 downgrade, NodeInfo constructor, and designated initializer workarounds that were only needed for C++17 compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These were replaced with positional brace-init during the now-abandoned C++17 support work. C++20 is still the standard, so designated initializers are valid and preferred. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fmt headers are included from the public header format_compat.hpp, so consumers need fmt's include dirs propagated. PRIVATE suppresses that. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
boulderdaze
approved these changes
May 4, 2026
…nd Docker Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
boulderdaze
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a CMake option (default OFF) to use the {fmt} library instead of std::format, A shim header (format_compat.hpp) aliases fmt or std into mc_fmt so call sites are unchanged. Packaging conditionally installs fmt when built from source and emits find_dependency(fmt) when found via the system.
This change is necessary because NOAA uses GCC11 which does not have full c++ 20 support and they can't use
std::format. We will reject this PR if they can get their compiler stack updated to a supported version of GCCAlso removed some unused variables and some erronoues
std::movecloses #262