Skip to content

Commit

Permalink
Upgrade Natron's minimum C++ version to c++17. (NatronGitHub#984)
Browse files Browse the repository at this point in the history
* Upgrade Natron's minimum C++ version to c++17.
* Removed old C++11 logic from build files.

Signed-off-by: Aaron Colwell <300262+acolwell@users.noreply.github.com>
  • Loading branch information
acolwell authored Jul 22, 2024
1 parent 73e7dd8 commit b38d9d5
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 140 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
cmake_minimum_required(VERSION 3.16.7)

project(Natron
VERSION "2.5.0"
VERSION "2.6.0"
DESCRIPTION "Open Source Compositing Software"
HOMEPAGE_URL "https://natrongithub.github.io/"
LANGUAGES CXX C
)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

option(NATRON_SYSTEM_LIBS "use system versions of dependencies instead of bundled ones" OFF)
option(NATRON_BUILD_TESTS "build the Natron test suite" ON)
Expand Down
2 changes: 1 addition & 1 deletion Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(PYENGINE_HEADER PySide2_Engine_Python.h)
set(POST_SHIBOKEN ../tools/utils/runPostShiboken2.sh)

set(shiboken_args
"--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"-std=c++17" "--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"--avoid-protected-hack" "--enable-pyside-extensions"
"-I." "-I.." "-I../Global" "-I../libs/OpenFX/include" ${PYENGINE_INCS}
"-T${PYSIDE_TYPESYSTEMS}" "--output-directory=${PYENGINE_OUT}"
Expand Down
4 changes: 2 additions & 2 deletions Global/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#endif

#ifdef __cplusplus
#if __cplusplus < 201402L
#error "Natron 2.5+ requires C++14"
#if __cplusplus < 201703L
#error "Natron 2.6+ requires C++17"
#endif
// Establish the name space.
namespace Natron { }
Expand Down
2 changes: 1 addition & 1 deletion Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(PYGUI_HEADER PySide2_Gui_Python.h)
set(POST_SHIBOKEN ../tools/utils/runPostShiboken2.sh)

set(shiboken_args
"--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"-std=c++17" "--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"--avoid-protected-hack" "--enable-pyside-extensions"
${PYGUI_INCS}
"-T../Engine" "-T${PYSIDE_TYPESYSTEMS}" "--output-directory=${PYGUI_OUT}"
Expand Down
71 changes: 8 additions & 63 deletions global.pri
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
# ***** END LICENSE BLOCK *****

CONFIG += c++11 c++14
CONFIG += c++17

# libs may modify the config (eg openmp), so it must be included before
include(libs.pri)
Expand Down Expand Up @@ -201,9 +201,6 @@ unix:LIBS += $$QMAKE_LIBS_DYNLOAD
# see https://github.com/MrKepzie/Natron/issues/1659
# -fpermissive turns it into a warning
QMAKE_CXXFLAGS += -fpermissive
# GCC 6 and later are C++14 by default, but Qt 4 is C++98
# Note: disabled, because qmake should put the right flags anyway
#lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=gnu++98

# clear some Eigen3 warnings
QMAKE_CFLAGS += -Wno-int-in-bool-context
Expand All @@ -215,22 +212,6 @@ unix:LIBS += $$QMAKE_LIBS_DYNLOAD
QMAKE_CXXFLAGS += -Wno-expansion-to-defined
}
}
c++11 {
# check for at least version 4.7
contains(GCCVer,[0-3]\\.[0-9]+.*) {
error("At least GCC 4.6 is required.")
} else {
contains(GCCVer,4\\.[0-5].*) {
error("At least GCC 4.6 is required.")
} else {
contains(GCCVer,4\\.6.*) {
lessThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++0x
} else {
lessThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
}
}
}
}
}

# from https://github.com/qt/qtbase/blob/dev/mkspecs/features/qt_common.prf
Expand Down Expand Up @@ -308,28 +289,14 @@ macx-clang-libc++ {
# in Qt 4.8.7, objective-C misses the stdlib and macos version flags
QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
QMAKE_OBJECTIVE_CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
c++11 {
c++14 {
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++14
}
!c++14 {
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++11
}
}
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++17
}

macx-clang {
# in Qt 4.8.7, objective-C misses the stdlib and macos version flags
QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
QMAKE_OBJECTIVE_CXXFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
c++11 {
c++14 {
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++14
}
!c++14 {
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++11
}
}
QMAKE_OBJECTIVE_CXXFLAGS += -std=c++17
}

CONFIG(debug) {
Expand All @@ -344,11 +311,6 @@ CONFIG(debug) {
}
}

!macx {
# c++11 build fails on Snow Leopard 10.6 (see the macx section below)
#CONFIG += c++11
}

win32 {
#ofx needs WINDOWS def
#microsoft compiler needs _MBCS to compile with the multi-byte character set.
Expand Down Expand Up @@ -527,33 +489,16 @@ unix {
symbols_hidden_by_default.name = GCC_SYMBOLS_PRIVATE_EXTERN
symbols_hidden_by_default.value = YES
QMAKE_MAC_XCODE_SETTINGS += symbols_hidden_by_default
c++11 {
c++14 {
QMAKE_CXXFLAGS += -std=c++14
enable_cxx14.name = CLANG_CXX_LANGUAGE_STANDARD
enable_cxx14.value = c++14
QMAKE_MAC_XCODE_SETTINGS += enable_cxx14
}
!c++14 {
QMAKE_CXXFLAGS += -std=c++11
enable_cxx11.name = CLANG_CXX_LANGUAGE_STANDARD
enable_cxx11.value = c++0x
QMAKE_MAC_XCODE_SETTINGS += enable_cxx11
}
}
QMAKE_CXXFLAGS += -std=c++17
enable_cxx17.name = CLANG_CXX_LANGUAGE_STANDARD
enable_cxx17.value = c++17
QMAKE_MAC_XCODE_SETTINGS += enable_cxx17
}

*clang* {
QMAKE_CXXFLAGS += -ftemplate-depth-1024
QMAKE_CXXFLAGS_WARN_ON += -Wno-c++11-extensions
c++11 {
c++14 {
QMAKE_CXXFLAGS += -std=c++14
}
!c++14 {
QMAKE_CXXFLAGS += -std=c++11
}
}
QMAKE_CXXFLAGS += -std=c++17
}

# see http://clang.llvm.org/docs/AddressSanitizer.html and http://blog.qt.digia.com/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/
Expand Down
24 changes: 5 additions & 19 deletions libs.pri
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,8 @@ DEFINES += OPENMVG_NO_SERIALIZATION
# Use this to use OsiMskSolverInterface.cpp
#DEFINES += OPENMVG_HAVE_MOSEK

c++11 {
DEFINES += OPENMVG_STD_UNORDERED_MAP
DEFINES += OPENMVG_STD_SHARED_PTR
} else {
# Use boost::shared_ptr and boost::unordered_map
CONFIG += boost
DEFINES += OPENMVG_BOOST_UNORDERED_MAP
DEFINES += OPENMVG_BOOST_SHARED_PTR
DEFINES += OPENMVG_NO_UNIQUE_PTR
}
DEFINES += OPENMVG_STD_UNORDERED_MAP
DEFINES += OPENMVG_STD_SHARED_PTR

INCLUDEPATH += $$PWD/libs/openMVG/openMVG
INCLUDEPATH += $$PWD/libs/openMVG
Expand All @@ -85,15 +77,9 @@ openmp {
#If undefined, make sure to add to sources all the files in ceres/internal/ceres/generated
DEFINES += CERES_RESTRICT_SCHUR_SPECIALIZATION
DEFINES += WITH_LIBMV_GUARDED_ALLOC GOOGLE_GLOG_DLL_DECL= LIBMV_NO_FAST_DETECTOR=
c++11 {
DEFINES += CERES_STD_UNORDERED_MAP
DEFINES += CERES_STD_SHARED_PTR
} else {
# Use boost::shared_ptr and boost::unordered_map
CONFIG += boost
DEFINES += CERES_BOOST_SHARED_PTR
DEFINES += CERES_BOOST_UNORDERED_MAP
}
DEFINES += CERES_STD_UNORDERED_MAP
DEFINES += CERES_STD_SHARED_PTR

INCLUDEPATH += $$PWD/libs/ceres/config
INCLUDEPATH += $$PWD/libs/ceres/include
INCLUDEPATH += $$PWD/libs/ceres/internal
Expand Down
4 changes: 2 additions & 2 deletions tools/jenkins/build-natron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ if [ "$QT_VERSION_MAJOR" = 5 ]; then
rm Engine/Qt${QT_VERSION_MAJOR}/NatronEngine/* Gui/Qt${QT_VERSION_MAJOR}/NatronGui/* || true
SHIBOKEN_INCLUDE_PATHS="-I. -I./Engine -I./Global -Ilibs/OpenFX/include -I${UNIX_SDK_HOME}/include -I${QTDIR}/include -I${UNIX_PYTHON_HOME}/include/python${PYVER} -I${UNIX_PYTHON_HOME}/include/PySide2 -I${UNIX_PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/include"
SHIBOKEN_TYPESYSTEM_PATHS="-T${UNIX_PYTHON_HOME}/share/PySide2/typesystems -T${UNIX_PYTHON_HOME}/lib/python${PYVER}/site-packages/PySide2/typesystems"
shiboken2 --avoid-protected-hack --enable-pyside-extensions ${SHIBOKEN_INCLUDE_PATHS} ${SHIBOKEN_TYPESYSTEM_PATHS} --output-directory=Engine/Qt${QT_VERSION_MAJOR} Engine/Pyside2_Engine_Python.h Engine/typesystem_engine.xml
shiboken2 -std=c++17 --avoid-protected-hack --enable-pyside-extensions ${SHIBOKEN_INCLUDE_PATHS} ${SHIBOKEN_TYPESYSTEM_PATHS} --output-directory=Engine/Qt${QT_VERSION_MAJOR} Engine/Pyside2_Engine_Python.h Engine/typesystem_engine.xml

shiboken2 --avoid-protected-hack --enable-pyside-extensions ${SHIBOKEN_INCLUDE_PATHS} -I${QTDIR}/include/QtWidgets -I${QTDIR}/include/QtCore ${SHIBOKEN_TYPESYSTEM_PATHS} -T./Engine -T./Shiboken --output-directory=Gui/Qt${QT_VERSION_MAJOR} Gui/Pyside2_Gui_Python.h Gui/typesystem_natronGui.xml
shiboken2 -std=c++17 --avoid-protected-hack --enable-pyside-extensions ${SHIBOKEN_INCLUDE_PATHS} -I${QTDIR}/include/QtWidgets -I${QTDIR}/include/QtCore ${SHIBOKEN_TYPESYSTEM_PATHS} -T./Engine -T./Shiboken --output-directory=Gui/Qt${QT_VERSION_MAJOR} Gui/Pyside2_Gui_Python.h Gui/typesystem_natronGui.xml

tools/utils/runPostShiboken2.sh Engine/Qt${QT_VERSION_MAJOR}/NatronEngine natronengine
tools/utils/runPostShiboken2.sh Gui/Qt${QT_VERSION_MAJOR}/NatronGui natrongui
Expand Down
7 changes: 0 additions & 7 deletions tools/jenkins/build-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,10 @@ if [ "$BUILD_ARENA" = "1" ] && [ -d "$TMP_PATH/openfx-arena" ]; then
make -C Bundle lodepng.h
fi

CXX_ARENA="$CXX17"
# poppler >= 21.12 requires C++17
# https://github.com/NatronGitHub/openfx-arena/issues/23
if version_gt 21.12 "$(pkg-config --modversion poppler)"; then
CXX_ARENA="$CXX"
fi
env \
MINGW="${ISWIN:-}" \
LICENSE="$NATRON_LICENSE" \
${ARENA_FLAGS:-} \
CXX="$CXX_ARENA" \
CONFIG="${COMPILE_TYPE}" \
OPTFLAG="${OPTFLAG}" \
BITS="${BITS}" \
Expand Down
61 changes: 18 additions & 43 deletions tools/jenkins/compiler-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ set -e # Exit immediately if a command exits with a non-zero status
set -u # Treat unset variables as an error when substituting.
#set -x # Print commands and their arguments as they are executed.

STD14="c++14"
STD17="c++17"

# https://stackoverflow.com/a/42232124
if [ "$PKGOS" = "Windows" ]; then
STD14="gnu++14"
STD17="gnu++17"
fi

Expand Down Expand Up @@ -46,46 +44,33 @@ if [ "$PKGOS" = "OSX" ]; then
9|10|11|12)
# GXX should be an openmp-capable compiler (to compile CImg.ofx)

# older version, using clang-3.4
CC=clang-mp-3.4
CXX="clang++-mp-3.4 -std=c++14"
CXX17="clang++-mp-3.4 -std=c++1z"
# older version, using clang-5.0
CC=clang-mp-5.0
CXX="clang++-mp-5.0 -std=c++1z"
GXX=g++-mp-4.9
OBJECTIVE_CC=$CC
OBJECTIVE_CXX=$CXX
;;
*)
# newer OS X / macOS version link with libc++ and can use the system clang
CC=clang
CXX="clang++ -std=c++14"
CXX17="clang++ -std=c++1z"
CXX="clang++ -std=c++1z"
OBJECTIVE_CC=$CC
OBJECTIVE_CXX=$CXX
;;
esac
elif [ "$COMPILER" = "clang-omp" ]; then
# newer version (testing) using clang-4.0
CC=clang-mp-4.0
CXX="clang++-mp-4.0 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-4.0 -stdlib=libc++ -std=c++1z"
# newer version (testing) using clang
# if a recent clang-mp is available
if command -v clang-mp-6.0 >/dev/null 2>&1; then
CC=clang-mp-6.0
CXX="clang++-mp-6.0 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-6.0 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-6.0 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-5.0 >/dev/null 2>&1; then
CC=clang-mp-5.0
CXX="clang++-mp-5.0 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-5.0 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-4.0 >/dev/null 2>&1; then
CC=clang-mp-4.0
CXX="clang++-mp-4.0 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-4.0 -stdlib=libc++ -std=c++1z"
CXX="clang++-mp-5.0 -stdlib=libc++ -std=c++17"
elif command -v /usr/local/opt/llvm@11/bin/clang >/dev/null 2>&1; then
CC=/usr/local/opt/llvm@11/bin/clang
CXX="/usr/local/opt/llvm@11/bin/clang++ -std=c++14"
CXX17="/usr/local/opt/llvm@11/bin/clang++ -std=c++17"
CXX="/usr/local/opt/llvm@11/bin/clang++ -std=c++17"
fi
# clang > 7.0 sometimes chokes on building Universal CImg.ofx, probably because of #pragma omp atomic
#Undefined symbols for architecture i386:
Expand All @@ -98,40 +83,31 @@ if [ "$PKGOS" = "OSX" ]; then
*)
if command -v clang-mp-17 >/dev/null 2>&1; then
CC=clang-mp-17
CXX="clang++-mp-17 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-17 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-17 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-16 >/dev/null 2>&1; then
CC=clang-mp-16
CXX="clang++-mp-16 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-16 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-16 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-15 >/dev/null 2>&1; then
CC=clang-mp-15
CXX="clang++-mp-15 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-15 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-15 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-14 >/dev/null 2>&1; then
CC=clang-mp-14
CXX="clang++-mp-14 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-14 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-14 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-13 >/dev/null 2>&1; then
CC=clang-mp-13
CXX="clang++-mp-13 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-13 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-13 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-12 >/dev/null 2>&1; then
CC=clang-mp-12
CXX="clang++-mp-12 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-12 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-12 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-11 >/dev/null 2>&1; then
CC=clang-mp-11
CXX="clang++-mp-11 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-11 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-11 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-10 >/dev/null 2>&1; then
CC=clang-mp-10
CXX="clang++-mp-10 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-10 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-10 -stdlib=libc++ -std=c++17"
elif command -v clang-mp-9.0 >/dev/null 2>&1; then
CC=clang-mp-9.0
CXX="clang++-mp-9.0 -stdlib=libc++ -std=c++14"
CXX17="clang++-mp-9.0 -stdlib=libc++ -std=c++17"
CXX="clang++-mp-9.0 -stdlib=libc++ -std=c++17"
fi
;;
esac
Expand All @@ -152,7 +128,7 @@ if [ "$PKGOS" = "OSX" ]; then
#GCC_VERSION=5
#GCC_VERSION=6
CC=gcc-mp-${GCC_VERSION}
CXX="g++-mp-${GCC_VERSION} -std=c++14"
CXX="g++-mp-${GCC_VERSION} -std=c++17"
OBJECTIVE_CC=gcc-4.2
OBJECTIVE_CXX=g++-4.2
fi
Expand Down Expand Up @@ -211,8 +187,7 @@ fi

COMPILER=${COMPILER:-gcc}
CC=${CC:-gcc}
CXX=${CXX:-g++ -std=${STD14}}
CXX17=${CXX17:-g++ -std=${STD17}}
CXX=${CXX:-g++ -std=${STD17}}
OBJECTIVE_CC=${OBJECTIVE_CC:-${CC}}
OBJECTIVE_CXX=${OBJECTIVE_CXX:-${CXX}}

Expand Down

0 comments on commit b38d9d5

Please sign in to comment.