cmake: Allow deprecation warnings
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 15 Jun 2020 23:51:34 +0000 (01:51 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 18 Jun 2020 19:43:46 +0000 (21:43 +0200)
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
cmake/QuasselCompileSettings.cmake

index 80040cf..5a241dd 100644 (file)
@@ -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)
 
 # 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
 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 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_<PkgName>=TRUE
 #####################################################################
 
 # Find package dependencies
 #
 # Note that you can forcefully disable optional packages
 # using -DCMAKE_DISABLE_FIND_PACKAGE_<PkgName>=TRUE
 #####################################################################
 
-set(QT_MIN_VERSION "5.5.0")
-
 # Required Qt components
 set(qt_components Core Network)
 if (BUILD_GUI)
 # Required Qt components
 set(qt_components Core Network)
 if (BUILD_GUI)
index dd63566..4493d4d 100644 (file)
@@ -45,6 +45,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
         -Wvla
         -Werror=return-type
         "$<$<BOOL:${FATAL_WARNINGS}>:-Werror>"
         -Wvla
         -Werror=return-type
         "$<$<BOOL:${FATAL_WARNINGS}>:-Werror>"
+        -Wno-error=deprecated  # Don't break on Qt upgrades
         -Wno-unknown-pragmas
         "$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2>"
     )
         -Wno-unknown-pragmas
         "$<$<NOT:$<CONFIG:Debug>>:-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")
     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}")
 
     # Link against the correct version of the C runtime
     set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")