From 9e90b17eb4c15e9bbf6953a90b2ab938708c299f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 21 Jul 2022 10:54:46 +0200 Subject: [PATCH 1/3] Require GCC 7+ --- CMakeLists.txt | 4 ++-- doc/21-development.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 109202018..196d3ce71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -386,8 +386,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OUTPUT_VARIABLE _ICINGA2_COMPILER_VERSION ) - if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "6.3.0") - message(FATAL_ERROR "Your version of GCC (${CMAKE_CXX_COMPILER_VERSION}) is too old for building Icinga 2 (GCC >= 6.3.0 is required).") + if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "7.0.0") + message(FATAL_ERROR "Your version of GCC (${CMAKE_CXX_COMPILER_VERSION}) is too old for building Icinga 2 (GCC >= 7.0.0 is required).") endif() endif() diff --git a/doc/21-development.md b/doc/21-development.md index dae57485c..c25ae839a 100644 --- a/doc/21-development.md +++ b/doc/21-development.md @@ -2173,7 +2173,7 @@ Icinga application using a dist tarball (including notes for distributions): * cmake >= 2.6 * GNU make (make) or ninja-build * C++ compiler which supports C++14 - * RHEL/Fedora/SUSE: gcc-c++ >= 6.3 (extra Developer Tools on RHEL7 see below) + * RHEL/Fedora/SUSE: gcc-c++ >= 7 (extra Developer Tools on RHEL7 see below) * Debian/Ubuntu: build-essential * Alpine: build-base * you can also use clang++ From 616ccc45fce5bf4f1ec493ab83a4efc58e49ba6d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 21 Jul 2022 10:57:08 +0200 Subject: [PATCH 2/3] Require C++17 --- CMakeLists.txt | 2 +- doc/21-development.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 196d3ce71..51c6c93ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.8) set(BOOST_MIN_VERSION "1.66.0") -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/doc/21-development.md b/doc/21-development.md index c25ae839a..66ce290fe 100644 --- a/doc/21-development.md +++ b/doc/21-development.md @@ -697,7 +697,7 @@ Read more about it in the [Technical Concepts](19-technical-concepts.md#technica #### Get to know the code -First off, you really need to know C++ and portions of C++14 and the boost libraries. +First off, you really need to know C++ and portions of C++17 and the boost libraries. Best is to start with a book or online tutorial to get into the basics. Icinga developers gained their knowledge through studies, training and self-teaching code by trying it out and asking senior developers for guidance. @@ -1138,7 +1138,7 @@ for formatting, splitting strings, joining arrays into strings, etc. Use the existing libraries and header-only includes for this specific version. -Note: Prefer C++14 features where possible, e.g. std::atomic and lambda functions. +Note: Prefer C++17 features where possible, e.g. std::atomic and lambda functions. General: @@ -1185,7 +1185,7 @@ If you consider an external library or code to be included with Icinga, the foll requirements must be fulfilled: - License is compatible with GPLv2+. Boost license, MIT works, Apache is not. -- C++14 is supported +- C++17 is supported - Header only implementations are preferred, external libraries require packages on every distribution. - No additional frameworks, Boost is the only allowed. - The code is proven to be robust and the GitHub repository is alive, or has 1k+ stars. Good libraries also provide a user list, if e.g. Ceph is using it, this is a good candidate. @@ -2172,7 +2172,7 @@ Icinga application using a dist tarball (including notes for distributions): * cmake >= 2.6 * GNU make (make) or ninja-build -* C++ compiler which supports C++14 +* C++ compiler which supports C++17 * RHEL/Fedora/SUSE: gcc-c++ >= 7 (extra Developer Tools on RHEL7 see below) * Debian/Ubuntu: build-essential * Alpine: build-base @@ -2445,7 +2445,7 @@ The following packages are required to build the SELinux policy module: ##### RHEL/CentOS 7 The RedHat Developer Toolset is required for building Icinga 2 beforehand. -This contains a C++ compiler which supports C++14 features. +This contains a C++ compiler which supports C++17 features. ```bash yum install centos-release-scl From 11f7fb19283e14db86100fff14a8eb9cd525b6a2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 15 Aug 2022 17:29:23 +0200 Subject: [PATCH 3/3] CMakeLists.txt: don't surprise (i.e. terminate) CMake < 3.8 (on SLES 12.5) with "set(CMAKE_CXX_STANDARD 17)" which it doesn't know. --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51c6c93ff..53a11b10b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,16 @@ cmake_minimum_required(VERSION 2.8.8) set(BOOST_MIN_VERSION "1.66.0") -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) + +if("${CMAKE_VERSION}" VERSION_LESS "3.8") # SLES 12.5 + if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + endif() +else() + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() project(icinga2) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")