Skip to content

refactor(Calorimeter): obtain tomlplusplus via find_package#23

Merged
olantwin merged 2 commits into
mainfrom
refactor/calorimeter-tomlplusplus-find-package
Jun 5, 2026
Merged

refactor(Calorimeter): obtain tomlplusplus via find_package#23
olantwin merged 2 commits into
mainfrom
refactor/calorimeter-tomlplusplus-find-package

Conversation

@olantwin
Copy link
Copy Markdown
Contributor

@olantwin olantwin commented Jun 4, 2026

Summary

  • Replace the `FetchContent_Declare(tomlplusplus)` block in `subsystems/Calorimeter/CMakeLists.txt` with a single `find_package(tomlplusplus REQUIRED)` call.
  • Aligns with how the repo treats its other production dependencies (`GeoModelCore`, `GeoModelIO`, `GeoModelTools` — all `find_package(... REQUIRED)` in the top-level `CMakeLists.txt`).
  • The `$<BUILD_INTERFACE:tomlplusplus::tomlplusplus>` wrapping in `target_link_libraries` is preserved — that's an install-time export concern and is independent of how the package is resolved.

Motivation

Surfaced while writing a `shipgeometry` recipe for `ship-conda-recipes`. `FetchContent` requires network at configure time, which we'd rather avoid in packaged builds. `tomlplusplus` is available on conda-forge (and as e.g. `libtomlplusplus-dev` on Debian/Ubuntu), so requiring it as a system dep is a small environment-setup bump rather than real friction.

Behaviour change

Builds without `tomlplusplus` installed will now fail at configure time with a clear CMake error pointing at the missing package, rather than silently downloading from GitHub. For contributors, `pixi install` / `apt install libtomlplusplus-dev` / `brew install tomlplusplus` covers it.

Test plan

  • CI (`build-test.yml`) stays green — the LCG / CVMFS environment should already provide `tomlplusplus`.
  • Existing Catch2 tests in `subsystems/Calorimeter/test_calorimeter.cpp` continue to pass (they exercise CalorimeterConfig's toml++ parsing).

Summary by CodeRabbit

  • Chores
    • Updated dependency management to use package manager distribution instead of pinned source downloads
    • Modified build configuration to resolve dependencies via standard package installation mechanisms

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR migrates toml++ from a pinned vendored source (FetchContent) to a system-managed dependency. The pixi configuration declares the tomlplusplus dependency, the CMake build file switches to find_package, and the source include path updates to match the system package layout.

Changes

toml++ System Dependency Integration

Layer / File(s) Summary
Dependency declaration and build integration
pixi.toml, subsystems/Calorimeter/CMakeLists.txt, subsystems/Calorimeter/src/CalorimeterConfig.cpp
pixi.toml declares tomlplusplus = "*" as a managed dependency. CMakeLists.txt replaces the FetchContent pinned-download block with find_package(tomlplusplus REQUIRED), referencing conda-forge and Linux distro sources. CalorimeterConfig.cpp updates the include path from toml++.toml.hpp to toml++/toml.h to align with the system package.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • ShipSoft/Geometry#26: This PR's pixi-based dependency management builds on the pixi build environment introduced in that PR.

Suggested reviewers

  • matclim
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: switching tomlplusplus dependency resolution from FetchContent to find_package in the Calorimeter subsystem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/calorimeter-tomlplusplus-find-package

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
subsystems/Calorimeter/src/CalorimeterConfig.cpp

subsystems/Calorimeter/src/CalorimeterConfig.cpp:27:10: fatal error: 'Calorimeter/CalorimeterConfig.h' file not found
27 | #include "Calorimeter/CalorimeterConfig.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
subsystems/Calorimeter/src/CalorimeterConfig.cpp:130:5-131:38: ERROR translating statement 'IfStmt'
Aborting translation of method 'SHiPGeometry::anonymous_namespace_subsystems_Calorimeter_src_CalorimeterConfig.cpp::readNumeric' in file 'subsystems/Calorimeter/src/CalorimeterConfig.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/cl

... [truncated 2200 characters] ...

in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml" (inlined), line 5365, characters 28-54
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs in file "src/clang/cTrans.ml" (inlined), line 5389, characters 6-70
Called from ClangFrontend__CTrans.CTran


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Replace the FetchContent_Declare(tomlplusplus) block with a single
find_package(tomlplusplus REQUIRED). This avoids fetching toml++ from
GitHub at configure time and aligns with how the repo treats its other
production dependencies (GeoModelCore, GeoModelIO, GeoModelTools).

tomlplusplus is available on conda-forge and in most distros, so this is a
small environment-setup requirement bump rather than a real friction
increase. Builds without the package installed will fail at configure
time with a clear CMake error pointing at the missing package.
@olantwin olantwin force-pushed the refactor/calorimeter-tomlplusplus-find-package branch from 140d6d0 to 733373b Compare June 5, 2026 14:48
Commit 733373b switched the Calorimeter from FetchContent to
find_package(tomlplusplus REQUIRED), but the pixi environment used by
CI didn't declare tomlplusplus, so configure failed with
"Could not find a package configuration file provided by tomlplusplus".

Add tomlplusplus to pixi.toml [dependencies]. conda-forge only ships
3.3.0, which still uses the legacy <toml++/toml.h> header
(the .h -> .hpp rename landed in 3.4.0), so update
CalorimeterConfig.cpp to include <toml++/toml.h>. This matches the
version available in the pixi env; if a newer build is later published
on the SHiP channel we can switch back to toml.hpp.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
subsystems/Calorimeter/src/CalorimeterConfig.cpp (1)

6-8: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale FetchContent reference.

This comment still mentions "fetched via CMake FetchContent," but the PR migrates to find_package. Update the documentation to reflect the new system-managed dependency approach.

📝 Proposed fix to update the comment
-// Calorimeter configuration parser. Reads a calo.toml file and populates
-// a CalorimeterConfig struct. Built on toml++
-// (https://github.com/marzer/tomlplusplus, single-header MIT, fetched via
-// CMake FetchContent), so the file format is standard TOML — no bespoke
-// scanner, no semicolon quirks.
+// Calorimeter configuration parser. Reads a calo.toml file and populates
+// a CalorimeterConfig struct. Built on toml++
+// (https://github.com/marzer/tomlplusplus, single-header MIT, resolved via
+// find_package from conda-forge/system packages), so the file format is 
+// standard TOML — no bespoke scanner, no semicolon quirks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@subsystems/Calorimeter/src/CalorimeterConfig.cpp` around lines 6 - 8, Update
the explanatory comment about tomlplusplus in CalorimeterConfig.cpp to remove
the outdated "fetched via CMake FetchContent" wording and state that
tomlplusplus is now resolved/managed via find_package (system-managed
dependency), e.g., replace the phrase "fetched via CMake FetchContent" with
something like "discovered via CMake find_package / system-managed dependency"
while keeping the rest of the note about tomlplusplus being a single-header MIT
library and the TOML format standards intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@subsystems/Calorimeter/src/CalorimeterConfig.cpp`:
- Line 36: The include in CalorimeterConfig.cpp currently uses the legacy header
name <toml++/toml.h> which breaks with tomlplusplus ≥3.4.0 where the header is
<toml++/toml.hpp>; either pin tomlplusplus in pixi.toml to the older version or
change CalorimeterConfig.cpp to conditionally include the correct header (e.g.,
use preprocessor detection like __has_include to try <toml++/toml.hpp> first and
fall back to <toml++/toml.h>), ensuring any code using the toml++ symbols
remains unchanged.

---

Outside diff comments:
In `@subsystems/Calorimeter/src/CalorimeterConfig.cpp`:
- Around line 6-8: Update the explanatory comment about tomlplusplus in
CalorimeterConfig.cpp to remove the outdated "fetched via CMake FetchContent"
wording and state that tomlplusplus is now resolved/managed via find_package
(system-managed dependency), e.g., replace the phrase "fetched via CMake
FetchContent" with something like "discovered via CMake find_package /
system-managed dependency" while keeping the rest of the note about tomlplusplus
being a single-header MIT library and the TOML format standards intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a79aa9f0-d8ec-422f-8ddd-0e3b46eb79f9

📥 Commits

Reviewing files that changed from the base of the PR and between 1d79150 and 58c2e22.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • pixi.toml
  • subsystems/Calorimeter/CMakeLists.txt
  • subsystems/Calorimeter/src/CalorimeterConfig.cpp

#include <string>
#include <string_view>
#include <toml++/toml.hpp>
#include <toml++/toml.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Header path assumes tomlplusplus <3.4.0.

This include uses the legacy .h extension, which matches tomlplusplus 3.3.0. However, pixi.toml specifies tomlplusplus = "*", allowing any version. When tomlplusplus ≥3.4.0 becomes available on conda-forge, this build will fail because the header was renamed to toml++/toml.hpp.

Either pin the version constraint in pixi.toml (see comment on pixi.toml:17) or use conditional compilation to support both header names.

🔄 Alternative fix: support both header names

If you want to support both old and new versions, use version-detection:

-#include <toml++/toml.h>
+#if __has_include(<toml++/toml.hpp>)
+#include <toml++/toml.hpp>
+#else
+#include <toml++/toml.h>
+#endif

This allows the code to work with both v3.3.0 (.h) and v3.4.0+ (.hpp), and you can then use a wider version range like tomlplusplus = ">=3.3.0" in pixi.toml.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@subsystems/Calorimeter/src/CalorimeterConfig.cpp` at line 36, The include in
CalorimeterConfig.cpp currently uses the legacy header name <toml++/toml.h>
which breaks with tomlplusplus ≥3.4.0 where the header is <toml++/toml.hpp>;
either pin tomlplusplus in pixi.toml to the older version or change
CalorimeterConfig.cpp to conditionally include the correct header (e.g., use
preprocessor detection like __has_include to try <toml++/toml.hpp> first and
fall back to <toml++/toml.h>), ensuring any code using the toml++ symbols
remains unchanged.

@olantwin olantwin merged commit d193ae1 into main Jun 5, 2026
3 checks passed
@olantwin olantwin deleted the refactor/calorimeter-tomlplusplus-find-package branch June 5, 2026 15:22
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.

1 participant