Skip to content

Commit c1bb209

Browse files
committed
Fix packaging and test infrastructure for portable distribution
- Fix CPack packaging to include HDF5 and Irrlicht DLLs - Fix data directory install path (trailing slash issue) - Include test input data (YAML, H5, geometry) in package - Set HYDROCHRONO_DATA_DIR in RUN-TESTS.ps1 for portable execution - Remove deprecated Chrono API calls (GetTypeAsString) in regression tests
1 parent 82c55e3 commit c1bb209

5 files changed

Lines changed: 62 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ endif()
162162
file(COPY ${CMAKE_SOURCE_DIR}/data/ DESTINATION ${HC_BUILD_DATA})
163163
message(STATUS " copied to: ${HC_BUILD_DATA}/")
164164

165-
# Install data directory
166-
install(DIRECTORY ${HC_BUILD_DATA} DESTINATION ${HC_INSTALL_DATA})
165+
# Install data directory (trailing slash copies contents, not the directory itself)
166+
install(DIRECTORY ${HC_BUILD_DATA}/ DESTINATION ${HC_INSTALL_DATA})
167167
message(STATUS " installed to: ${CMAKE_INSTALL_PREFIX}/${HC_INSTALL_DATA}/")
168168

169169
# -- Output Directory Structure --
@@ -663,14 +663,45 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
663663
endif()
664664
endforeach()
665665

666-
# HDF5 DLLs
666+
# HDF5 DLLs - use glob to find all DLLs in HDF5 bin directory
667+
if(DEFINED HDF5_ROOT OR DEFINED HDF5_DIR)
668+
# Determine HDF5 root from various possible variables
669+
if(DEFINED HDF5_ROOT)
670+
set(_hdf5_root "${HDF5_ROOT}")
671+
elseif(DEFINED HDF5_DIR)
672+
# HDF5_DIR might point to share/cmake/hdf5 or similar
673+
get_filename_component(_hdf5_root "${HDF5_DIR}" DIRECTORY)
674+
get_filename_component(_hdf5_root "${_hdf5_root}" DIRECTORY)
675+
get_filename_component(_hdf5_root "${_hdf5_root}" DIRECTORY)
676+
endif()
677+
678+
set(_hdf5_bin "${_hdf5_root}/bin")
679+
if(EXISTS "${_hdf5_bin}")
680+
file(GLOB _hdf5_dlls "${_hdf5_bin}/*.dll")
681+
if(_hdf5_dlls)
682+
message(STATUS "Installing HDF5 DLLs from: ${_hdf5_bin}")
683+
install(FILES ${_hdf5_dlls} DESTINATION bin COMPONENT runtime)
684+
endif()
685+
endif()
686+
endif()
687+
688+
# Also try target-based approach as fallback
667689
foreach(tgt ${HDF5_TARGETS})
668690
get_target_property(tgt_DLL ${tgt} IMPORTED_LOCATION_RELEASE)
669691
if(EXISTS ${tgt_DLL})
670692
install(FILES ${tgt_DLL} DESTINATION bin COMPONENT runtime)
671693
endif()
672694
endforeach()
673695

696+
# Irrlicht DLL
697+
if(HYDROCHRONO_ENABLE_IRRLICHT AND DEFINED Irrlicht_ROOT)
698+
set(_irr_dll "${Irrlicht_ROOT}/bin/Win64-VisualStudio/Irrlicht.dll")
699+
if(EXISTS "${_irr_dll}")
700+
message(STATUS "Installing Irrlicht.dll from: ${_irr_dll}")
701+
install(FILES "${_irr_dll}" DESTINATION bin COMPONENT runtime)
702+
endif()
703+
endif()
704+
674705
# Python DLLs, if Chrono::Parsers depends on it
675706
if(CHRONO_PARSERS_PYTHON)
676707
find_package(Python3 QUIET COMPONENTS Interpreter Development)
@@ -694,6 +725,13 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/tests/regression/run_hydrochrono
694725
PATTERN "__pycache__" EXCLUDE
695726
PATTERN "*.pyc" EXCLUDE)
696727

728+
# Install test input data (YAML configs, hydro data, geometry) into tests/run_hydrochrono
729+
# The Python scripts expect test case folders (iea_sphere/, oswec/, rm3/, f3of/) to be siblings
730+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/demos/run_hydrochrono/
731+
DESTINATION tests/run_hydrochrono COMPONENT python-tests
732+
PATTERN "__pycache__" EXCLUDE
733+
PATTERN "*.pyc" EXCLUDE)
734+
697735
# Simple runner script to execute tests from the installed tree
698736
install(PROGRAMS ${PROJECT_SOURCE_DIR}/scripts/RUN-TESTS.ps1
699737
DESTINATION tests COMPONENT python-tests)

build.ps1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,25 @@ function Package-Artifacts {
744744
}
745745
$hdf5Bin = Join-Path $hdf5Root "bin"
746746
if (Test-Path $hdf5Bin) {
747+
Write-Info "Copying HDF5 DLLs from: $hdf5Bin"
748+
$hdf5Count = 0
747749
Get-ChildItem -Path $hdf5Bin -Filter "*.dll" -ErrorAction SilentlyContinue | ForEach-Object {
748750
$dest = Join-Path $installBin $_.Name
749-
if (-not (Test-Path $dest)) {
750-
Copy-Item -Path $_.FullName -Destination $dest -Force -ErrorAction SilentlyContinue
751-
}
751+
Copy-Item -Path $_.FullName -Destination $dest -Force -ErrorAction SilentlyContinue
752+
$hdf5Count++
752753
}
754+
Write-Info "Copied $hdf5Count HDF5 DLL(s)"
755+
} else {
756+
Write-Warning "HDF5 bin directory not found: $hdf5Bin"
757+
}
758+
759+
# Copy Irrlicht DLL
760+
$irrlichtDll = Join-Path $Config.IrrlichtDir "bin\Win64-VisualStudio\Irrlicht.dll"
761+
if (Test-Path $irrlichtDll) {
762+
Copy-Item -Path $irrlichtDll -Destination $installBin -Force -ErrorAction SilentlyContinue
763+
Write-Info "Copied Irrlicht.dll"
764+
} else {
765+
Write-Warning "Irrlicht.dll not found at: $irrlichtDll"
753766
}
754767
# Also copy DLLs from this project's build bin (Release/Debug) into install\bin
755768
$hcDllSource = Join-Path (Get-Location) "bin\$BuildType"

scripts/RUN-TESTS.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ if (!(Test-Path $exe)) {
2121
$oldPath = $env:PATH
2222
$env:PATH = "$bin;$env:PATH"
2323

24+
# Set data directory for the installed package
25+
# The executable has hardcoded build-time paths, so we override via environment
26+
$dataDir = Join-Path $installRoot "data"
27+
$env:HYDROCHRONO_DATA_DIR = $dataDir
28+
2429
Push-Location $tests
2530

2631
$reqs = @()

tests/regression/f3of/test_f3of_dt2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ int main(int argc, char* argv[]) {
173173
}
174174

175175
std::cout << "Start simulation" << std::endl;
176-
std::cout << " Integrator: " << system.GetTimestepper()->GetTypeAsString() << std::endl;
177-
std::cout << " Solver: " << system.GetSolver()->GetTypeAsString() << std::endl;
178176
std::cout << " Step size: " << timestep << std::endl;
179177
std::cout << " Duration: " << simulationDuration << std::endl;
180178

tests/regression/oswec/test_oswec_decay.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ int main(int argc, char* argv[]) {
202202
}
203203

204204
std::cout << "Start simulation"<< std::endl;
205-
std::cout << " Integrator: " << system.GetTimestepper()->GetTypeAsString() << std::endl;
206-
std::cout << " Solver: " << system.GetSolver()->GetTypeAsString() << std::endl;
207205
std::cout << " Step size: " << timestep << std::endl;
208206
std::cout << " Duration: " << simulationDuration << std::endl;
209207

0 commit comments

Comments
 (0)