@@ -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
7446message (STATUS "Project: ${HYDROCHRONO_NAME} v${HYDROCHRONO_VERSION} " )
7547message (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
8250configure_file (${CMAKE_SOURCE_DIR} /cmake/version.h.in
@@ -108,13 +76,14 @@ endif()
10876# ===============================================================================
10977
11078option (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 )
11280option (HYDROCHRONO_ENABLE_VSG "Enable VSG visualization library" OFF )
11381option (HYDROCHRONO_ENABLE_DEMOS "Enable demo executables" OFF )
11482option (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 ------------------------------------------------------------
@@ -466,6 +435,27 @@ target_include_directories(HydroChronoGUI
466435 "$<BUILD_INTERFACE :${HC_INCLUDES_BUILD} >"
467436 "$<INSTALL_INTERFACE :include >"
468437)
438+
439+ # HydroChronoGUI includes Irrlicht headers directly (e.g., <IEventReceiver.h>).
440+ # Chrono may expose Irrlicht include dirs as SYSTEM/external includes on MSVC; add a normal /I include path too.
441+ if (HYDROCHRONO_ENABLE_IRRLICHT)
442+ # Derive include dir from Irrlicht_ROOT if caller didn't provide it explicitly.
443+ if ((NOT Irrlicht_INCLUDE_DIR OR Irrlicht_INCLUDE_DIR STREQUAL "" ) AND (DEFINED Irrlicht_ROOT AND NOT Irrlicht_ROOT STREQUAL "" ))
444+ set (Irrlicht_INCLUDE_DIR "${Irrlicht_ROOT} /include" CACHE PATH "Irrlicht include directory (auto-derived from Irrlicht_ROOT)" FORCE )
445+ endif ()
446+
447+ if (NOT Irrlicht_INCLUDE_DIR OR Irrlicht_INCLUDE_DIR STREQUAL "" OR NOT EXISTS "${Irrlicht_INCLUDE_DIR} /irrlicht.h" )
448+ 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>)." )
449+ endif ()
450+
451+ target_include_directories (HydroChronoGUI PUBLIC "${Irrlicht_INCLUDE_DIR} " )
452+
453+ if (MSVC )
454+ # Force a normal include search path even if Chrono exports Irrlicht as external headers.
455+ target_compile_options (HydroChronoGUI PRIVATE "/I${Irrlicht_INCLUDE_DIR} " )
456+ endif ()
457+ endif ()
458+
469459set_target_properties (HydroChronoGUI PROPERTIES POSITION_INDEPENDENT_CODE ON )
470460target_link_libraries (HydroChronoGUI
471461 PUBLIC
@@ -475,6 +465,14 @@ target_link_libraries(HydroChronoGUI
475465 $<$<BOOL :${HYDROCHRONO_ENABLE_VSG} >:Chrono ::Chrono_vsg >
476466)
477467
468+ # Suppress warnings from third-party Irrlicht headers on MSVC.
469+ # The Irrlicht headers trigger C4458 warnings (x/y hiding member) that we cannot fix.
470+ # Use /external:I to treat Irrlicht includes as external headers with reduced warning level.
471+ if (MSVC AND HYDROCHRONO_ENABLE_IRRLICHT AND DEFINED Irrlicht_ROOT)
472+ target_include_directories (HydroChronoGUI SYSTEM PUBLIC "${Irrlicht_ROOT} /include" )
473+ target_compile_options (HydroChronoGUI PRIVATE /external:anglebrackets /external:W0 )
474+ endif ()
475+
478476# ===============================================================================
479477# ------- Auxiliary Targets (app, tests, demos) ---------------------------------
480478# ===============================================================================
@@ -558,7 +556,6 @@ if(HYDROCHRONO_ENABLE_TESTS)
558556 set (HYDROCHRONO_DATA_DIR "${PROJECT_SOURCE_DIR} /demos" )
559557 endif ()
560558
561- include (CTest )
562559 enable_testing ()
563560
564561 # Configure test environment with DLL paths
@@ -705,6 +702,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
705702 if (CHRONO_PARSERS_PYTHON)
706703 find_package (Python3 QUIET COMPONENTS Interpreter Development )
707704 if (Python3_Interpreter_FOUND AND Python3_Development_FOUND)
705+ message (STATUS "Found Python and dependencies" )
706+ message (STATUS " Python3_Interpreter_FOUND: ${Python3_Interpreter_FOUND} " )
707+ message (STATUS " Python3_Development_FOUND: ${Python3_Development_FOUND} " )
708708 get_target_property (tgt_DLL Python3::Python IMPORTED_LOCATION_RELEASE )
709709 get_target_property (tgt_DLL_d Python3::Python IMPORTED_LOCATION_DEBUG )
710710 if (EXISTS ${tgt_DLL} )
0 commit comments