Skip to content

Commit

Permalink
Add the possibility to install all the components as libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
micaeljtoliveira committed Oct 25, 2023
1 parent fe2b037 commit a548e6c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 4 deletions.
36 changes: 33 additions & 3 deletions CDEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Subdirectories

## Build FoX
add_subdirectory(fox)

### Targets

## Common library
Expand Down Expand Up @@ -89,7 +94,32 @@ target_sources(OM3_cdeps_drof PRIVATE
CDEPS/drof/rof_comp_nuopc.F90
)

### Subdirectories
### Install and Export

## Build FoX
add_subdirectory(fox)
## Library
if(OM3_LIB_INSTALL)
# cdeps_common
set_target_properties(OM3_cdeps_common PROPERTIES
OUTPUT_NAME access-cdeps-common
)
install(TARGETS OM3_cdeps_common
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# components
foreach(LIB atm ocn ice wav rof)
set_target_properties(OM3_cdeps_d${LIB} PROPERTIES
OUTPUT_NAME access-cdeps-d${LIB}
)
install(TARGETS OM3_cdeps_d${LIB}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
get_target_property(d${LIB}_moddir OM3_cdeps_d${LIB} Fortran_MODULE_DIRECTORY)
install(FILES ${d${LIB}_moddir}/${LIB}_comp_nuopc.mod DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cdeps-d${LIB})
endforeach()
endif()
18 changes: 18 additions & 0 deletions CICE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,21 @@ elseif(OM3_CICE_IO MATCHES "Binary")
CICE/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90
)
endif()

### Install and Export

## Library
if(OM3_LIB_INSTALL)
set_target_properties(OM3_cice PROPERTIES
OUTPUT_NAME access-cice
)
install(TARGETS OM3_cice
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
get_target_property(cice_moddir OM3_cice Fortran_MODULE_DIRECTORY)
install(FILES ${cice_moddir}/ice_comp_nuopc.mod DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cice)
endif()
20 changes: 20 additions & 0 deletions CMEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,23 @@ target_sources(OM3_nuopc_cap_share PRIVATE
CMEPS/cesm/nuopc_cap_share/glc_elevclass_mod.F90
CMEPS/cesm/nuopc_cap_share/nuopc_shr_methods.F90
)

### Install and Export

## Library
if(OM3_LIB_INSTALL)
set_target_properties(OM3_cmeps PROPERTIES
OUTPUT_NAME access-cmeps
)
install(TARGETS OM3_cmeps
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
get_target_property(cmeps_moddir OM3_cmeps Fortran_MODULE_DIRECTORY)
foreach(MOD med med_time_mod med_internalstate_mod)
install(FILES ${cmeps_moddir}/${MOD}.mod ${} DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cmeps)
endforeach()
endif()
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ endforeach()

## Installs

# Note that the installation of some components is done in the corresponding subdirectory

# OM3 executables
if(OM3_BIN_INSTALL)
foreach(CONF IN LISTS KnownConfigurations)
Expand Down
18 changes: 18 additions & 0 deletions MOM6/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,21 @@ target_sources(OM3_mom6 PRIVATE
MOM6/config_src/drivers/nuopc_cap/time_utils.F90
)
add_patched_source(OM3_mom6 MOM6/config_src/drivers/nuopc_cap/mom_cap.F90)

### Install and Export

## Library
if(OM3_LIB_INSTALL)
set_target_properties(OM3_mom6 PROPERTIES
OUTPUT_NAME access-mom6
)
install(TARGETS OM3_mom6
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
get_target_property(mom_moddir OM3_mom6 Fortran_MODULE_DIRECTORY)
install(FILES ${mom_moddir}/ocn_comp_nuopc.mod DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-mom6)
endif()
19 changes: 18 additions & 1 deletion WW3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,25 @@ set_target_properties(OM3_ww3_outp PROPERTIES
)
target_link_libraries(OM3_ww3_outp PRIVATE OM3_ww3)

### Install and Export

## Installs
## Library
if(OM3_LIB_INSTALL)
set_target_properties(OM3_ww3 PROPERTIES
OUTPUT_NAME access-ww3
)
install(TARGETS OM3_ww3
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
get_target_property(ww3_moddir OM3_ww3 Fortran_MODULE_DIRECTORY)
install(FILES ${ww3_moddir}/wav_comp_nuopc.mod DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-ww3)
endif()

## Utilities
if(OM3_BIN_INSTALL)
install(TARGETS OM3_ww3_grid OM3_ww3_strt OM3_ww3_ounf OM3_ww3_outp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down

0 comments on commit a548e6c

Please sign in to comment.