Skip to content

Commit d3689d9

Browse files
authored
Merge pull request #74 from Project-SEA-Stack/enable-linux-build
Enable Linux build: updated CMakeLists and YAML parser
2 parents a584df3 + 1017a24 commit d3689d9

3 files changed

Lines changed: 39 additions & 28 deletions

File tree

CMakeLists.txt

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020
# ═══════════════════════════════════════════════════════════════════════════════
2121

2222
project(HydroChrono
23-
VERSION 0.3
23+
VERSION 0.3.1
2424
DESCRIPTION "Hydrodynamics for Project Chrono."
2525
LANGUAGES CXX
2626
)
@@ -147,11 +147,27 @@ endif()
147147

148148
# Now we can find Chrono (which assumes Irrlicht::Irrlicht already exists)
149149
find_package(Chrono CONFIG REQUIRED)
150+
message(STATUS "Chrono core targets: ${Chrono_LIBRARIES}")
151+
152+
if(EXISTS "${Chrono_DIR}/ChronoTargets.cmake")
153+
include("${Chrono_DIR}/ChronoTargets.cmake")
154+
message(STATUS "Manually included ChronoTargets.cmake from ${Chrono_DIR}")
155+
endif()
156+
150157

151158
# Verify required Chrono targets are available
152159
if(NOT TARGET Chrono::Chrono_core)
153160
message(FATAL_ERROR "Chrono::Chrono_core target not found. Ensure Chrono was built with modern CMake target exports.")
154161
endif()
162+
# Find OpenMP first to ensure OpenMP::OpenMP_CXX is available
163+
find_package(OpenMP REQUIRED)
164+
165+
if(OpenMP_CXX_FOUND)
166+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
167+
endif()
168+
169+
# Then include Chrono
170+
find_package(Chrono REQUIRED PATHS /usr/local/lib/cmake/Chrono)
155171

156172
# Enable Irrlicht support if requested and available
157173
if(HYDROCHRONO_ENABLE_IRRLICHT)
@@ -175,19 +191,8 @@ endif()
175191

176192
# ── HDF5 Integration ──
177193
# Prefer config package at provided root; avoid environment/registry
178-
if(DEFINED HDF5_DIR AND NOT DEFINED HDF5_ROOT)
179-
set(HDF5_ROOT "${HDF5_DIR}")
180-
endif()
181-
set(HDF5_ROOT "${HDF5_ROOT}" CACHE PATH "HDF5 root directory")
182-
if(DEFINED HDF5_ROOT)
183-
# Prepend so our supplied root wins
184-
if(CMAKE_PREFIX_PATH)
185-
set(CMAKE_PREFIX_PATH "${HDF5_ROOT};${CMAKE_PREFIX_PATH}")
186-
else()
187-
set(CMAKE_PREFIX_PATH "${HDF5_ROOT}")
188-
endif()
189-
endif()
190-
find_package(HDF5 CONFIG REQUIRED COMPONENTS CXX)
194+
195+
find_package(HDF5 REQUIRED COMPONENTS CXX)
191196

192197
# ---- Eigen: support both CONFIG and module modes ----
193198
find_package(Eigen3 QUIET CONFIG)
@@ -220,8 +225,6 @@ if (NOT HC_CHRONO_INCLUDE_DIRS AND DEFINED Chrono_DIR)
220225
endif()
221226

222227

223-
224-
225228
#-----------------------------------------------------------------------------
226229
# Fix for VS 2017 15.8 and newer to handle alignment specification with Eigen
227230
#-----------------------------------------------------------------------------
@@ -619,9 +622,14 @@ if(HC_INSTALL_DEV_KIT)
619622
)
620623
endif()
621624

622-
# ── Debug Symbols in Release Mode ──
623-
# Keep debug symbols in Release builds for better profiling and crash analysis
624-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /O2")
625+
if(MSVC)
626+
# Windows: Enable debug symbols in Release builds with MSVC
627+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /O2")
628+
else()
629+
# Non-MSVC (Linux, macOS): Use -g for debug symbols
630+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -O2")
631+
endif()
632+
625633

626634
# ──────────────────────────────────────────────────────────────────────────────
627635
# 7.1 Runtime installer and ZIP packaging for releases
@@ -750,12 +758,15 @@ if(HC_INSTALL_DEV_DEMOS)
750758
FILES_MATCHING PATTERN "demo_*.exe")
751759
endif()
752760

761+
753762
# MSVC runtime DLLs and ZIP packaging via CPack
754-
include(InstallRequiredSystemLibraries)
755-
set(CPACK_GENERATOR "ZIP")
756-
set(CPACK_PACKAGE_NAME "HydroChrono")
757-
set(CPACK_COMPONENTS_ALL runtime python-tests dev-demos)
758-
include(CPack)
763+
include(InstallRequiredSystemLibraries)
764+
set(CPACK_GENERATOR "ZIP")
765+
set(CPACK_PACKAGE_NAME "HydroChrono")
766+
set(CPACK_COMPONENTS_ALL runtime python-tests dev-demos)
767+
include(CPack)
768+
769+
759770

760771
# Optionally include Python runtime DLL if Chrono::Parsers depends on it
761772
find_package(Python3 QUIET COMPONENTS Interpreter)
@@ -768,4 +779,4 @@ if(Python3_Interpreter_FOUND OR Python3_FOUND)
768779
install(FILES "${_PY_DLL_PATH}" DESTINATION bin COMPONENT runtime)
769780
endif()
770781
endif()
771-
endif()
782+
endif()

src/hydro_yaml_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ YAMLHydroData ReadHydroYAML(const std::string& hydro_file_path) {
496496
t += step;
497497
}
498498
if (inclusive) {
499-
if (std::fabs((data.waves.period_values.empty() ? start : data.waves.period_values.back()) - stop) > eps) {
499+
if (std::abs((data.waves.period_values.empty() ? start : data.waves.period_values.back()) - stop) > eps) {
500500
// add last if not already close to stop and within tolerance by stepping once more would overshoot but inclusive means include stop
501501
data.waves.period_values.push_back(stop);
502502
} else {
@@ -566,4 +566,4 @@ YAMLHydroData ReadHydroYAML(const std::string& hydro_file_path) {
566566
}
567567

568568
return data;
569-
}
569+
}

src/utils/logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void CLILogger::ShowBanner() {
303303
Log(LogLevel::Success, "│ │", LogColor::BrightCyan);
304304
Log(LogLevel::Success, "│ Hydrodynamics for Project Chrono │", LogColor::White);
305305
Log(LogLevel::Success, "│ │", LogColor::BrightCyan);
306-
Log(LogLevel::Success, "│ Version : 0.3.0", LogColor::Gray);
306+
Log(LogLevel::Success, "│ Version : 0.3.1", LogColor::Gray);
307307
Log(LogLevel::Success, "│ Status : Prototype │", LogColor::Gray);
308308
Log(LogLevel::Success, "│ Author : SEA-Stack Development Team │", LogColor::Gray);
309309
Log(LogLevel::Success, "│ Lead Developer : David Ogden │", LogColor::Gray);

0 commit comments

Comments
 (0)