Skip to content

Commit

Permalink
Use C++14 by default when building on systems that support it. (netda…
Browse files Browse the repository at this point in the history
…ta#16972)

This is needed to properly support the latest versions of Protobuf.
Ferroin authored Feb 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent dd11815 commit 63f53de
Showing 4 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -60,7 +60,13 @@ project(netdata
find_package(PkgConfig REQUIRED)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

option(USE_CXX_11 "use C++11 instead of C++14" False)

if(USE_CXX_11)
set(CMAKE_CXX_STANDARD 11)
endif()

set(CMAKE_C_STANDARD_REQUIRED On)
set(CMAKE_CXX_STANDARD_REQUIRED On)
3 changes: 3 additions & 0 deletions netdata-installer.sh
Original file line number Diff line number Diff line change
@@ -209,6 +209,7 @@ USAGE: ${PROGRAM} [options]
--disable-ebpf Disable eBPF Kernel plugin. Default: enabled.
--disable-cloud Disable all Netdata Cloud functionality.
--require-cloud Fail the install if it can't build Netdata Cloud support.
--force-legacy-cxx Force usage of an older C++ standard to allow building on older systems. This will usually be autodetected.
--enable-plugin-freeipmi Enable the FreeIPMI plugin. Default: enable it when libipmimonitoring is available.
--disable-plugin-freeipmi Explicitly disable the FreeIPMI plugin.
--disable-https Explicitly disable TLS support.
@@ -257,6 +258,7 @@ ENABLE_H2O=1
ENABLE_CLOUD=1
ENABLE_LOGS_MANAGEMENT=1
ENABLE_LOGS_MANAGEMENT_TESTS=0
FORCE_LEGACY_CXX=0
NETDATA_CMAKE_OPTIONS="${NETDATA_CMAKE_OPTIONS-}"

RELEASE_CHANNEL="nightly" # valid values are 'nightly' and 'stable'
@@ -273,6 +275,7 @@ while [ -n "${1}" ]; do
"--auto-update-type") ;;
"--stable-channel") RELEASE_CHANNEL="stable" ;;
"--nightly-channel") RELEASE_CHANNEL="nightly" ;;
"--force-legacy-cxx") FORCE_LEGACY_CXX=1 ;;
"--enable-plugin-freeipmi") ENABLE_FREEIPMI=1 ;;
"--disable-plugin-freeipmi") ENABLE_FREEIPMI=0 ;;
"--disable-https")
5 changes: 5 additions & 0 deletions netdata.spec.in
Original file line number Diff line number Diff line change
@@ -352,6 +352,11 @@ make download
# Conf step
%cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=/ \
%if 0%{?centos_ver:1}
%if %{centos_ver} < 8
-DUSE_CXX_11=On \
%endif
%endif
%if %{_have_cups}
-DENABLE_PLUGIN_CUPS=On \
%else
22 changes: 22 additions & 0 deletions packaging/installer/functions.sh
Original file line number Diff line number Diff line change
@@ -235,6 +235,28 @@ check_for_feature() {
prepare_cmake_options() {
NETDATA_CMAKE_OPTIONS="-S ./ -B ${NETDATA_BUILD_DIR} ${CMAKE_OPTS} ${NETDATA_PREFIX+-DCMAKE_INSTALL_PREFIX="${NETDATA_PREFIX}"} ${NETDATA_USER:+-DNETDATA_USER=${NETDATA_USER}} ${NETDATA_CMAKE_OPTIONS} "

NEED_OLD_CXX=0

if [ "${FORCE_LEGACY_CXX:-0}" -eq 1 ]; then
NEED_OLD_CXX=1
else
if command -v gcc >/dev/null 2>&1; then
if [ "$(gcc --version | head -n 1 | sed 's/(.*) //' | cut -f 2 -d ' ' | cut -f 1 -d '.')" -lt 5 ]; then
NEED_OLD_CXX=1
fi
fi

if command -v clang >/dev/null 2>&1; then
if [ "$(clang --version | head -n 1 | cut -f 3 -d ' ' | cut -f 1 -d '.')" -lt 4 ]; then
NEED_OLD_CXX=1
fi
fi
fi

if [ "${NEED_OLD_CXX}" -eq 1 ]; then
NETDATA_CMAKE_OPTIONS="${NETDATA_CMAKE_OPTIONS} -DUSE_CXX_11=On"
fi

if [ "${USE_SYSTEM_PROTOBUF:-1}" -eq 1 ]; then
enable_feature BUNDLED_PROTOBUF 0
else

0 comments on commit 63f53de

Please sign in to comment.