Skip to content

Commit 4645ffd

Browse files
committed
Add Chrono::Core manually when there is an error about modern cmake
1 parent 9a8085e commit 4645ffd

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -209,8 +225,6 @@ if (NOT HC_CHRONO_INCLUDE_DIRS AND DEFINED Chrono_DIR)
209225
endif()
210226

211227

212-
213-
214228
#-----------------------------------------------------------------------------
215229
# Fix for VS 2017 15.8 and newer to handle alignment specification with Eigen
216230
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)