From c9d498c1d165c23cb854a8fbe9482a9289029071 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 16 Jun 2020 01:51:34 +0200 Subject: [PATCH] cmake: Allow deprecation warnings In recent releases, Qt deprecated a whole bunch of APIs, probably in preparation of the advent of Qt 6. Unfortunately, avoiding those is not straightforward, since Quassel has to support a broad range of older Qt releases, and not all deprecated APIs are easy to replace in those older versions. Some APIs, such as bearer management, don't even have a replacement yet. Since Qt 5.13, deprecation warnings cannot be disabled at all. To avoid breaking the CI builds, make deprecation warnings non-fatal even if FATAL_WARNINGS is enabled. This allows us to remove the WARN_QT_DEPRECATION option, which only had an effect when building against Qt < 5.13 anyway, and unconditionally enable the warnings when compiling with GCC or Clang. For MSVC, disable deprecation warnings completely, since there seems to be no way to selectively make warnings non-fatal, and we still want to fail for anything other than deprecations. Disable the use of APIs completely that were deprecated in Qt 5.5 (our current baseline) or earlier to prevent accidental use. This threshold can be raised in the future as we can rely on newer Qt versions and modernize affected code. --- CMakeLists.txt | 15 ++++++++------- cmake/QuasselCompileSettings.cmake | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80040cfa..5a241dd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,11 +108,6 @@ endif() # The following options are not for end-user consumption, so don't list them in the feature summary option(FATAL_WARNINGS "Make compile warnings fatal (most useful for CI builds)" OFF) -option(WARN_QT_DEPRECATION "Warn about deprecated Qt functionality" OFF) -if (WARN_QT_DEPRECATION) - # Enable Qt deprecation warnings for Qt < 5.13 (on by default in newer versions) - add_definitions("-DQT_DEPRECATED_WARNINGS") -endif() cmake_dependent_option(DEPLOY "Add required libs to bundle resources and create a dmg" OFF "APPLE" OFF) # List of authenticators and the cmake flags to build them @@ -155,14 +150,20 @@ endif() # Set up Qt ##################################################################### +set(QT_MIN_VERSION "5.5.0") + +# Enable Qt deprecation warnings for Qt < 5.13 (on by default in newer versions) +add_definitions(-DQT_DEPRECATED_WARNINGS) + +# Disable all Qt APIs that were deprecated in 5.5 and before +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050500) + # Find package dependencies # # Note that you can forcefully disable optional packages # using -DCMAKE_DISABLE_FIND_PACKAGE_=TRUE ##################################################################### -set(QT_MIN_VERSION "5.5.0") - # Required Qt components set(qt_components Core Network) if (BUILD_GUI) diff --git a/cmake/QuasselCompileSettings.cmake b/cmake/QuasselCompileSettings.cmake index dd63566b..4493d4d2 100644 --- a/cmake/QuasselCompileSettings.cmake +++ b/cmake/QuasselCompileSettings.cmake @@ -45,6 +45,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") -Wvla -Werror=return-type "$<$:-Werror>" + -Wno-error=deprecated # Don't break on Qt upgrades -Wno-unknown-pragmas "$<$>:-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2>" ) @@ -91,6 +92,8 @@ elseif(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4456") # C4458: declaration of 'identifier' hides class member set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4458") + # C4996: deprecation warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # Link against the correct version of the C runtime set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") -- 2.20.1