Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,16 @@ target_include_directories(fv3dycore PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/atmos_c
target_include_directories(fv3dycore INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)

target_link_libraries(fv3dycore PUBLIC fms
gfsphysics
esmf)
if(32BIT)
target_link_libraries(fv3dycore PUBLIC FMS::fms_r4
gfsphysics
esmf)
else()
target_link_libraries(fv3dycore PUBLIC FMS::fms_r8
gfsphysics
esmf)
endif()

if(OpenMP_Fortran_FOUND)
target_link_libraries(fv3dycore PUBLIC OpenMP::OpenMP_Fortran)
endif()
Expand Down
12 changes: 9 additions & 3 deletions io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ set_target_properties(io PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BIN
target_compile_definitions(io PRIVATE "${_io_defs_private}")
target_include_directories(io PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)

target_link_libraries(io PRIVATE fms
gfsphysics
ccppdriver)
if(32BIT)
target_link_libraries(io PRIVATE FMS::fms_r4
gfsphysics
ccppdriver)
else()
target_link_libraries(io PRIVATE FMS::fms_r8
gfsphysics
ccppdriver)
endif()
Comment on lines +34 to +42
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but in the subsequent PR's we could use an alias target when FMS is provided as a module or "third-party library" or built in the UFS (as is the case now).
This can be achieved by something like this in the UFS:

find_package(FMS QUIET)
if (FMS_FOUND)
  if (32BIT)
    add_library(fms ALIAS FMS::fms_r4)
  else()
    add_library(fms ALIAS FMS::fms_r8)
  endif()
else()
  add_subdirectory(FMS)
  if (32BIT)
    add_library(fms ALIAS FMS::fms_r4)
  else()
    add_library(fms ALIAS FMS::fms_r8)
  endif()
endif()

All downstream targets can then use fms without the need for and if-else block scattered everywhere.


if(INLINE_POST)
target_link_libraries(io PRIVATE upp::upp)
Expand Down
15 changes: 11 additions & 4 deletions stochastic_physics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ target_include_directories(stochastic_physics_wrapper PRIVATE ${CMAKE_BINARY_DIR
target_include_directories(stochastic_physics_wrapper PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src
${CMAKE_BINARY_DIR}/FV3/ccpp/physics)
target_include_directories(stochastic_physics_wrapper PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(stochastic_physics_wrapper PUBLIC fms
stochastic_physics
gfsphysics
fv3dycore)
if(32BIT)
target_link_libraries(stochastic_physics_wrapper PUBLIC FMS::fms_r4
stochastic_physics
gfsphysics
fv3dycore)
else()
target_link_libraries(stochastic_physics_wrapper PUBLIC FMS::fms_r8
stochastic_physics
gfsphysics
fv3dycore)
endif()

if(OpenMP_Fortran_FOUND)
target_link_libraries(stochastic_physics_wrapper PUBLIC OpenMP::OpenMP_Fortran)
Expand Down