Skip to content

Commit a49d588

Browse files
authored
Merge pull request #623 from E3SM-Project/dqwu/cmake_regression_workaround
This PR applies a temporary but necessary workaround to address a CMake regression (3.22.0 or higher) that causes find_package(MPI) to fail or hang when detected in subprojects on Cray systems. This workaround ensures that find_package(MPI) is properly detected in subprojects until the regression is resolved by CMake developers. Fixes #517
2 parents 79a593f + 74dddaa commit a49d588

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ endif ()
347347
# ADDING SOURCE & TOOLS
348348
#==============================================================================
349349

350+
# Workaround for CMake 3.22.0+ regression on Cray systems (e.g., Frontier).
351+
# The regression breaks the existing FindMPI logic and causes MPI detection
352+
# to fail or hang inside subprojects.
353+
# This workaround adds an additional find_package(MPI) call at the root level
354+
# to restore MPI detection functionality in a subproject. The fix is temporary
355+
# but necessary until the issue is addressed in future CMake releases.
356+
if (DEFINED ENV{CRAYPE_VERSION})
357+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0")
358+
find_package(MPI REQUIRED)
359+
endif ()
360+
endif ()
361+
350362
# Libraries
351363
add_subdirectory (src)
352364

0 commit comments

Comments
 (0)