Verified Commit 901cccba authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Basic daemon skeleton

parent e5bcd7d7
Loading
Loading
Loading
Loading

.clang-format

0 → 100644
+73 −0
Original line number Diff line number Diff line
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: All
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
  AfterCaseLabel: false
  AfterClass: false
  AfterControlStatement: Never
  AfterEnum: false
  AfterFunction: false
  AfterNamespace: false
  AfterUnion: false
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
  SplitEmptyFunction: false
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 80
CompactNamespaces: false
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
FixNamespaceComments: true
# IncludeBlocks? TODO
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
TabWidth: 4
UseTab: Never

.cmake-format

0 → 100644
+49 −0
Original line number Diff line number Diff line
# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):

  # enable comment markup parsing and reflow
  enable_markup = False

# -----------------------------
# Options affecting formatting.
# -----------------------------
with section("format"):

  # Disable formatting entirely, making cmake-format a no-op
  disable = False

  # How wide to allow formatted cmake files
  line_width = 80

  # How many spaces to tab for indent
  tab_size = 2

  # If true, lines are indented using tab characters (utf-8 0x09) instead of
  # <tab_size> space characters (utf-8 0x20). In cases where the layout would
  # require a fractional tab character, the behavior of the  fractional
  # indentation is governed by <fractional_tab_policy>
  use_tabchars = False

  # If true, separate flow control names from their parentheses with a space
  separate_ctrl_name_with_space = False

  # If true, separate function names from parentheses with a space
  separate_fn_name_with_space = False

  # If a statement is wrapped to more than one line, than dangle the closing
  # parenthesis on its own line.
  dangle_parens = True

  # If an argument group contains more than this many sub-groups (parg or kwarg
  # groups) then force it to a vertical layout.
  max_subgroups_hwrap = 2

  # If a positional argument group contains more than this many arguments, then
  # force it to a vertical layout.
  max_pargs_hwrap = 2

  # If a cmdline positional group consumes more than this many lines without
  # nesting, then invalidate the layout (and nest)
  max_rows_cmdline = 2

CMakeLists.txt

0 → 100644
+146 −0
Original line number Diff line number Diff line
################################################################################
# Copyright 2021, 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 scord.                                                  #
#                                                                              #
# scord 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.                                          #
#                                                                              #
# scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################


# ##############################################################################
# Configure CMake
# ##############################################################################

# FetchContent_MakeAvailable() was introduced in 3.14
cmake_minimum_required(VERSION 3.14)

# Set default build type and also populate a list of available options
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "[hermes] Setting build type to '${default_build_type}' as none was specified.")
  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
      STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# ##############################################################################
# Define the CMake project
# ##############################################################################
project(
  scord
  VERSION 0.1.0
  LANGUAGES CXX
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(STATUS "[${PROJECT_NAME}] Project version: ${PROJECT_VERSION}")
configure_file(src/version.hpp.in src/version.hpp)

# FetchContent defines FetchContent_Declare() and FetchContent_MakeAvailable()
# which are used to download some dependencies
include(FetchContent)

# GNUInstallDirs defines variables such as BINDIR, SBINDIR, SYSCONFDIR, etc.
# that are substituted when generating defaults.cpp below
include(GNUInstallDirs)

# Make sure that CMake can find our internal modules
list(
  PREPEND
  CMAKE_MODULE_PATH
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)

# ##############################################################################
# Project configuration options
# ##############################################################################

### server bind address
set(SCORD_BIND_ADDRESS
    "127.0.0.1"
    CACHE
      STRING
      "Define the bind address for the ${PROJECT_NAME} server (default: 127.0.0.1)"
)
message(STATUS "[${PROJECT_NAME}] server bind address: ${SCORD_BIND_ADDRESS}")

### server bind port
set(SCORD_BIND_PORT
    "52000"
    CACHE STRING
          "Define the bind port for the ${PROJECT_NAME} server (default: 52000)"
)
message(STATUS "[${PROJECT_NAME}] server bind port: ${SCORD_BIND_PORT}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ##############################################################################
# Check for and/or download dependencies
# ##############################################################################

### boost libraries: required for processing program options
message(STATUS "[${PROJECT_NAME}] Checking for boost libraries")
find_package(
  Boost
  1.53
  REQUIRED
  COMPONENTS program_options
)

### yaml-cpp: required for reading configuration files
message(STATUS "[${PROJECT_NAME}] Checking for yaml-cpp")
find_package(
  YAMLCpp
  0.6.2
  REQUIRED
)

### {fmt}: required for sensible output formatting
message(STATUS "[${PROJECT_NAME}] Downloading and building {fmt}")
FetchContent_Declare(
  fmt
  GIT_REPOSITORY https://github.com/fmtlib/fmt
  GIT_TAG d141cdbeb0fb422a3fb7173b285fd38e0d1772dc # v8.0.1
  GIT_SHALLOW ON
  GIT_PROGRESS ON
)

FetchContent_MakeAvailable(fmt)

### spdlog: required for logging
message(STATUS "[${PROJECT_NAME}] Downloading and building spdlog")
FetchContent_Declare(
  spdlog
  GIT_REPOSITORY https://github.com/gabime/spdlog
  GIT_TAG eb3220622e73a4889eee355ffa37972b3cac3df5 # v1.9.2
  GIT_SHALLOW ON
  GIT_PROGRESS ON
)

FetchContent_MakeAvailable(spdlog)

# ##############################################################################
# Process subdirectories
# ##############################################################################
add_subdirectory(etc)
add_subdirectory(src)
+120 −0
Original line number Diff line number Diff line
################################################################################
# Copyright 2021, 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 scord.                                                  #
#                                                                              #
# scord 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.                                          #
#                                                                              #
# scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

#[=======================================================================[.rst:
FindYAMLCpp
---------

Find yaml-cpp include dirs and libraries.

Use this module by invoking find_package with the form::

  find_package(YAMLCpp
    [version] [EXACT]     # Minimum or EXACT version e.g. 0.6.2
    [REQUIRED]            # Fail with error if yaml-cpp is not found
    )

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``YAMLCpp::YAMLCpp``
  The YAMLCpp library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``YAMLCpp_FOUND``
  True if the system has the YAMLCpp library.
``YAMLCpp_VERSION``
  The version of the YAMLCpp library which was found.
``YAMLCpp_INCLUDE_DIRS``
  Include directories needed to use YAMLCpp.
``YAMLCpp_LIBRARIES``
  Libraries needed to link to YAMLCpp.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``YAMLCpp_INCLUDE_DIR``
  The directory containing ``yaml.h``.
``YAMLCpp_LIBRARY``
  The path to the YAMLCpp library.

#]=======================================================================]

# yaml-cpp already provides a config file, but sadly it doesn't define
# a target with the appropriate properties. Fortunately, it also provides a
# pkg-config .pc file that we can use to fetch the required library properties
# and wrap them neatly into the 'YAMLCpp' target we provide
find_package(PkgConfig)
pkg_check_modules(PC_YAMLCpp QUIET yaml-cpp)

find_path(YAMLCpp_INCLUDE_DIR
  NAMES yaml-cpp/yaml.h
  PATHS ${PC_YAMLCpp_INCLUDE_DIRS}
  PATH_SUFFIXES YAMLCpp
)

find_library(YAMLCpp_LIBRARY
  NAMES yaml-cpp
  PATHS ${PC_YAMLCpp_LIBRARY_DIRS}
)

mark_as_advanced(
  YAMLCpp_INCLUDE_DIR
  YAMLCpp_LIBRARY
)

set(YAMLCpp_VERSION ${PC_YAMLCpp_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(YAMLCpp
  FOUND_VAR YAMLCpp_FOUND
  REQUIRED_VARS
    YAMLCpp_LIBRARY
    YAMLCpp_INCLUDE_DIR
  VERSION_VAR YAMLCpp_VERSION
)

if(YAMLCpp_FOUND)
  set(YAMLCpp_LIBRARIES ${YAMLCpp_LIBRARY})
  set(YAMLCpp_INCLUDE_DIRS ${YAMLCpp_INCLUDE_DIR})
  set(YAMLCpp_DEFINITIONS ${PC_YAMLCpp_CFLAGS_OTHER})
endif()

if(YAMLCpp_FOUND AND NOT TARGET YAMLCpp::YAMLCpp)
  add_library(YAMLCpp::YAMLCpp UNKNOWN IMPORTED)
  set_target_properties(YAMLCpp::YAMLCpp PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
    IMPORTED_LOCATION "${YAMLCpp_LIBRARY}"
    INTERFACE_COMPILE_DEFINITIONS "${PC_YAMLCpp_CFLAGS_OTHER}"
    INTERFACE_INCLUDE_DIRECTORIES "${YAMLCpp_INCLUDE_DIR}"
)
endif()

etc/CMakeLists.txt

0 → 100644
+25 −0
Original line number Diff line number Diff line
################################################################################
# Copyright 2021, 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 scord.                                                  #
#                                                                              #
# scord 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.                                          #
#                                                                              #
# scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

configure_file(scord.conf.in scord.conf)
Loading