aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2022-06-25 15:27:39 +0200
committerFriedrich W. H. Kossebau <kossebau@kde.org>2022-06-25 15:30:06 +0200
commit0064cf77e96acda8a99c0eba4cc89f83768b65d3 (patch)
treed3b95582276f2910553de3d3c9d6de967c91d113
parent8687d6cb7a838ce619ca6aca97507cbaf5e3ce9c (diff)
downloadextra-cmake-modules-5.96.0-rc1.tar.gz
extra-cmake-modules-5.96.0-rc1.tar.bz2
ECMDeprecationSettings: enable warnings by defaultv5.96.0-rc1v5.96.0
The main target consumers of this macro currently (should) want to be informed about new deprecations as early as possible. As do the authors of the warnings. So instead let's make no warnings an opt-in. Not documenting the now deprecated flag in the docs, given no wide-spread use yet, just supporting still in the code with a note to users.
-rw-r--r--kde-modules/KDEFrameworkCompilerSettings.cmake6
-rw-r--r--modules/ECMDeprecationSettings.cmake24
2 files changed, 19 insertions, 11 deletions
diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake
index bbe38026..47a39aa8 100644
--- a/kde-modules/KDEFrameworkCompilerSettings.cmake
+++ b/kde-modules/KDEFrameworkCompilerSettings.cmake
@@ -57,12 +57,6 @@ endif()
# Current defaults
include(KDECompilerSettings NO_POLICY_SCOPE)
-# enable warnings for any deprecated Qt/KF API of current 5 series
-add_definitions(
- -DQT_DEPRECATED_WARNINGS_SINCE=0x060000
- -DKF_DEPRECATED_WARNINGS_SINCE=0x060000
-)
-
# add clang-format target
include(KDEClangFormat)
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.hpp *.c)
diff --git a/modules/ECMDeprecationSettings.cmake b/modules/ECMDeprecationSettings.cmake
index f46eaa37..6f8fe91e 100644
--- a/modules/ECMDeprecationSettings.cmake
+++ b/modules/ECMDeprecationSettings.cmake
@@ -21,12 +21,13 @@ This module provides the following function:
::
ecm_set_disabled_deprecation_versions(
- [SHOW_DEPRECATIONS]
+ [DISABLE_NEWER_WARNINGS] # since 5.96
[<identifier> <deprecation_version>]
[<identifier2> <deprecation_version2>]
)
-``SHOW_DEPRECATIONS`` if this option is used, deprecation warnings for the current major version are emitted.
+``DISABLE_NEWER_WARNINGS`` disables additionally the compiler warnings for API deprecated in newer versions
+of the same major version.
Example usage:
@@ -36,7 +37,7 @@ Example usage:
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.90")
- ecm_set_disabled_deprecation_versions(SHOW_DEPRECATIONS
+ ecm_set_disabled_deprecation_versions(
QT ${QT_MIN_VERSION}
KF ${KF5_MIN_VERSION}
KCOREADDONS 5.89.0 # In case we depend on deprecated KCoreAddons API
@@ -49,7 +50,20 @@ Since 5.91
function (ecm_set_disabled_deprecation_versions)
include(CMakeParseArguments)
- cmake_parse_arguments(ARGS "SHOW_DEPRECATIONS" "" "" ${ARGN})
+ cmake_parse_arguments(ARGS "SHOW_DEPRECATIONS;DISABLE_NEWER_WARNINGS" "" "" ${ARGN})
+
+ # support legacy initial flag to opt-in to warnings
+ if (ARGS_SHOW_DEPRECATIONS)
+ message(DEPRECATION "SHOW_DEPRECATIONS is deprecated, since 5.96 warnings are enabled by default.")
+ endif()
+ if (ARGS_SHOW_DEPRECATIONS AND ARGS_DISABLE_NEWER_WARNINGS)
+ message(FATAL_ERROR "SHOW_DEPRECATIONS && DISABLE_NEWER_WARNINGS cannot be set both.")
+ endif()
+ set(show_newer_warnings TRUE)
+ if (ARGS_DISABLE_NEWER_WARNINGS)
+ set(show_newer_warnings FALSE)
+ endif()
+
list(LENGTH ARGS_UNPARSED_ARGUMENTS PAIR_COUNT)
math(EXPR is_even_number "${PAIR_COUNT} % 2")
if (NOT is_even_number EQUAL 0)
@@ -83,7 +97,7 @@ function (ecm_set_disabled_deprecation_versions)
add_definitions(-D${DEPRECATION_DEFINITION_NAME}=${DEPRECATION_HEX_VERSION})
# Set the version for the deprecation warnings
- if (ARGS_SHOW_DEPRECATIONS)
+ if (show_newer_warnings)
string(REGEX MATCH "([0-9]+)\\." _ ${DEPRECATION_VERSION})
if (NOT CMAKE_MATCH_1)
message(FATAL_ERROR "Failed to get major version from ${DEPRECATION_VERSION}")