diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1df9a..20cca21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.26.5) # This template attempts to be "fetch_content"-able # so that it works well with tools like CPM or other @@ -23,9 +23,9 @@ endif() # Set a default build type if none was specified # This is required for Conan 2.0 to work properly if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Debug' as none was specified.") + message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE - Debug + Release CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui, ccmake set_property( diff --git a/CMakePresets.json b/CMakePresets.json index 55256f3..66abc96 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,122 +1,195 @@ { - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 24, - "patch": 0 - }, - "configurePresets": [ - { - "name": "conf-common", - "description": "General settings that apply to all configurations", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}" - }, - { - "name": "conf-linux-common", - "description": "Linux OS settings for gcc and clang toolchains", - "hidden": true, - "inherits": "conf-common", - "condition": { - "type": "inList", - "string": "${hostSystemName}", - "list": [ - "Linux" - ] - }, - "vendor": { - "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { - "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" - } - } - }, - { - "name": "linux-gcc-debug", - "displayName": "gcc Debug", - "description": "Target Linux OS with the gcc compiler, debug build type", - "inherits": "conf-linux-common", - "cacheVariables": { - "CMAKE_C_COMPILER": "gcc", - "CMAKE_CXX_COMPILER": "g++", - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "linux-gcc-release", - "displayName": "gcc Release", - "description": "Target Linux OS with the gcc compiler, release build type", - "inherits": "conf-linux-common", - "cacheVariables": { - "CMAKE_C_COMPILER": "gcc", - "CMAKE_CXX_COMPILER": "g++", - "CMAKE_BUILD_TYPE": "Release" - } - }, - { - "name": "linux-clang-debug", - "displayName": "clang Debug", - "description": "Target Linux OS with the clang compiler, debug build type", - "inherits": "conf-linux-common", - "cacheVariables": { - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "linux-clang-release", - "displayName": "clang Release", - "description": "Target Linux OS with the clang compiler, release build type", - "inherits": "conf-linux-common", - "cacheVariables": { - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_BUILD_TYPE": "Release" - } - } - ], - "testPresets": [ - { - "name": "test-common", - "description": "Test CMake settings that apply to all configurations", - "hidden": true, - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } - }, - { - "name": "test-linux-gcc-debug", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "test-common", - "configurePreset": "linux-gcc-debug" - }, - { - "name": "test-linux-gcc-release", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "test-common", - "configurePreset": "linux-gcc-release" - }, - { - "name": "test-linux-clang-debug", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "test-common", - "configurePreset": "linux-clang-debug" + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 26, + "patch": 5 + }, + "configurePresets": [ + { + "name": "conf-common", + "description": "General settings that apply to all configurations", + "hidden": true, + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}" + }, + { + "name": "conf-linux-common", + "description": "Linux common settings", + "hidden": true, + "inherits": "conf-common", + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": ["Linux"] + }, + "vendor": { + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" }, - { - "name": "test-linux-clang-release", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "test-common", - "configurePreset": "linux-clang-release" + "jetbrains.com/clion": { + "toolchain": "CloysterHPC RHEL9 Dev" } - ] -} \ No newline at end of file + } + }, + { + "name": "conf-linux-gcc-common", + "description": "Target Linux OS with the gcc compiler", + "hidden": true, + "inherits": "conf-linux-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" + } + }, + { + "name": "rhel9-gcc-release", + "displayName": "RHEL9 GCC Release", + "description": "Target Red Hat Enterprise Linux 9 with the gcc compiler, release build type", + "inherits": "conf-linux-gcc-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "rhel9-gcc-debug", + "displayName": "RHEL9 GCC Debug", + "description": "Target Red Hat Enterprise Linux 9 with the gcc compiler, debug build type", + "inherits": "conf-linux-gcc-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "conf-linux-gcc-toolset-13-common", + "description": "Target Linux OS with the gcc toolset 13 compiler", + "hidden": true, + "inherits": "conf-linux-common", + "environment": { + "PATH": "/opt/rh/gcc-toolset-13/root/usr/bin:$penv{PATH}", + "MANPATH": "/opt/rh/gcc-toolset-13/root/usr/share/man:$penv{MANPATH}", + "INFOPATH": "/opt/rh/gcc-toolset-13/root/usr/share/info:$penv{INFOPATH}", + "PCP_DIR": "/opt/rh/gcc-toolset-13/root", + "LD_LIBRARY_PATH": "/opt/rh/gcc-toolset-13/root/usr/lib64:$penv{LD_LIBRARY_PATH}", + "PKG_CONFIG_PATH": "/opt/rh/gcc-toolset-13/root/usr/lib64/pkgconfig:$penv{PKG_CONFIG_PATH}", + "X_SCLS": "gcc-toolset-13" + }, + "cacheVariables": { + "CMAKE_C_COMPILER": "/opt/rh/gcc-toolset-13/root/usr/bin/gcc", + "CMAKE_CXX_COMPILER": "/opt/rh/gcc-toolset-13/root/usr/bin/g++" + } + }, + { + "name": "rhel9-gcc-toolset-13-release", + "displayName": "RHEL9 GCC 13 Release", + "description": "Target Red Hat Enterprise Linux 9 with the gcc toolset 13 compiler, release build type", + "inherits": "conf-linux-gcc-toolset-13-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "rhel9-gcc-toolset-13-debug", + "displayName": "RHEL9 GCC 13 Debug", + "description": "Target Red Hat Enterprise Linux 9 with the gcc toolset 13 compiler, debug build type", + "inherits": "conf-linux-gcc-toolset-13-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "conf-linux-clang-common", + "description": "Target Linux OS with the clang compiler", + "hidden": true, + "inherits": "conf-linux-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "linux-clang-release", + "displayName": "clang Release", + "description": "Target Linux OS with the clang compiler, release build type", + "hidden": true, + "inherits": "conf-linux-clang-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "linux-clang-debug", + "displayName": "clang Debug", + "description": "Target Linux OS with the clang compiler, debug build type", + "hidden": true, + "inherits": "conf-linux-clang-common", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ], + "buildPresets": [ + { + "name": "rhel9-gcc-release", + "displayName": "gcc build release", + "configurePreset": "rhel9-gcc-release" + }, + { + "name": "rhel9-gcc-debug", + "displayName": "gcc build debug", + "configurePreset": "rhel9-gcc-debug" + }, + { + "name": "rhel9-gcc-toolset-13-release", + "displayName": "gcc toolset 13 build release", + "configurePreset": "rhel9-gcc-toolset-13-release" + }, + { + "name": "rhel9-gcc-toolset-13-debug", + "displayName": "gcc toolset 13 build debug", + "configurePreset": "rhel9-gcc-toolset-13-debug" + } + ], + "testPresets": [ + { + "name": "test-common", + "description": "Test CMake settings that apply to all configurations", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "test-linux-gcc-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "linux-gcc-debug" + }, + { + "name": "test-linux-gcc-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "linux-gcc-release" + }, + { + "name": "test-linux-clang-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "linux-clang-debug" + }, + { + "name": "test-linux-clang-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "linux-clang-release" + } + ] +} diff --git a/README.md b/README.md index 0ecf375..179286f 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ nature and `root` execution requirements. ### Recommended VM settings -* EL8 based system with **minimal** package selection +* EL8.9 or EL9.4 and higher based system with **minimal** package selection * Half of system CPU cores as vCPU * At least 4GB of RAM * 50GB of Disk @@ -131,20 +131,18 @@ All dependencies should be installed after its execution and then follow with standard [CMake](https://cmake.org) procedure. All default [CMake](https://cmake.org) targets are supported. By default, it -builds a **Debug** target with sanitizers enabled that modifies the -running OS, so be **advised to run the code on a development system only**. +builds a **Release** target that modifies the running OS, so be **advised to +run the code on a development system only**. Finally, to build the software just run the commands: ``` - $ git submodule init - $ git submodule update $ cmake -S . -B ./build $ cmake --build ./build ``` -Resulting binary will be available on `/build/src` directory in the root directory of -the project. +Resulting binary will be available on `/build/src` directory in the root +directory of the project. As a final warning: running the software without **DUMMY** option will probably damage the running OS if they run as **root**. Be advised. diff --git a/include/cloysterhpc/mailsystem/postfix.h b/include/cloysterhpc/mailsystem/postfix.h index 5836a5c..c0de431 100644 --- a/include/cloysterhpc/mailsystem/postfix.h +++ b/include/cloysterhpc/mailsystem/postfix.h @@ -8,6 +8,7 @@ #include #include +#include class Postfix { public: diff --git a/rhel-gcc-toolset-12.sh b/rhel-gcc-toolset-12.sh deleted file mode 100644 index 51ed35b..0000000 --- a/rhel-gcc-toolset-12.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# This file should be executed to enable the GCC 12 toolset on RHEL 8. -# It is meant to be sourced by the user's shell before any compilation, -# including Conan builds. If running from an IDE please remeber to check this -# file as the environment. - -source scl_source enable gcc-toolset-12 diff --git a/rhel-gcc-toolset-13.sh b/rhel-gcc-toolset-13.sh new file mode 100644 index 0000000..440225c --- /dev/null +++ b/rhel-gcc-toolset-13.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# +# This file should be executed to enable the GCC 13 toolset on RHEL. +# It is meant to be sourced by the user's shell before any compilation, +# including Conan builds. If running from an IDE please remember to check this +# file as the environment. + +source scl_source enable gcc-toolset-13 diff --git a/setupDevEnvironment.sh b/setupDevEnvironment.sh index d5e6fda..766728d 100755 --- a/setupDevEnvironment.sh +++ b/setupDevEnvironment.sh @@ -6,24 +6,53 @@ # This file is part of CloysterHPC # https://github.com/viniciusferrao/cloysterhpc # -# Script to ease development environment setup on EL8 systems +# Script to ease development environment setup on Enterprise Linux (EL) systems # Stop execution in case of any error (add x for debugging) set -e -os_version=$(rpm -E %{rhel}) + +# Check if it's not running as root +if [ "$(id -u)" -ne 0 ]; then + # Check if sudo is available + if command -v sudo >/dev/null; then + # Override dnf to use sudo + dnf() { + sudo /usr/bin/dnf "$@" + } + else + echo \ + "sudo is required but not installed. Please install sudo or run as root." + exit 1 + fi +fi + +# Grab EL version from RPM +os_version=$(rpm -E %rhel) + +# Helper functions +add_epel() { + dnf -y install \ + "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${os_version}.noarch.rpm" +} # OS relevant settings redhat() { - subscription-manager refresh - dnf config-manager --set-enabled codeready-builder-for-rhel-8-x86_64-rpms - dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + if [ "$(id -u)" -eq 0 ]; then + subscription-manager refresh + else + sudo subscription-manager refresh + fi + + dnf config-manager --set-enabled \ + "codeready-builder-for-rhel-${os_version}-x86_64-rpms" + add_epel; } rocky() { - if [ "$os_version" == "8" ]; then - repo_name="powertools" - elif [ "$os_version" == "9" ]; then - repo_name="crb" + if [ "$os_version" = "8" ]; then + repo_name="powertools" + elif [ "$os_version" = "9" ]; then + repo_name="crb" fi dnf config-manager --set-enabled "$repo_name" @@ -31,10 +60,10 @@ rocky() { } almalinux() { - if [ "$os_version" == "8" ]; then - repo_name="powertools" - elif [ "$os_version" == "9" ]; then - repo_name="crb" + if [ "$os_version" = "8" ]; then + repo_name="powertools" + elif [ "$os_version" = "9" ]; then + repo_name="crb" fi dnf config-manager --set-enabled "$repo_name" @@ -42,8 +71,8 @@ almalinux() { } oracle() { - dnf config-manager --set-enabled ol8_codeready_builder - dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + dnf config-manager --set-enabled "ol${os_version}_codeready_builder" + add_epel; } # @@ -67,21 +96,31 @@ case $(cut -f 3 -d : /etc/system-release-cpe) in ;; *) echo Unable to properly identify the running OS. Aborting. - exit 1 + exit 2 ;; esac -# Build toolset and packages -dnf -y install git cmake ccache llvm-toolset compiler-rt gcc-toolset-12 python3-pip\* +# Build toolset, packages and utils +dnf -y install git gcc-c++ cmake ccache cppcheck rsync + +if [ "$os_version" = "8" ]; then + dnf -y install python3 python3-pip\* llvm-toolset compiler-rt \ + gcc-toolset-13 gcc-toolset-13-libubsan-devel gcc-toolset-13-libasan-devel +elif [ "$os_version" = "9" ]; then + dnf -y install python pip libasan libubsan +fi + pip3 install --user conan -pip3 install numpy # Required libraries -dnf -y install newt-devel cppcheck +dnf -y install newt-devel echo echo Development tools, packages and libraries were installed on your system. -echo Please remeber to source or activate the environment file with the correct -echo compiler: \"source rhel-gcc-toolset-12.sh\" +echo +echo If compiling or running on EL8, please remember to source or activate the +echo environment file with the correct toolset compiler: +echo \"source rhel-gcc-toolset-13.sh\" +echo echo To proceed with the compilation please refer to the README.md file. echo diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e9bd202..c070ee6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.26.5) project(CmakeConfigPackageTests LANGUAGES CXX)