Skip to content

Commit 98e9972

Browse files
committed
First successful built of partial drivers
1 parent f6eaf38 commit 98e9972

1 file changed

Lines changed: 109 additions & 5 deletions

File tree

src/drivers/CMakeLists.txt

Lines changed: 109 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,112 @@
22
# SPDX-License-Identifier: CC0-1.0
33
# SPDX-FileContributor: Carsten Lemmen <carsten.lemmen@hereon.de>
44

5-
# Placeholder for src/drivers CMake definitions
6-
# This directory will contain the source code for different drivers.
7-
# Example:
8-
# add_library(MyDriver MyDriver.cpp)
9-
# target_include_directories(MyDriver PUBLIC ../include)
5+
add_library(mossco_drivers STATIC)
6+
7+
set(DRIVER_SOURCES
8+
#driver.F
9+
empty_driver.F90
10+
particle_driver.F90
11+
simplewave_driver.F90
12+
#tracer_driver.F90
13+
#vertical_macrobenthos_driver.F90
14+
)
15+
16+
option(USE_HAMSOM "Enable HAMSOM-based drivers" OFF)
17+
if(USE_HAMSOM)
18+
list(APPEND DRIVER_SOURCES
19+
hamsom_driver.F90
20+
)
21+
endif()
22+
23+
option(USE_CMAQ "Enable CMAQ-based drivers" OFF)
24+
if(USE_CMAQ)
25+
list(APPEND DRIVER_SOURCES
26+
cmaq_driver.F90
27+
)
28+
endif()
29+
30+
option(USE_GETM "Enable GETM-based drivers" OFF)
31+
if(USE_GETM)
32+
list(APPEND DRIVER_SOURCES
33+
getm_driver.F90
34+
)
35+
endif()
36+
37+
option(USE_FABM "Enable FABM-based drivers" OFF)
38+
if(USE_FABM)
39+
list(APPEND DRIVER_SOURCES
40+
fabm0d_driver.F90
41+
fabm_benthic_driver.F90
42+
fabm_gotm_driver.F90
43+
fabm_pelagic_driver.F90
44+
fabm_sediment_driver.F90
45+
)
46+
endif()
47+
48+
# Option to enable or disable EROSED-related sources
49+
option(USE_EROSED "Enable EROSED-related drivers (biotypes, benthoseffect_class)" OFF)
50+
if(USE_EROSED)
51+
list(APPEND DRIVER_SOURCES
52+
biotypes.F90
53+
benthoseffect_class.F90
54+
erosed.F90
55+
macrofauna_class.F90
56+
macrofauna_interface.F90
57+
mbalthica_class.F90
58+
microphytobenthos_class.F90
59+
benthoseffect_class.F90
60+
criticalsheareffect.F90
61+
erodibilityeffect.F90
62+
)
63+
endif()
64+
65+
# Find and link NetCDF
66+
find_package(NetCDF REQUIRED COMPONENTS Fortran C)
67+
68+
if(NetCDF_FOUND)
69+
message(STATUS "NetCDF found. Linking with NetCDF::NetCDF_Fortran and NetCDF::NetCDF_C.")
70+
#target_link_libraries(mossco_utilities PRIVATE NetCDF::NetCDF_Fortran NetCDF::NetCDF_C)
71+
# Modern NetCDF targets should propagate their include directories.
72+
# If not, explicitly add:
73+
target_include_directories(mossco_drivers PRIVATE ${NetCDF_INCLUDE_DIRS})
74+
else()
75+
message(FATAL_ERROR "NetCDF (Fortran and C) was REQUIRED but not found. Check NetCDF installation and CMAKE_PREFIX_PATH.")
76+
endif()
77+
78+
79+
# Option to enable or disable clm_driver.F90
80+
option(USE_CLM "Enable CLM file-based coupling" OFF)
81+
if(USE_CLM )
82+
list(APPEND DRIVER_SOURCES
83+
clm_driver.F90
84+
river_driver.F90
85+
)
86+
endif()
87+
88+
target_sources(mossco_drivers PRIVATE ${DRIVER_SOURCES})
89+
90+
# Link against mossco_utilities to get access to ESMF, versioning, NetCDF (via ESMF), etc.
91+
# Using PUBLIC will propagate the usage requirements of mossco_utilities (like its INTERFACE include directories
92+
# and link libraries) to targets that link against mossco_drivers.
93+
target_link_libraries(mossco_drivers PUBLIC mossco_utilities)
94+
95+
# Ensure that consumers of mossco_drivers can find Fortran modules (.mod files)
96+
# generated by mossco_drivers. These modules are placed in CMAKE_Fortran_MODULE_DIRECTORY.
97+
# Linking mossco_utilities PUBLIC should already make CMAKE_Fortran_MODULE_DIRECTORY
98+
# an interface include directory if mossco_utilities exports it.
99+
# However, explicitly stating it for mossco_drivers ensures clarity and correctness
100+
# if mossco_drivers itself produces modules that are distinct from those in mossco_utilities,
101+
# or if mossco_utilities's propagation isn't fully comprehensive for this specific need.
102+
target_include_directories(mossco_drivers
103+
PUBLIC # Changed from INTERFACE in prompt to PUBLIC for BUILD_INTERFACE and INSTALL_INTERFACE consistency
104+
# For consumers finding .mod files from this target
105+
"$<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>"
106+
"$<INSTALL_INTERFACE:include>" # Assuming .mod files might be installed to 'include/modules' or similar
107+
# This part needs alignment with actual install rules for modules.
108+
# For now, generic 'include' is a placeholder.
109+
PRIVATE
110+
# For mossco_drivers' own source files to find modules they produce (if any interdependencies)
111+
${CMAKE_Fortran_MODULE_DIRECTORY}
112+
)
113+

0 commit comments

Comments
 (0)