File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ if(NOT Chrono_DIR)
168168 return ()
169169endif ()
170170
171+ # Pre-load HDF5 targets so the shims below are only created when genuinely
172+ # needed (i.e., when HDF5 config-mode doesn't provide hdf5_tools).
173+ # Without this, installers that define all HDF5 targets as a batch
174+ # (e.g., HDF Group installer) error out on the partial pre-definition.
175+ find_package (HDF5 CONFIG QUIET )
176+
171177# Chrono's export file may reference hdf5::hdf5_tools-{shared,static} which is
172178# absent from some HDF5 installations (e.g., vcpkg). Provide empty shims so
173179# ChronoTargets.cmake loads without errors. Must be created BEFORE find_package(Chrono).
@@ -250,9 +256,8 @@ endif()
250256find_package (OpenMP REQUIRED COMPONENTS CXX )
251257
252258# -- HDF5 Integration --
253- # Prefer config-mode (vcpkg, official HDF5 installer). Fall back to CMake's
254- # built-in FindHDF5 module for system-installed packages (apt, yum, brew, etc.).
255- find_package (HDF5 CONFIG QUIET )
259+ # Config-mode discovery runs early (before Chrono) to avoid target conflicts
260+ # with the hdf5_tools shims. Fall back to module-mode here if it wasn't found.
256261if (NOT HDF5_FOUND)
257262 find_package (HDF5 REQUIRED COMPONENTS CXX )
258263endif ()
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ if (-not $hasHDF5) {
154154# Eigen3: extract include path from Chrono config so FindEigen3.cmake can
155155# bypass Eigen3ConfigVersion.cmake (Eigen 5.x rejects the "3.3" request).
156156$eigen3Include = $null
157- if ($chronoContent -match ' Eigen3_DIR\s+"([^"]+)"' ) {
157+ if ($chronoContent -match ' Eigen3_DIR\s+"([^"]+)"' -and $Matches [ 1 ] -notmatch ' NOTFOUND ' ) {
158158 $eigen3Root = Split-Path (Split-Path $Matches [1 ])
159159 $candidate = Join-Path $eigen3Root " include/eigen3"
160160 if (Test-Path (Join-Path $candidate " Eigen" )) {
@@ -164,6 +164,15 @@ if ($chronoContent -match 'Eigen3_DIR\s+"([^"]+)"') {
164164 Write-Warn " Eigen3 headers not found at $candidate "
165165 }
166166}
167+ if (-not $eigen3Include -and $chronoContent -match ' EIGEN3_INCLUDE_DIR\s+"([^"]+)"' -and $Matches [1 ] -notmatch ' NOTFOUND' ) {
168+ $candidate = $Matches [1 ]
169+ if (Test-Path (Join-Path $candidate " Eigen" )) {
170+ $eigen3Include = $candidate
171+ Write-OK " Eigen3: $eigen3Include (via EIGEN3_INCLUDE_DIR)"
172+ } else {
173+ Write-Warn " Eigen3 headers not found at $candidate "
174+ }
175+ }
167176
168177# =============================================================================
169178# Check CMake
You can’t perform that action at this time.
0 commit comments