Loading CMakeLists.txt +16 −8 Original line number Diff line number Diff line Loading @@ -97,6 +97,10 @@ include(FetchContent) # that are substituted when generating defaults.cpp below include(GNUInstallDirs) # CMakeDependentOption defines cmake_dependent_option() which is used to # define options that depend on other options include(CMakeDependentOption) # Make sure that CMake can find our internal modules list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") Loading Loading @@ -154,6 +158,16 @@ option(CARGO_BUILD_TESTS "Build tests (disabled by default)" OFF) set(CARGOCTL_MPIEXEC_OPTIONS "--map-by node --oversubscribe" CACHE STRING "Options passed to `${MPIEXEC_EXECUTABLE}` by `cargoctl` when starting the server") ### systemd support option(CARGO_SYSTEMD_SUPPORT "Enable systemd support (enabled by default)" ON) cmake_dependent_option( CARGO_SYSTEMD_INSTALL_UNIT_FILES "Install systemd unit files (disabled by default)" OFF "CARGO_SYSTEMD_SUPPORT" OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # ############################################################################## Loading Loading @@ -343,11 +357,6 @@ endif() # using find_package() # ############################################################################## set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path where ${PROJECT_NAME} binaries will be installed") set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" CACHE PATH "Path where ${PROJECT_NAME} data files will be installed") include(CMakePackageConfigHelpers) configure_package_config_file( Loading @@ -355,7 +364,6 @@ configure_package_config_file( "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}" PATH_VARS BIN_INSTALL_DIR DATA_INSTALL_DIR ) write_basic_package_version_file( Loading cmake/systemd.cmake 0 → 100644 +79 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain # # # # This software was partially supported by the EuroHPC-funded project ADMIRE # # (Project ID: 956748, https://www.admire-eurohpc.eu). # # # # This file is part of Cargo. # # # # cargo is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # cargo is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with cargo. If not, see <https://www.gnu.org/licenses/>. # # # # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ include(CMakeParseArguments) #[=======================================================================[.rst: get_systemd_unit_directory(OUTPUT_VARIABLE [USER]) Initialize ``OUTPUT_VARIABLE`` to the directory where systemd unit files are installed. This function will use ``pkg-config`` to find the information. If ``USER`` is specified, the user unit directory will be returned instead. #]=======================================================================] function(get_systemd_unit_directory OUTPUT_VARIABLE) set(OPTIONS USER) set(SINGLE_VALUE) set(MULTI_VALUE) cmake_parse_arguments( ARGS "${OPTIONS}" "${SINGLE_VALUE}" "${MULTI_VALUE}" ${ARGN} ) if(ARGS_UNPARSED_ARGUMENTS) message(WARNING "Unparsed arguments in get_systemd_unit_directory(): " "this often indicates typos!\n" "Unparsed arguments: ${ARGS_UNPARSED_ARGUMENTS}" ) endif() find_package(PkgConfig REQUIRED) # Check for the systemd application, so that we can find out where to # install the service unit files pkg_check_modules(SYSTEMD_PROGRAM QUIET systemd) if (ARGS_USER) set(_pc_var systemduserunitdir) else () set(_pc_var systemdsystemunitdir) endif () if (SYSTEMD_PROGRAM_FOUND) # Use pkg-config to look up the systemd unit install directory execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_pc_var} systemd OUTPUT_VARIABLE _systemd_unit_dir) string(REGEX REPLACE "[ \t\n]+" "" _systemd_unit_dir "${_systemd_unit_dir}") message(STATUS "systemd services install dir: ${_systemd_unit_dir}") set(${OUTPUT_VARIABLE} ${_systemd_unit_dir} PARENT_SCOPE ) endif () endfunction() systemd/CMakeLists.txt 0 → 100644 +45 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain # # # # This software was partially supported by the EuroHPC-funded project ADMIRE # # (Project ID: 956748, https://www.admire-eurohpc.eu). # # # # This file is part of Cargo. # # # # Cargo is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # Cargo is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with Cargo. If not, see <https://www.gnu.org/licenses/>. # # # # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ configure_file(cargo@.service.in cargo@.service @ONLY) # If requested, install the systemd unit files to the system directory # for user-defined services. Otherwise, install them to the configured # `datadir` directory (usually `/usr/share`). if(CARGO_SYSTEMD_INSTALL_UNIT_FILES) include(systemd) get_systemd_unit_directory(SYSTEMD_UNIT_DIRECTORY USER) if(NOT SYSTEMD_UNIT_DIRECTORY) message(FATAL_ERROR "Could not find systemd unit directory") endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cargo@.service DESTINATION ${SYSTEMD_UNIT_DIRECTORY} ) else() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cargo@.service DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME} ) endif() systemd/cargo@.service.in 0 → 100644 +11 −0 Original line number Diff line number Diff line [Unit] Description=Cargo parallel data stager [Service] Type=simple EnvironmentFile=%S/cargo/%I.cfg ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/cargoctl start -s ${CARGO_ADDRESS} -H ${CARGO_HOSTS} -n ${CARGO_NUM_NODES} ExecStop=@CMAKE_INSTALL_FULL_BINDIR@/cargoctl stop -s ${CARGO_ADDRESS} Restart=no PrivateTmp=true NoNewPrivileges=true Loading
CMakeLists.txt +16 −8 Original line number Diff line number Diff line Loading @@ -97,6 +97,10 @@ include(FetchContent) # that are substituted when generating defaults.cpp below include(GNUInstallDirs) # CMakeDependentOption defines cmake_dependent_option() which is used to # define options that depend on other options include(CMakeDependentOption) # Make sure that CMake can find our internal modules list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") Loading Loading @@ -154,6 +158,16 @@ option(CARGO_BUILD_TESTS "Build tests (disabled by default)" OFF) set(CARGOCTL_MPIEXEC_OPTIONS "--map-by node --oversubscribe" CACHE STRING "Options passed to `${MPIEXEC_EXECUTABLE}` by `cargoctl` when starting the server") ### systemd support option(CARGO_SYSTEMD_SUPPORT "Enable systemd support (enabled by default)" ON) cmake_dependent_option( CARGO_SYSTEMD_INSTALL_UNIT_FILES "Install systemd unit files (disabled by default)" OFF "CARGO_SYSTEMD_SUPPORT" OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # ############################################################################## Loading Loading @@ -343,11 +357,6 @@ endif() # using find_package() # ############################################################################## set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path where ${PROJECT_NAME} binaries will be installed") set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" CACHE PATH "Path where ${PROJECT_NAME} data files will be installed") include(CMakePackageConfigHelpers) configure_package_config_file( Loading @@ -355,7 +364,6 @@ configure_package_config_file( "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}" PATH_VARS BIN_INSTALL_DIR DATA_INSTALL_DIR ) write_basic_package_version_file( Loading
cmake/systemd.cmake 0 → 100644 +79 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain # # # # This software was partially supported by the EuroHPC-funded project ADMIRE # # (Project ID: 956748, https://www.admire-eurohpc.eu). # # # # This file is part of Cargo. # # # # cargo is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # cargo is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with cargo. If not, see <https://www.gnu.org/licenses/>. # # # # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ include(CMakeParseArguments) #[=======================================================================[.rst: get_systemd_unit_directory(OUTPUT_VARIABLE [USER]) Initialize ``OUTPUT_VARIABLE`` to the directory where systemd unit files are installed. This function will use ``pkg-config`` to find the information. If ``USER`` is specified, the user unit directory will be returned instead. #]=======================================================================] function(get_systemd_unit_directory OUTPUT_VARIABLE) set(OPTIONS USER) set(SINGLE_VALUE) set(MULTI_VALUE) cmake_parse_arguments( ARGS "${OPTIONS}" "${SINGLE_VALUE}" "${MULTI_VALUE}" ${ARGN} ) if(ARGS_UNPARSED_ARGUMENTS) message(WARNING "Unparsed arguments in get_systemd_unit_directory(): " "this often indicates typos!\n" "Unparsed arguments: ${ARGS_UNPARSED_ARGUMENTS}" ) endif() find_package(PkgConfig REQUIRED) # Check for the systemd application, so that we can find out where to # install the service unit files pkg_check_modules(SYSTEMD_PROGRAM QUIET systemd) if (ARGS_USER) set(_pc_var systemduserunitdir) else () set(_pc_var systemdsystemunitdir) endif () if (SYSTEMD_PROGRAM_FOUND) # Use pkg-config to look up the systemd unit install directory execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_pc_var} systemd OUTPUT_VARIABLE _systemd_unit_dir) string(REGEX REPLACE "[ \t\n]+" "" _systemd_unit_dir "${_systemd_unit_dir}") message(STATUS "systemd services install dir: ${_systemd_unit_dir}") set(${OUTPUT_VARIABLE} ${_systemd_unit_dir} PARENT_SCOPE ) endif () endfunction()
systemd/CMakeLists.txt 0 → 100644 +45 −0 Original line number Diff line number Diff line ################################################################################ # Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain # # # # This software was partially supported by the EuroHPC-funded project ADMIRE # # (Project ID: 956748, https://www.admire-eurohpc.eu). # # # # This file is part of Cargo. # # # # Cargo is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # Cargo is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with Cargo. If not, see <https://www.gnu.org/licenses/>. # # # # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ configure_file(cargo@.service.in cargo@.service @ONLY) # If requested, install the systemd unit files to the system directory # for user-defined services. Otherwise, install them to the configured # `datadir` directory (usually `/usr/share`). if(CARGO_SYSTEMD_INSTALL_UNIT_FILES) include(systemd) get_systemd_unit_directory(SYSTEMD_UNIT_DIRECTORY USER) if(NOT SYSTEMD_UNIT_DIRECTORY) message(FATAL_ERROR "Could not find systemd unit directory") endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cargo@.service DESTINATION ${SYSTEMD_UNIT_DIRECTORY} ) else() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cargo@.service DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME} ) endif()
systemd/cargo@.service.in 0 → 100644 +11 −0 Original line number Diff line number Diff line [Unit] Description=Cargo parallel data stager [Service] Type=simple EnvironmentFile=%S/cargo/%I.cfg ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/cargoctl start -s ${CARGO_ADDRESS} -H ${CARGO_HOSTS} -n ${CARGO_NUM_NODES} ExecStop=@CMAKE_INSTALL_FULL_BINDIR@/cargoctl stop -s ${CARGO_ADDRESS} Restart=no PrivateTmp=true NoNewPrivileges=true