From 4889d477b959674541b67bee9d4f981b57b7b61c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 27 Feb 2025 16:03:14 -0700 Subject: [PATCH] Rework the dependency linking of hydro compilation in CMake Some dependencies were not being fully satisfied and were implicit / partially fulfilled by subsequent compilation. In compilers that could tolerate these situations the hydro folder would compile successfully. However, for compilers where dependencies are enforced (i.e. symbols resloved at compile time even within Fortran submodules), compilation would fail. To account for these situations, dependencies between the hydro libraries and the transitive link properties were reworked to propagate dependencies up the chain correctly. --- hydro/CPL/WRF_cpl/CMakeLists.txt | 2 ++ hydro/Data_Rec/CMakeLists.txt | 1 + hydro/Debug_Utilities/CMakeLists.txt | 1 + hydro/HYDRO_drv/CMakeLists.txt | 3 +-- hydro/IO/CMakeLists.txt | 1 + hydro/MPP/CMakeLists.txt | 2 +- hydro/Routing/CMakeLists.txt | 1 + hydro/utils/CMakeLists.txt | 1 + 8 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hydro/CPL/WRF_cpl/CMakeLists.txt b/hydro/CPL/WRF_cpl/CMakeLists.txt index 914191ba5b..c98d242ddc 100644 --- a/hydro/CPL/WRF_cpl/CMakeLists.txt +++ b/hydro/CPL/WRF_cpl/CMakeLists.txt @@ -14,6 +14,8 @@ add_dependencies(hydro_wrf_cpl MPI::MPI_Fortran ) +target_link_libraries( hydro_wrf_cpl PRIVATE hydro_driver ) + target_include_directories(hydro_wrf_cpl PRIVATE $ diff --git a/hydro/Data_Rec/CMakeLists.txt b/hydro/Data_Rec/CMakeLists.txt index 7590bd19f2..91cb335b94 100644 --- a/hydro/Data_Rec/CMakeLists.txt +++ b/hydro/Data_Rec/CMakeLists.txt @@ -5,3 +5,4 @@ add_library(hydro_data_rec STATIC module_RT_data.F90 module_namelist.F90 ) +target_link_libraries( hydro_data_rec PRIVATE hydro_mpp ) diff --git a/hydro/Debug_Utilities/CMakeLists.txt b/hydro/Debug_Utilities/CMakeLists.txt index da145d69c1..2f6806af32 100644 --- a/hydro/Debug_Utilities/CMakeLists.txt +++ b/hydro/Debug_Utilities/CMakeLists.txt @@ -2,3 +2,4 @@ add_library(hydro_debug_utils STATIC debug_dump_variable.F90 ) +target_link_libraries( hydro_debug_utils PRIVATE hydro_mpp ) diff --git a/hydro/HYDRO_drv/CMakeLists.txt b/hydro/HYDRO_drv/CMakeLists.txt index e0b1a6f442..fae58f0408 100644 --- a/hydro/HYDRO_drv/CMakeLists.txt +++ b/hydro/HYDRO_drv/CMakeLists.txt @@ -8,8 +8,7 @@ target_link_libraries(hydro_driver PUBLIC hydro_data_rec hydro_routing hydro_debug_utils - PRIVATE - netCDF::netcdff + netCDF::netcdff ) if(WRF_HYDRO_NUDGING STREQUAL "1") diff --git a/hydro/IO/CMakeLists.txt b/hydro/IO/CMakeLists.txt index 3566adc795..fafb14878d 100644 --- a/hydro/IO/CMakeLists.txt +++ b/hydro/IO/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(hydro_netcdf_layer STATIC ) target_link_libraries(hydro_netcdf_layer + PUBLIC MPI::MPI_Fortran netCDF::netcdff ) diff --git a/hydro/MPP/CMakeLists.txt b/hydro/MPP/CMakeLists.txt index 1eb929cc95..d9756c445e 100644 --- a/hydro/MPP/CMakeLists.txt +++ b/hydro/MPP/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(hydro_mpp STATIC hashtable.F90 ) -target_link_libraries(hydro_mpp MPI::MPI_Fortran) +target_link_libraries(hydro_mpp PUBLIC MPI::MPI_Fortran) target_include_directories(hydro_mpp PUBLIC ${MPI_Fortran_MODULE_DIR} ) diff --git a/hydro/Routing/CMakeLists.txt b/hydro/Routing/CMakeLists.txt index 307b695ec6..8c40440b07 100644 --- a/hydro/Routing/CMakeLists.txt +++ b/hydro/Routing/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(hydro_routing STATIC ) target_link_libraries(hydro_routing + PRIVATE MPI::MPI_Fortran netCDF::netcdff hydro_mpp diff --git a/hydro/utils/CMakeLists.txt b/hydro/utils/CMakeLists.txt index 923017f10d..b6d2e57540 100644 --- a/hydro/utils/CMakeLists.txt +++ b/hydro/utils/CMakeLists.txt @@ -18,3 +18,4 @@ add_library(hydro_utils STATIC module_version.F90 module_hydro_stop.F90 ) +target_link_libraries(hydro_utils PRIVATE MPI::MPI_Fortran)