Merge pull request #9133 from Icinga/feature/gcc63

Require C++14 and GCC 6.3+
This commit is contained in:
Julian Brost 2022-08-12 14:17:12 +02:00 committed by GitHub
commit ad58106226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 33 deletions

View File

@ -2,6 +2,8 @@
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.8.8)
set(BOOST_MIN_VERSION "1.66.0") set(BOOST_MIN_VERSION "1.66.0")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(icinga2) project(icinga2)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@ -383,8 +385,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
OUTPUT_VARIABLE _ICINGA2_COMPILER_VERSION OUTPUT_VARIABLE _ICINGA2_COMPILER_VERSION
) )
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7.0") 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 >= 4.7.0 is required).") message(FATAL_ERROR "Your version of GCC (${CMAKE_CXX_COMPILER_VERSION}) is too old for building Icinga 2 (GCC >= 6.3.0 is required).")
endif() endif()
endif() endif()
@ -395,8 +397,6 @@ if(MSVC)
endif() endif()
if(NOT MSVC) if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE) check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)
if(NOT CXX_FEATURE_OVERRIDE) if(NOT CXX_FEATURE_OVERRIDE)

View File

@ -697,7 +697,7 @@ Read more about it in the [Technical Concepts](19-technical-concepts.md#technica
#### Get to know the code <a id="development-develop-get-to-know-the-code"></a> #### Get to know the code <a id="development-develop-get-to-know-the-code"></a>
First off, you really need to know C++ and portions of C++11 and the boost libraries. First off, you really need to know C++ and portions of C++14 and the boost libraries.
Best is to start with a book or online tutorial to get into the basics. 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 Icinga developers gained their knowledge through studies, training and self-teaching
code by trying it out and asking senior developers for guidance. 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 Use the existing libraries and header-only includes
for this specific version. for this specific version.
Note: Prefer C++11 features where possible, e.g. std::atomic and lambda functions. Note: Prefer C++14 features where possible, e.g. std::atomic and lambda functions.
General: General:
@ -1185,7 +1185,7 @@ If you consider an external library or code to be included with Icinga, the foll
requirements must be fulfilled: requirements must be fulfilled:
- License is compatible with GPLv2+. Boost license, MIT works, Apache is not. - License is compatible with GPLv2+. Boost license, MIT works, Apache is not.
- C++11 is supported, C++14 or later doesn't work - C++14 is supported
- Header only implementations are preferred, external libraries require packages on every distribution. - Header only implementations are preferred, external libraries require packages on every distribution.
- No additional frameworks, Boost is the only allowed. - 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. - 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.
@ -1365,13 +1365,13 @@ are best effort and sometimes out-of-date. Git Master may contain updates.
#### CentOS 7 <a id="development-linux-dev-env-centos"></a> #### CentOS 7 <a id="development-linux-dev-env-centos"></a>
```bash ```bash
yum -y install gdb vim git bash-completion htop yum -y install gdb vim git bash-completion htop centos-release-scl
yum -y install rpmdevtools ccache \ yum -y install rpmdevtools ccache \
cmake make gcc-c++ flex bison \ cmake make devtoolset-11-gcc-c++ flex bison \
openssl-devel boost169-devel systemd-devel \ openssl-devel boost169-devel systemd-devel \
mysql-devel postgresql-devel libedit-devel \ mysql-devel postgresql-devel libedit-devel \
libstdc++-devel devtoolset-11-libstdc++-devel
groupadd icinga groupadd icinga
groupadd icingacmd groupadd icingacmd
@ -1412,8 +1412,8 @@ Fourth, depending on your likings, you may add a bash alias for building,
or invoke the commands inside: or invoke the commands inside:
```bash ```bash
alias i2_debug="cd /root/icinga2; mkdir -p debug; cd debug; cmake $I2_DEBUG ..; make -j2; sudo make -j2 install; cd .." alias i2_debug="cd /root/icinga2; mkdir -p debug; cd debug; scl enable devtoolset-11 -- cmake $I2_DEBUG ..; make -j2; sudo make -j2 install; cd .."
alias i2_release="cd /root/icinga2; mkdir -p release; cd release; cmake $I2_RELEASE ..; make -j2; sudo make -j2 install; cd .." alias i2_release="cd /root/icinga2; mkdir -p release; cd release; scl enable devtoolset-11 -- cmake $I2_RELEASE ..; make -j2; sudo make -j2 install; cd .."
``` ```
This is taken from the [centos7-dev](https://github.com/Icinga/icinga-vagrant/tree/master/centos7-dev) Vagrant box. This is taken from the [centos7-dev](https://github.com/Icinga/icinga-vagrant/tree/master/centos7-dev) Vagrant box.
@ -2172,8 +2172,8 @@ Icinga application using a dist tarball (including notes for distributions):
* cmake >= 2.6 * cmake >= 2.6
* GNU make (make) or ninja-build * GNU make (make) or ninja-build
* C++ compiler which supports C++11 * C++ compiler which supports C++14
* RHEL/Fedora/SUSE: gcc-c++ >= 4.7 (extra Developer Tools on RHEL5/6 see below) * RHEL/Fedora/SUSE: gcc-c++ >= 6.3 (extra Developer Tools on RHEL7 see below)
* Debian/Ubuntu: build-essential * Debian/Ubuntu: build-essential
* Alpine: build-base * Alpine: build-base
* you can also use clang++ * you can also use clang++
@ -2442,33 +2442,18 @@ The following packages are required to build the SELinux policy module:
* selinux-policy (selinux-policy on CentOS 6, selinux-policy-devel on CentOS 7) * selinux-policy (selinux-policy on CentOS 6, selinux-policy-devel on CentOS 7)
* selinux-policy-doc * selinux-policy-doc
##### RHEL/CentOS 6 ##### RHEL/CentOS 7
The RedHat Developer Toolset is required for building Icinga 2 beforehand. The RedHat Developer Toolset is required for building Icinga 2 beforehand.
This contains a modern version of flex and a C++ compiler which supports This contains a C++ compiler which supports C++14 features.
C++11 features.
```bash ```bash
cat >/etc/yum.repos.d/devtools-2.repo <<REPO yum install centos-release-scl
[testing-devtools-2-centos-\$releasever]
name=testing 2 devtools for CentOS $releasever
baseurl=https://people.centos.org/tru/devtools-2/\$releasever/\$basearch/RPMS
gpgcheck=0
REPO
``` ```
Dependencies to devtools-2 are used in the RPM SPEC, so the correct tools Dependencies to devtools-11 are used in the RPM SPEC, so the correct tools
should be used for building. should be used for building.
As an alternative, you can use newer Boost packages provided on
[packages.icinga.com](https://packages.icinga.com/epel).
```bash
cat >$HOME/.rpmmacros <<MACROS
%build_icinga_org 1
MACROS
```
##### Amazon Linux ##### Amazon Linux
If you prefer to build packages offline, a suitable Vagrant box is located If you prefer to build packages offline, a suitable Vagrant box is located