Skip to content

Commit 1568681

Browse files
committed
Leverage workaround supplied by https://github.com/mathomp4 for CMake/NAG/OpenMP bug https://gitlab.kitware.com/cmake/cmake/-/issues/21280.
1 parent 93a7b1a commit 1568681

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/addon/ESMX/Driver/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ foreach(ESMX_LINK_LIBRARY IN ITEMS ${ESMX_LINK_LIBRARIES})
160160
endif()
161161
endforeach()
162162

163+
# CMake has a bug with NAG and OpenMP:
164+
# https://gitlab.kitware.com/cmake/cmake/-/issues/21280
165+
# so we work around it ... credit to https://github.com/mathomp4
166+
if (OpenMP_Fortran_FOUND AND CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
167+
message(WARNING "NAG Fortran detected, resetting OpenMP flags to avoid CMake bug")
168+
set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY INTERFACE_LINK_LIBRARIES "")
169+
set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY INTERFACE_LINK_OPTIONS "-openmp")
170+
endif()
171+
163172
# link options
164173
if(DEFINED ESMX_LINK_OPTIONS)
165174
target_link_options(esmx_driver PUBLIC ${ESMX_LINK_OPTIONS})

0 commit comments

Comments
 (0)