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 Nov 29, 2023
1 parent 8160455 commit 0911d8b
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 1 deletion.
32 changes: 32 additions & 0 deletions CDEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,35 @@ target_link_libraries(OM3_cdeps_drof
target_sources(OM3_cdeps_drof PRIVATE
CDEPS/drof/rof_comp_nuopc.F90
)

### Install and Export

## 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} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# 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} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_cdeps_d${LIB} PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-d${LIB}>")
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}
COMPONENT AccessOM3_Development
)
endforeach()
endif()
21 changes: 21 additions & 0 deletions CICE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,24 @@ 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} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_cice PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-cice>")
get_target_property(cice_moddir OM3_cice Fortran_MODULE_DIRECTORY)
install(FILES ${cice_moddir}/ice_comp_nuopc.mod
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cice
COMPONENT AccessOM3_Development
)
endif()
38 changes: 38 additions & 0 deletions CMEPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,41 @@ 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

if(OM3_LIB_INSTALL)
## CMEPS library
set_target_properties(OM3_cmeps PROPERTIES
OUTPUT_NAME access-cmeps
)
install(TARGETS OM3_cmeps
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_cmeps PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-cmeps>")
get_target_property(cmeps_moddir OM3_cmeps Fortran_MODULE_DIRECTORY)
install(FILES ${cmeps_moddir}/med.mod ${cmeps_moddir}/med_time_mod.mod ${cmeps_moddir}/med_internalstate_mod.mod
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-cmeps
COMPONENT AccessOM3_Development
)

## NUOPC cap share
set_target_properties(OM3_nuopc_cap_share PROPERTIES
OUTPUT_NAME access-nuopc_cap_share
)
install(TARGETS OM3_nuopc_cap_share
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_nuopc_cap_share PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-nuopc_cap_share>")
get_target_property(nuopc_cap_share_moddir OM3_nuopc_cap_share Fortran_MODULE_DIRECTORY)
install(DIRECTORY ${nuopc_cap_share_moddir}/
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-nuopc_cap_share
COMPONENT AccessOM3_Development
)
endif()
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ add_compile_definitions(
CESMCOUPLED
)

## Fortran modules path; currently this is simply set to be the include dir
set(CMAKE_INSTALL_MODULEDIR ${CMAKE_INSTALL_INCLUDEDIR}
CACHE STRING
"Fortran module installation path (Not a cmake native variable)"
)

#[==============================================================================[
# External packages #
#]==============================================================================]
Expand Down Expand Up @@ -217,6 +223,10 @@ 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)
if(NOT OM3_ENABLE_${CONF})
Expand Down
21 changes: 21 additions & 0 deletions MOM6/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,24 @@ 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} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_mom6 PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-mom6>")
get_target_property(mom_moddir OM3_mom6 Fortran_MODULE_DIRECTORY)
install(FILES ${mom_moddir}/ocn_comp_nuopc.mod ${mom_moddir}/mom_cap_mod.mod
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-mom6
COMPONENT AccessOM3_Development
)
endif()
22 changes: 21 additions & 1 deletion WW3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,28 @@ set_target_properties(OM3_ww3_ounp PROPERTIES
)
target_link_libraries(OM3_ww3_ounp PRIVATE AccessOM3::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} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_ww3 PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-ww3>")
get_target_property(ww3_moddir OM3_ww3 Fortran_MODULE_DIRECTORY)
install(FILES ${ww3_moddir}/wav_comp_nuopc.mod
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-ww3
COMPONENT AccessOM3_Development
)
endif()

## Utilities
if(OM3_BIN_INSTALL)
install(TARGETS OM3_ww3_grid OM3_ww3_strt OM3_ww3_outf OM3_ww3_ounf OM3_ww3_ounp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down
38 changes: 38 additions & 0 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,41 @@ target_sources(OM3_timing PRIVATE
timing/perf_mod.F90
timing/perf_utils.F90
)

### Install and Export

if(OM3_LIB_INSTALL)
## share library
set_target_properties(OM3_share PROPERTIES
OUTPUT_NAME access-share
)
install(TARGETS OM3_share
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_share PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-share>")
get_target_property(share_moddir OM3_share Fortran_MODULE_DIRECTORY)
install(DIRECTORY ${share_moddir}/
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-share
COMPONENT AccessOM3_Development
)

## timing library
set_target_properties(OM3_timing PROPERTIES
OUTPUT_NAME access-timing
)
install(TARGETS OM3_timing
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_RunTime NAMELINK_COMPONENT AccessOM3_Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT AccessOM3_Development
)
# Fortran module files are a special case, as currently there is no standard
# way of handling them in CMake
target_include_directories(OM3_timing PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/access-timing>")
get_target_property(timing_moddir OM3_timing Fortran_MODULE_DIRECTORY)
install(DIRECTORY ${timing_moddir}/
DESTINATION ${CMAKE_INSTALL_MODULEDIR}/access-timing
COMPONENT AccessOM3_Development
)
endif()

0 comments on commit 0911d8b

Please sign in to comment.