From 74dddaafefba9169dc3c1faa4604729c4b5535c0 Mon Sep 17 00:00:00 2001 From: dqwu Date: Tue, 26 Nov 2024 11:38:07 -0600 Subject: [PATCH] Applying a workaround for CMake FindMPI regression on Cray systems Utilized a temporary but necessary workaround to address a confirmed CMake regression (3.22.0 or higher) that causes find_package(MPI) to fail or hang when detected in subprojects on Cray systems. Until this regression is resolved by CMake developers, an additional find_package(MPI) call is added at the root level when running CMake on Cray systems with versions 3.22.0 or higher. --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60e23cbde..85548fc07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,6 +347,18 @@ endif () # ADDING SOURCE & TOOLS #============================================================================== +# Workaround for CMake 3.22.0+ regression on Cray systems (e.g., Frontier). +# The regression breaks the existing FindMPI logic and causes MPI detection +# to fail or hang inside subprojects. +# This workaround adds an additional find_package(MPI) call at the root level +# to restore MPI detection functionality in a subproject. The fix is temporary +# but necessary until the issue is addressed in future CMake releases. +if (DEFINED ENV{CRAYPE_VERSION}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0") + find_package(MPI REQUIRED) + endif () +endif () + # Libraries add_subdirectory (src)