Skip to content

Commit 5b79d01

Browse files
authored
Merge pull request #5434 from ywwry66/mixed_openmp_warning
CMake: Demote the OpenMP mixed linkage check to NOTICE
2 parents 48e33f2 + ed6c223 commit 5b79d01

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cmake/system.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,16 @@ if (USE_OPENMP)
447447
if (NOT NOFORTRAN)
448448
find_package(OpenMP COMPONENTS Fortran REQUIRED)
449449
# Avoid mixed OpenMP linkage
450-
get_target_property(OMP_C_LIB OpenMP::OpenMP_C INTERFACE_LINK_LIBRARIES)
451-
get_target_property(OMP_Fortran_LIB OpenMP::OpenMP_Fortran INTERFACE_LINK_LIBRARIES)
452-
if (NOT OMP_C_LIB STREQUAL OMP_Fortran_LIB)
453-
message(FATAL_ERROR "Multiple OpenMP runtime libraries detected. Mixed OpenMP runtime linkage is dangerous. You may pass -DOpenMP_LANG_LIB_NAMES and -DOpenMP_omp_LIBRARY to manually choose the OpenMP library.")
450+
get_target_property(OMP_C_LIBS OpenMP::OpenMP_C INTERFACE_LINK_LIBRARIES)
451+
get_target_property(OMP_F_LIBS OpenMP::OpenMP_Fortran INTERFACE_LINK_LIBRARIES)
452+
if (NOT OMP_C_LIBS STREQUAL OMP_F_LIBS)
453+
message(NOTICE
454+
"CMake detected different OpenMP libraries for C and Fortran:\n"
455+
"C=${OMP_C_LIBS}\n"
456+
"Fortran=${OMP_F_LIBS}\n"
457+
"In case you encounter issues, please check that this is correct.\n"
458+
"You may pass -DOpenMP_<lang>_LIB_NAMES and -DOpenMP_<libname>_LIBRARY to cmake to manually force the OpenMP library."
459+
)
454460
endif()
455461
endif ()
456462
endif ()

0 commit comments

Comments
 (0)