From 27f95904c39cf072c379605ff66c5917695cd92e Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Tue, 17 Oct 2023 14:59:36 +1100 Subject: [PATCH] Add installation of OM3 executables and WW3 utilities to CMakeLists. Update build script to use "cmake --install" and rename all executables. --- CMakeLists.txt | 15 ++++++++++++++- WW3/CMakeLists.txt | 7 +++++++ build.sh | 10 +++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 157a025..a9333bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,12 +35,14 @@ message(STATUS " - CICE6-WW3 ${OM3_ENABLE_CICE6-WW3}") message(STATUS " - MOM6-CICE6-WW3 ${OM3_ENABLE_MOM6-CICE6-WW3}") # Build options +option(OM3_BIN_INSTALL "Instal ACCESS-OM3 executables" ${PROJECT_IS_TOP_LEVEL}) option(OM3_OPENMP "Enable OpenMP threading" OFF) option(OM3_MOM_SYMMETRIC "Use symmetric memory" OFF) set(OM3_CICE_IO "PIO" CACHE STRING "CICE OPTIONS: Choose IO options.") set_property(CACHE OM3_CICE_IO PROPERTY STRINGS "NetCDF" "PIO" "Binary") message(STATUS "Build options") +message(STATUS " - OM3_BIN_INSTALL ${OM3_BIN_INSTALL}") message(STATUS " - OM3_OPENMP ${OM3_OPENMP}") message(STATUS " - OM3_MOM_SYMMETRIC ${OM3_MOM_SYMMETRIC}") message(STATUS " - OM3_CICE_IO ${OM3_CICE_IO}") @@ -207,4 +209,15 @@ endforeach() # Install or Export # #]==============================================================================] -# TODO +## Installs +if(OM3_BIN_INSTALL) + foreach(CONF IN LISTS KnownConfigurations) + if(NOT OM3_ENABLE_${CONF}) + continue() + endif() + + install(TARGETS OM3_${CONF} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endforeach() +endif() diff --git a/WW3/CMakeLists.txt b/WW3/CMakeLists.txt index 18efa8a..2b5e687 100644 --- a/WW3/CMakeLists.txt +++ b/WW3/CMakeLists.txt @@ -138,3 +138,10 @@ set_target_properties(OM3_ww3_outp PROPERTIES OUTPUT_NAME ww3_outp ) target_link_libraries(OM3_ww3_outp PRIVATE OM3_ww3) + + +## Installs +if(OM3_BIN_INSTALL) + install(TARGETS OM3_ww3_grid OM3_ww3_strt OM3_ww3_ounf OM3_ww3_outp + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/build.sh b/build.sh index 429ba3f..3fea3cf 100755 --- a/build.sh +++ b/build.sh @@ -25,24 +25,24 @@ module load esmf/8.4.2 fms/git.2021.03.01=2021.03.01 parallelio/2.5.10 module load intel-compiler/${COMPILER_VERSION} openmpi/${OPENMPI_VERSION} cd ${SCRIPT_DIR} +INSTALL_DIR=${SCRIPT_DIR} hash=`git rev-parse --short=7 HEAD` test -z "$(git status --porcelain)" || hash=${hash}-modified # uncommitted changes or untracked files -mkdir -p bin - for BUILD_TYPE in "${BUILD_TYPES[@]}"; do echo "BUILD_TYPE = "${BUILD_TYPE} rm -r build || true cmake -S . -B build --preset=gadi -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_VERBOSE_MAKEFILE=ON cmake --build build -j 4 + cmake --install build --prefix=${INSTALL_DIR} - for exec in build/access-om3*; do - dest=bin/$(basename ${exec}) + for exec in ${INSTALL_DIR}/bin/*; do + dest=${INSTALL_DIR}/bin/$(basename ${exec}) if [[ ${BUILD_TYPE} != "Release" ]] ; then dest=${dest}-${BUILD_TYPE}; fi dest=${dest}-${hash} - cp -p ${exec} ${dest} + mv ${exec} ${dest} echo "Successfully built ${dest}" done done