Skip to content

Commit e86a997

Browse files
committed
CMake configuration tweaks.
- Revert explicit configuration of Irrlicht (instead, use variables provided the Chrono project configuration script). - Install VSG DLLs (Windows).
1 parent f1e4cc1 commit e86a997

1 file changed

Lines changed: 23 additions & 65 deletions

File tree

CMakeLists.txt

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ project(HydroChrono
2626
)
2727

2828
# 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.
29+
# Some third-party headers rely on nested quoted includes that can fail intermittently when treated as external headers.
30+
# Force SYSTEM include dirs to be emitted as normal /I include paths instead.
3231
if(MSVC)
3332
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "/I")
3433
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/I")
@@ -81,10 +80,6 @@ option(HYDROCHRONO_ENABLE_VSG "Enable VSG visualization library" OFF)
8180
option(HYDROCHRONO_ENABLE_DEMOS "Enable demo executables" OFF)
8281
option(HYDROCHRONO_ENABLE_YAML_RUNNER "Enable YAML-based CLI runner" OFF)
8382

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.)")
87-
8883
# ===============================================================================
8984
# ------ Build setup ------------------------------------------------------------
9085
# ===============================================================================
@@ -105,7 +100,7 @@ if(MSVC)
105100
-D_SCL_SECURE_NO_DEPRECATE # Disable SCL deprecation warnings
106101
-DNOMINMAX # Prevent Windows.h from defining min/max macros
107102
)
108-
add_compile_options(/wd4275) # Disable warnings triggered by Irrlicht
103+
add_compile_options(/wd4275) # Disable non-DLL class used as base for DLL-interface class
109104
add_compile_options(/wd4251) # Disable "class needs to have dll-interface" warnings
110105
endif()
111106

@@ -436,26 +431,6 @@ target_include_directories(HydroChronoGUI
436431
"$<INSTALL_INTERFACE:include>"
437432
)
438433

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-
459434
set_target_properties(HydroChronoGUI PROPERTIES POSITION_INDEPENDENT_CODE ON)
460435
target_link_libraries(HydroChronoGUI
461436
PUBLIC
@@ -465,14 +440,6 @@ target_link_libraries(HydroChronoGUI
465440
$<$<BOOL:${HYDROCHRONO_ENABLE_VSG}>:Chrono::Chrono_vsg>
466441
)
467442

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-
476443
# ===============================================================================
477444
# ------- Auxiliary Targets (app, tests, demos) ---------------------------------
478445
# ===============================================================================
@@ -646,68 +613,59 @@ endif()
646613

647614
# On Windows, install DLLs
648615
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
616+
message(STATUS "Set DLLs for installation")
649617

650618
# Chrono DLLs
651619
foreach(tgt ${CHRONO_TARGETS})
652620
get_target_property(tgt_DLL ${tgt} IMPORTED_LOCATION_RELEASE)
653621
get_target_property(tgt_DLL_d ${tgt} IMPORTED_LOCATION_DEBUG)
654622
if(EXISTS ${tgt_DLL})
623+
message(STATUS " Chrono DLL ${tgt_DLL}")
655624
install(FILES ${tgt_DLL} DESTINATION bin COMPONENT runtime)
656625
endif()
657626
if(EXISTS ${tgt_DLL_d})
658627
install(FILES ${tgt_DLL_d} DESTINATION bin COMPONENT runtime)
659628
endif()
660629
endforeach()
661630

662-
# HDF5 DLLs - use glob to find all DLLs in HDF5 bin directory
663-
if(DEFINED HDF5_ROOT OR DEFINED HDF5_DIR)
664-
# Determine HDF5 root from various possible variables
665-
if(DEFINED HDF5_ROOT)
666-
set(_hdf5_root "${HDF5_ROOT}")
667-
elseif(DEFINED HDF5_DIR)
668-
# HDF5_DIR might point to share/cmake/hdf5 or similar
669-
get_filename_component(_hdf5_root "${HDF5_DIR}" DIRECTORY)
670-
get_filename_component(_hdf5_root "${_hdf5_root}" DIRECTORY)
671-
get_filename_component(_hdf5_root "${_hdf5_root}" DIRECTORY)
672-
endif()
673-
674-
set(_hdf5_bin "${_hdf5_root}/bin")
675-
if(EXISTS "${_hdf5_bin}")
676-
file(GLOB _hdf5_dlls "${_hdf5_bin}/*.dll")
677-
if(_hdf5_dlls)
678-
message(STATUS "Installing HDF5 DLLs from: ${_hdf5_bin}")
679-
install(FILES ${_hdf5_dlls} DESTINATION bin COMPONENT runtime)
680-
endif()
681-
endif()
682-
endif()
683-
684-
# Also try target-based approach as fallback
631+
# HDF5 DLLs
685632
foreach(tgt ${HDF5_TARGETS})
686633
get_target_property(tgt_DLL ${tgt} IMPORTED_LOCATION_RELEASE)
687634
if(EXISTS ${tgt_DLL})
635+
message(STATUS " HDF5 DLL ${tgt_DLL}")
688636
install(FILES ${tgt_DLL} DESTINATION bin COMPONENT runtime)
689637
endif()
690638
endforeach()
691639

692640
# Irrlicht DLL
693-
if(HYDROCHRONO_ENABLE_IRRLICHT AND DEFINED Irrlicht_ROOT)
694-
set(_irr_dll "${Irrlicht_ROOT}/bin/Win64-VisualStudio/Irrlicht.dll")
641+
if(HYDROCHRONO_ENABLE_IRRLICHT AND EXISTS ${Irrlicht_DLL_DIR})
642+
set(_irr_dll "${Irrlicht_DLL_DIR}/Irrlicht.dll")
695643
if(EXISTS "${_irr_dll}")
696-
message(STATUS "Installing Irrlicht.dll from: ${_irr_dll}")
644+
message(STATUS " Irrlicht DLL ${_irr_dll}")
697645
install(FILES "${_irr_dll}" DESTINATION bin COMPONENT runtime)
698646
endif()
699647
endif()
648+
649+
# VSG DLLs
650+
if(HYDROCHRONO_ENABLE_VSG AND EXISTS "${VSG_DLL_DIR}")
651+
file(GLOB _vsg_dlls "${VSG_DLL_DIR}/*.dll")
652+
if(_vsg_dlls)
653+
message(STATUS " VSG DLLs ${_vsg_dlls}")
654+
install(FILES ${_vsg_dlls} DESTINATION bin COMPONENT runtime)
655+
endif()
656+
endif()
700657

701658
# Python DLLs, if Chrono::Parsers depends on it
702659
if(CHRONO_PARSERS_PYTHON)
703660
find_package(Python3 QUIET COMPONENTS Interpreter Development)
704661
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}")
662+
#message(STATUS "Found Python and dependencies")
663+
#message(STATUS " Python3_Interpreter_FOUND: ${Python3_Interpreter_FOUND}")
664+
#message(STATUS " Python3_Development_FOUND: ${Python3_Development_FOUND}")
708665
get_target_property(tgt_DLL Python3::Python IMPORTED_LOCATION_RELEASE)
709666
get_target_property(tgt_DLL_d Python3::Python IMPORTED_LOCATION_DEBUG)
710667
if(EXISTS ${tgt_DLL})
668+
message(STATUS " Python DLL ${tgt_DLL}")
711669
install(FILES ${tgt_DLL} DESTINATION bin COMPONENT runtime)
712670
endif()
713671
if(EXISTS ${tgt_DLL_d})

0 commit comments

Comments
 (0)