From 146da1d4094ef541ff7eb249910735de233cf5ca Mon Sep 17 00:00:00 2001 From: Nick Dingle Date: Wed, 23 Jul 2025 11:05:22 +0100 Subject: [PATCH] Capture module file dependencies in CMake The modulefile la_xisnan.F90 depends on the modulefile la_constants.f90 but this dependency is not expressed in the CMake rules. In some parallel builds we have observed failures where compilation of objects that depend on la_constants.mod starts before compilation of la_constants.f90 has finished. This patch modifies CMakeLists.txt to ensure that la_constants.mod is built before any other object or modulefile that depends on it. --- SRC/CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/SRC/CMakeLists.txt b/SRC/CMakeLists.txt index be426cecd..676397e76 100644 --- a/SRC/CMakeLists.txt +++ b/SRC/CMakeLists.txt @@ -36,7 +36,9 @@ # ####################################################################### -set(ALLMOD la_xisnan.F90 la_constants.f90) +set(CONSTMOD la_constants.f90) + +set(NANMOD la_xisnan.F90) set(ALLAUX ilaenv.f ilaenv2stage.f ieeeck.f lsamen.f iparmq.f iparam2stage.F ilaprec.f ilatrans.f ilauplo.f iladiag.f chla_transtype.f @@ -519,7 +521,14 @@ list(REMOVE_DUPLICATES SOURCES) # Use special target for MOD files to guarantee they are built before # any other files that depend on them -add_library(mod_files OBJECT ${ALLMOD}) +add_library(const_mod_file OBJECT ${CONSTMOD}) +set_target_properties( + const_mod_file PROPERTIES + POSITION_INDEPENDENT_CODE ON + Fortran_PREPROCESS ON + ) + +add_library(mod_files OBJECT ${NANMOD} $) set_target_properties( mod_files PROPERTIES POSITION_INDEPENDENT_CODE ON