From b09d081fe44278b49ac1d6660b8195fc04045c34 Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 24 Apr 2024 17:27:26 +0200 Subject: [PATCH] Enable C++17 by default when building against Qt 6 (#1825) * Enable C++17 by default when building against Qt 6 * Streamline compiler options * Get rid of LTO in MSVC release builds --- .github/workflows/ci.yml | 1 - util/common.pri | 34 ++++++++++------------------------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd7be4bd7..e340cc808 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,7 +94,6 @@ jobs: run: mkdir build; ${{runner.os == 'Linux' && matrix.qt == 6 && 'qmake6' || 'qmake'}} -o build PREFIX=/usr CONFIG-=debug_and_release CONFIG+=release CONFIG+=GIT CONFIG+=PENCIL2D_${{github.ref == 'refs/heads/release' && 'RELEASE' || 'NIGHTLY'}} - ${{matrix.qt == 6 && 'CONFIG+=c++17 QMAKE_CXX_FLAGS+=-std=c++17' || ''}} - name: Build Pencil2D working-directory: build diff --git a/util/common.pri b/util/common.pri index 9157507c3..c43024f71 100644 --- a/util/common.pri +++ b/util/common.pri @@ -11,39 +11,25 @@ PENCIL2D_RELEASE { DEFINES += PENCIL2D_RELEASE_BUILD } -CONFIG += c++11 - -win32-g++ { - QMAKE_CXXFLAGS += -std=c++11 +CONFIG += strict_c strict_c++ +greaterThan(QT_MAJOR_VERSION, 5) { + CONFIG += c++17 +} else { + CONFIG += c++11 } -win32-msvc* { - QMAKE_CXXFLAGS += /MP /utf-8 - CONFIG(release,debug|release) { - QMAKE_CXXFLAGS += /Gy /GL - CONFIG += ltcg - CONFIG += force_debug_info - } -} +# utf8_source is only for Qt 5, it is the default since Qt 6 +CONFIG += msvc_mp utf8_source +win32-msvc*:CONFIG(release,debug|release): CONFIG += force_debug_info +win32:!WIN_LEGACY: DEFINES += _WIN32_WINNT=0x0601 WIN_LEGACY { - QMAKE_CXXFLAGS -= /utf-8 QMAKE_LFLAGS += /SUBSYSTEM:CONSOLE,5.01 QMAKE_CXX += /D_USING_V110_SDK71_ DEFINES += _WIN32_WINNT=0x0501 } -win32:!WIN_LEGACY: DEFINES += _WIN32_WINNT=0x0601 -macx { - QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ - LIBS += -lobjc -framework Carbon -framework AppKit -} - -unix:!macx { - QMAKE_CXXFLAGS += -std=c++11 - QMAKE_LINK = $$QMAKE_CXX - QMAKE_LINK_SHLIB = $$QMAKE_CXX -} +macx: LIBS += -lobjc -framework Carbon -framework AppKit # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings