Skip to content

Commit 1d81eff

Browse files
authored
Simplify build.ps1 system and clean up CMake configuration (#81)
* Fix Windows/MSVC build issues with Irrlicht includes and ctest executable paths. - Force MSVC to use /I instead of /external:I for system includes, fixing nested Irrlicht header resolution failures (e.g., rect.h, line3d.h) - Add explicit Irrlicht_ROOT and Irrlicht_INCLUDE_DIR cache variables - Fix CTest executable paths to use $<TARGET_FILE:...> generator expression instead of hardcoded paths that fail with VS multi-config builds - Inject HYDROCHRONO_DATA_DIR environment for regression tests - Add Irrlicht.dll copying to build output directory * remove obsolete files and simplify CMake configuration - Delete quick-build.ps1 (superseded by build.ps1) - Remove orphaned test files from tests/ root - Remove CDash dashboard targets (Nightly, Continuous, etc.) - Simplify project metadata to just use CMake project() * remove unused CMake options * Simplify build system - auto-detect deps from Chrono - Config reduced from 12 fields to 2 (ChronoDir + optional PythonRoot) - Auto-detect Irrlicht/VSG/HDF5 from Chrono's cmake config - Enable visualization by default if Chrono has it (use -NoIrrlicht to disable) - Remove redundant path handling - Eigen, HDF5, runtime library all inherited
1 parent d1464d5 commit 1d81eff

10 files changed

Lines changed: 283 additions & 1126 deletions

File tree

CMakeLists.txt

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,26 @@ project(HydroChrono
2525
LANGUAGES CXX
2626
)
2727

28+
# MSVC: CMake may pass "SYSTEM" include directories as external headers (/external:I).
29+
# Some third-party headers (e.g. Irrlicht) rely on nested quoted includes that can fail
30+
# intermittently when treated as external headers. Force SYSTEM include dirs to be emitted
31+
# as normal /I include paths instead.
32+
if(MSVC)
33+
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "/I")
34+
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/I")
35+
endif()
36+
2837
# ===============================================================================
29-
# -------- Parse Project Metadata ----------------------------------------------
38+
# -------- Project Metadata ----------------------------------------------------
3039
# ===============================================================================
3140

32-
# Read and parse project.meta file if present; otherwise provide sensible defaults
33-
if(EXISTS "${CMAKE_SOURCE_DIR}/project.meta")
34-
file(READ "${CMAKE_SOURCE_DIR}/project.meta" PROJECT_META_CONTENT)
35-
string(REPLACE "\n" ";" PROJECT_META_LINES "${PROJECT_META_CONTENT}")
36-
37-
# Parse each line and extract key-value pairs
38-
foreach(line ${PROJECT_META_LINES})
39-
if(line MATCHES "^([^=]+)=([^=]+)$")
40-
string(STRIP "${CMAKE_MATCH_1}" key)
41-
string(STRIP "${CMAKE_MATCH_2}" value)
42-
if(key STREQUAL "name")
43-
set(HYDROCHRONO_NAME "${value}")
44-
elseif(key STREQUAL "version")
45-
set(HYDROCHRONO_VERSION "${value}")
46-
elseif(key STREQUAL "description")
47-
set(HYDROCHRONO_DESCRIPTION "${value}")
48-
elseif(key STREQUAL "author")
49-
set(HYDROCHRONO_AUTHOR "${value}")
50-
elseif(key STREQUAL "maintainer")
51-
set(HYDROCHRONO_MAINTAINER "${value}")
52-
elseif(key STREQUAL "url")
53-
set(HYDROCHRONO_URL "${value}")
54-
elseif(key STREQUAL "license")
55-
set(HYDROCHRONO_LICENSE "${value}")
56-
elseif(key STREQUAL "status")
57-
set(HYDROCHRONO_STATUS "${value}")
58-
endif()
59-
endif()
60-
endforeach()
61-
else()
62-
# Defaults when meta file is not present
63-
set(HYDROCHRONO_NAME "${PROJECT_NAME}")
64-
set(HYDROCHRONO_VERSION "${PROJECT_VERSION}")
65-
set(HYDROCHRONO_DESCRIPTION "${PROJECT_DESCRIPTION}")
66-
set(HYDROCHRONO_AUTHOR "")
67-
set(HYDROCHRONO_MAINTAINER "")
68-
set(HYDROCHRONO_URL "")
69-
set(HYDROCHRONO_LICENSE "")
70-
set(HYDROCHRONO_STATUS "")
71-
endif()
41+
# Project metadata derived from project() command - single source of truth
42+
set(HYDROCHRONO_NAME "${PROJECT_NAME}")
43+
set(HYDROCHRONO_VERSION "${PROJECT_VERSION}")
44+
set(HYDROCHRONO_DESCRIPTION "${PROJECT_DESCRIPTION}")
7245

73-
# Display parsed metadata
7446
message(STATUS "Project: ${HYDROCHRONO_NAME} v${HYDROCHRONO_VERSION}")
7547
message(STATUS "Description: ${HYDROCHRONO_DESCRIPTION}")
76-
message(STATUS "Author: ${HYDROCHRONO_AUTHOR}")
77-
message(STATUS "Maintainer: ${HYDROCHRONO_MAINTAINER}")
78-
message(STATUS "License: ${HYDROCHRONO_LICENSE}")
79-
message(STATUS "Status: ${HYDROCHRONO_STATUS}")
8048

8149
# Generate version.h header from template
8250
configure_file(${CMAKE_SOURCE_DIR}/cmake/version.h.in
@@ -108,13 +76,14 @@ endif()
10876
# ===============================================================================
10977

11078
option(HYDROCHRONO_ENABLE_TESTS "Enable tests" ON)
111-
option(HYDROCHRONO_ENABLE_IRRLICHT "Enable irrlicht visualization library" OFF)
79+
option(HYDROCHRONO_ENABLE_IRRLICHT "Enable Irrlicht visualization library" OFF)
11280
option(HYDROCHRONO_ENABLE_VSG "Enable VSG visualization library" OFF)
11381
option(HYDROCHRONO_ENABLE_DEMOS "Enable demo executables" OFF)
11482
option(HYDROCHRONO_ENABLE_YAML_RUNNER "Enable YAML-based CLI runner" OFF)
115-
option(HYDROCHRONO_ENABLE_USER_DOC "User's documentation" OFF)
116-
option(HYDROCHRONO_ENABLE_PROG_DOC "Programmer's documentation" OFF)
117-
option(HYDROCHRONO_ENABLE_LOGGING "Enable debug logging" OFF)
83+
84+
# Irrlicht hints (used by Chrono's Irrlicht module and by HydroChronoGUI directly)
85+
set(Irrlicht_ROOT "" CACHE PATH "Irrlicht root directory (contains include/, lib/, bin/)")
86+
set(Irrlicht_INCLUDE_DIR "" CACHE PATH "Irrlicht include directory (contains irrlicht.h, IEventReceiver.h, etc.)")
11887

11988
# ===============================================================================
12089
# ------ Build setup ------------------------------------------------------------
@@ -430,8 +399,6 @@ target_compile_definitions(HydroChrono
430399
PUBLIC
431400
"HYDROCHRONO_VERSION=\"${PROJECT_VERSION}\""
432401
"HYDROCHRONO_BUILD_TYPE=\"$<IF:$<CONFIG:Debug>,Debug,$<IF:$<CONFIG:Release>,Release,$<IF:$<CONFIG:RelWithDebInfo>,RelWithDebInfo,$<IF:$<CONFIG:MinSizeRel>,MinSizeRel,Unknown>>>>\""
433-
PRIVATE
434-
$<$<BOOL:${HYDROCHRONO_ENABLE_LOGGING}>:"HYDROCHRONO_ENABLE_LOGGING=1">
435402
)
436403

437404
# ===============================================================================
@@ -467,6 +434,26 @@ target_include_directories(HydroChronoGUI
467434
"$<BUILD_INTERFACE:${HC_INCLUDES_BUILD}>"
468435
"$<INSTALL_INTERFACE:include>"
469436
)
437+
438+
# HydroChronoGUI includes Irrlicht headers directly (e.g., <IEventReceiver.h>).
439+
# Chrono may expose Irrlicht include dirs as SYSTEM/external includes on MSVC; add a normal /I include path too.
440+
if(HYDROCHRONO_ENABLE_IRRLICHT)
441+
# Derive include dir from Irrlicht_ROOT if caller didn't provide it explicitly.
442+
if((NOT Irrlicht_INCLUDE_DIR OR Irrlicht_INCLUDE_DIR STREQUAL "") AND (DEFINED Irrlicht_ROOT AND NOT Irrlicht_ROOT STREQUAL ""))
443+
set(Irrlicht_INCLUDE_DIR "${Irrlicht_ROOT}/include" CACHE PATH "Irrlicht include directory (auto-derived from Irrlicht_ROOT)" FORCE)
444+
endif()
445+
446+
if(NOT Irrlicht_INCLUDE_DIR OR Irrlicht_INCLUDE_DIR STREQUAL "" OR NOT EXISTS "${Irrlicht_INCLUDE_DIR}/irrlicht.h")
447+
message(FATAL_ERROR "HYDROCHRONO_ENABLE_IRRLICHT is ON but Irrlicht_INCLUDE_DIR is not a valid Irrlicht include directory. Provide -DIrrlicht_INCLUDE_DIR=<IrrlichtRoot>/include (or -DIrrlicht_ROOT=<IrrlichtRoot>).")
448+
endif()
449+
450+
target_include_directories(HydroChronoGUI PUBLIC "${Irrlicht_INCLUDE_DIR}")
451+
452+
if(MSVC)
453+
# Force a normal include search path even if Chrono exports Irrlicht as external headers.
454+
target_compile_options(HydroChronoGUI PRIVATE "/I${Irrlicht_INCLUDE_DIR}")
455+
endif()
456+
endif()
470457
set_target_properties(HydroChronoGUI PROPERTIES POSITION_INDEPENDENT_CODE ON)
471458
target_link_libraries(HydroChronoGUI
472459
PUBLIC
@@ -559,7 +546,6 @@ if(HYDROCHRONO_ENABLE_TESTS)
559546
set(HYDROCHRONO_DATA_DIR "${PROJECT_SOURCE_DIR}/demos")
560547
endif()
561548

562-
include(CTest)
563549
enable_testing()
564550

565551
# Configure test environment with DLL paths

build-config-example.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
{
22
"ChronoDir": "C:/path/to/chrono/build/cmake",
3-
"Hdf5Dir": "C:/path/to/hdf5/share/cmake",
4-
"EigenDir": "C:/path/to/eigen-3.4.0",
5-
"IrrlichtDir": "C:/path/to/irrlicht-1.8.4",
6-
"PythonRoot": "C:/Users/<you>/.conda/envs/<env>",
7-
"ScriptVersion": "2.1",
8-
"DefaultBuildType": "Release",
9-
"DefaultYamlRunner": "ON",
10-
"VisualStudioPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC",
11-
"RuntimeLibrary": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
12-
"CMakeModulePath": "C:/path/to/chrono/build/cmake"
13-
}
3+
"PythonRoot": "C:/Users/you/.conda/envs/chrono"
4+
}

0 commit comments

Comments
 (0)