diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b9588d..bfec365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,23 @@ target_compile_definitions(shum PUBLIC ${SHUM_DEFINES}) +# BUILD_OPENMP goes as far as find_package(OpenMP) in ShumOptions.cmake, but +# the imported targets have to be linked for the option to have any effect. +# Without this, no -fopenmp reaches a compile line, _OPENMP is never defined +# and the OpenMP regions are preprocessed away, so a CMake build produces a +# serial library where the Makefile build (SHUM_OPENMP ?= true) produces a +# threaded one. +# +# PRIVATE is sufficient: _OPENMP is used inside c_shum_byteswap.c, never in an +# installed header, so consumers of shumlib do not need OpenMP flags of their +# own. +if(BUILD_OPENMP) + target_link_libraries(shum + PRIVATE + OpenMP::OpenMP_C + OpenMP::OpenMP_Fortran) +endif() + # Install shumlib and the C header files for the sub-libraries that # have them install(TARGETS shum @@ -95,6 +112,16 @@ if(BUILD_TESTS) PUBLIC ${CMAKE_Fortran_MODULE_DIRECTORY}) target_link_libraries(shumlib-tests PUBLIC fruit shum) + # The thread_utils tests exercise the OpenMP paths directly, and shumlib's + # OpenMP linkage is PRIVATE, so the test executable needs the flags in its + # own right. + if(BUILD_OPENMP) + target_link_libraries(shumlib-tests + PRIVATE + OpenMP::OpenMP_C + OpenMP::OpenMP_Fortran) + endif() + add_subdirectory(fruit) setup_shum_fruit() diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e4f90b3..4d1f42f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,8 +1,9 @@ # Contributors -| GitHub user | Real Name | Affiliation | Date | -| --------------- | ---------------- | ----------- | ---------- | -| james-bruten-mo | James Bruten | Met Office | 2025-12-09 | -| t00sa | Sam Clarke-Green | Met Office | 2026-02-10 | -| jennyhickson | Jenny Hickson | Met Office | 2026-03-02 | -| yaswant | Yaswant Pradhan | Met Office | 2026-07-17 | +| GitHub user | Real Name | Affiliation | Date | +| --------------- | ---------------- | ----------- | ---------- | +| james-bruten-mo | James Bruten | Met Office | 2025-12-09 | +| t00sa | Sam Clarke-Green | Met Office | 2026-02-10 | +| jennyhickson | Jenny Hickson | Met Office | 2026-03-02 | +| yaswant | Yaswant Pradhan | Met Office | 2026-07-17 | +| ickc | Kolen Cheung | University of Exeter | 2026-09-16 |