Skip to content

Commit 02a1be4

Browse files
committed
Revert "v11: Updates needed for Ninja support"
This reverts commit 9b71e56.
1 parent 9b71e56 commit 02a1be4

File tree

1 file changed

+31
-56
lines changed

1 file changed

+31
-56
lines changed

CMakeLists.txt

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,42 @@ if (BUILD_GEOS_GTFV3_INTERFACE)
111111
SRCS ${srcs}
112112
SUBCOMPONENTS fvdycore
113113
DEPENDENCIES ${dependencies}
114+
DEPENDENCIES ${GFDL}
114115
DEPENDENCIES geos_gtfv3_interface_py) # Make the main library depend on the Python library
115116
else ()
116117
esma_add_library (${this}
117118
SRCS ${srcs}
118119
SUBCOMPONENTS fvdycore
119-
DEPENDENCIES ${dependencies})
120+
DEPENDENCIES ${dependencies}
121+
DEPENDENCIES ${GFDL})
120122
endif ()
121123

122124
if (FV_PRECISION STREQUAL R4)
123-
target_link_libraries (${this} PUBLIC fms_r4)
124-
target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4)
125+
set (GFDL fms_r4)
125126
elseif (FV_PRECISION STREQUAL R4R8) # FV is R4 but FMS is R8
126-
# fvdycore needs r4 .mod interfaces
127-
get_target_property(inc_r4 fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
128-
target_include_directories(${this} PRIVATE $<BUILD_INTERFACE:${inc_r4}>)
129-
130-
# But fvdycore should not *compile* with fms_r8 includes
131-
target_link_libraries(${this} PUBLIC $<LINK_ONLY:fms_r8>)
132-
133-
target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4)
134-
135-
# This tells CMake that we need these targets built before we can build
136-
add_dependencies(${this} fms_r4 fms_r8)
127+
# We need to add_dependencies for fms_r4 because CMake doesn't know we
128+
# need it for include purposes. In R4R8, we only ever link against
129+
# fms_r4, so it doesn't know we need to build it.
130+
# NOTE NOTE NOTE: This should *not* be included in GEOSgcm v12
131+
# because FMS is pre-built library in that case.
132+
add_dependencies (${this} fms_r4)
133+
get_target_property (extra_incs fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
134+
target_include_directories(${this} PRIVATE
135+
$<BUILD_INTERFACE:${extra_incs}>
136+
)
137+
set (GFDL fms_r8)
137138
elseif (FV_PRECISION STREQUAL R8)
138-
target_link_libraries (${this} PUBLIC fms_r8)
139-
string(REPLACE " " ";" tmp ${FREAL8})
140-
foreach(flag ${tmp})
141-
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${flag}>)
142-
endforeach()
139+
set (GFDL fms_r8)
140+
string(REPLACE " " ";" tmp ${FREAL8})
141+
foreach(flag ${tmp})
142+
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${flag}>)
143+
endforeach()
144+
endif ()
145+
146+
if (FV_PRECISION MATCHES R4)
147+
target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4)
148+
elseif (FV_PRECISION MATCHES R4R8) # FV is R4 but FMS is R8
149+
target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4)
143150
endif ()
144151

145152
message(STATUS "Building FV as ${FV_PRECISION}")
@@ -150,7 +157,11 @@ if (CRAY_POINTER)
150157
set_target_properties (${this} PROPERTIES COMPILE_FLAGS ${CRAY_POINTER})
151158
endif()
152159

153-
target_compile_definitions (${this} PRIVATE MAPL_MODE FVREGRID_MAPL_MODE)
160+
add_definitions (-DSPMD -DMAPL_MODE -DFVREGRID_MAPL_MODE)
161+
162+
foreach(flag ${tmp})
163+
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${flag}>)
164+
endforeach()
154165

155166
ecbuild_add_executable (
156167
TARGET StandAlone_FV3_Dycore.x
@@ -187,32 +198,6 @@ ecbuild_add_executable (
187198
SOURCES interp_restarts_bin.F90
188199
LIBS ${this} OpenMP::OpenMP_Fortran)
189200

190-
# If we are doing R4R8 we also need add_dependencies for both fms_r4 and fms_r8
191-
# for all our executables that link to ${this} because of the way we set up the
192-
# main library above.
193-
if (FV_PRECISION STREQUAL R4R8)
194-
foreach(executable
195-
StandAlone_FV3_Dycore.x
196-
rs_scale.x
197-
StandAlone_AdvCore.x
198-
StandAlone_DynAdvCore.x
199-
c2c.x
200-
interp_restarts.x
201-
interp_restarts_bin.x)
202-
203-
# fvdycore needs r4 .mod interfaces
204-
get_target_property(inc_r4 fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
205-
target_include_directories(${executable} PRIVATE $<BUILD_INTERFACE:${inc_r4}>)
206-
207-
# But fvdycore should not *compile* with fms_r8 includes
208-
target_link_libraries(${executable} $<LINK_ONLY:fms_r8>)
209-
210-
# This tells CMake that we need these targets built before we can build
211-
add_dependencies(${executable} fms_r4 fms_r8)
212-
endforeach()
213-
endif ()
214-
215-
216201
if (BUILD_GEOS_GTFV3_INTERFACE)
217202
ecbuild_add_executable (
218203
TARGET fv3_driver.x
@@ -224,16 +209,6 @@ if (BUILD_GEOS_GTFV3_INTERFACE)
224209
geos-gtfv3/driver/input/input_arrays.f90
225210
geos-gtfv3/driver/fv3_driver.F90
226211
LIBS ${this})
227-
if (FV_PRECISION STREQUAL R4R8)
228-
# fvdycore needs r4 .mod interfaces
229-
get_target_property(inc_r4 fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
230-
target_include_directories(fv3_driver.x PRIVATE $<BUILD_INTERFACE:${inc_r4}>)
231-
232-
# But fvdycore should not *compile* with fms_r8 includes
233-
target_link_libraries(fv3_driver.x PUBLIC $<LINK_ONLY:fms_r8>)
234-
235-
add_dependencies(fv3_driver.x fms_r4 fms_r8)
236-
endif ()
237212
endif ()
238213

239214
add_subdirectory(scripts)

0 commit comments

Comments
 (0)