Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TO

The new name describes the behavior in a better way.

[ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is
renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but
is still recognized if it is defined during configuration and the new
name is not defined.

Task-number: QTBUG-104944
Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Ivan Solovev 2022-08-16 12:26:25 +02:00
parent b9baa42b62
commit 3226c82740
29 changed files with 65 additions and 50 deletions

View File

@ -180,16 +180,16 @@ function(qt_internal_apply_intel_cet target visibility)
endfunction()
function(qt_internal_library_deprecation_level result)
# QT_DISABLE_DEPPRECATED_BEFORE controls which version we use as a cut-off
# QT_DISABLE_DEPRECATED_UP_TO controls which version we use as a cut-off
# compiling in to the library. E.g. if it is set to QT_VERSION then no
# code which was deprecated before QT_VERSION will be compiled in.
if(WIN32)
# On Windows, due to the way DLLs work, we need to export all functions,
# including the inlines
list(APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x040800")
list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=0x040800")
else()
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
list(APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x050000")
list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=0x050000")
endif()
# QT_DEPRECATED_WARNINGS_SINCE controls the upper-bound of deprecation
# warnings that are emitted. E.g. if it is set to 7.0 then all deprecations

View File

@ -321,7 +321,7 @@ ProjectGenerator::writeMakefile(QTextStream &t)
"# Please consult the documentation of the deprecated API in order to know\n"
"# how to port your code away from it.\n"
"# You can also select to disable deprecated APIs only up to a certain version of Qt.\n"
"#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0\n\n";
"#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier\n\n";
t << "# Input" << "\n";
t << getWritableVar("HEADERS")

View File

@ -1527,23 +1527,33 @@ bool qSharedBuild() noexcept
*/
/*!
\macro QT_DISABLE_DEPRECATED_BEFORE
\relates <QtGlobal>
\macro QT_DISABLE_DEPRECATED_BEFORE
\relates <QtGlobal>
\deprecated [6.5] Use QT_DISABLE_DEPRECATED_UP_TO instead
This macro can be defined in the project file to disable functions deprecated in
a specified version of Qt or any earlier version. The default version number is 5.0,
meaning that functions deprecated in or before Qt 5.0 will not be included.
For instance, when preparing to upgrade to Qt 6.3, setting
\c{QT_DISABLE_DEPRECATED_BEFORE=0x0602ff} will disable functions deprecated in
Qt 6.2 and earlier, making it easy to find changes worth making before the
upgrade. In any release, set \c{QT_DISABLE_DEPRECATED_BEFORE=0x000000} to
enable all functions, including the ones deprecated in Qt 5.0 (although most
of those have by now been removed entirely).
\sa QT_DEPRECATED_WARNINGS
\sa QT_DISABLE_DEPRECATED_UP_TO
*/
/*!
\macro QT_DISABLE_DEPRECATED_UP_TO
\relates <QtGlobal>
This macro can be defined in the project file to disable functions
deprecated in a specified version of Qt or any earlier version. The default
version number is 5.0, meaning that functions deprecated in or before
Qt 5.0 will not be included.
For instance, when preparing to upgrade to Qt 6.3, after eliminating all
deprecation warnings, you can set \c{QT_DISABLE_DEPRECATED_UP_TO=0x060300}
to exclude from your builds the Qt APIs you no longer use. In your own
project's build configuration, this will ensure that anyone adding new calls
to the deprecated APIs will know about it right away. If you also build Qt
for yourself, including this define in your build configuration for Qt will
make your binaries smaller by leaving out even the implementation of the
deprecated APIs.
\sa QT_DEPRECATED_WARNINGS, QT_DISABLE_DEPRECATED_BEFORE
*/
/*!
\macro QT_DEPRECATED_WARNINGS

View File

@ -36,16 +36,21 @@ QT_BEGIN_NAMESPACE
# define Q_DECL_ENUMERATOR_DEPRECATED
#endif
// If the deprecated macro is defined, use its value
#if !defined(QT_DISABLE_DEPRECATED_UP_TO) && defined(QT_DISABLE_DEPRECATED_BEFORE)
# define QT_DISABLE_DEPRECATED_UP_TO QT_DISABLE_DEPRECATED_BEFORE
#endif
#ifndef QT_DEPRECATED_WARNINGS_SINCE
# ifdef QT_DISABLE_DEPRECATED_BEFORE
# define QT_DEPRECATED_WARNINGS_SINCE QT_DISABLE_DEPRECATED_BEFORE
# ifdef QT_DISABLE_DEPRECATED_UP_TO
# define QT_DEPRECATED_WARNINGS_SINCE QT_DISABLE_DEPRECATED_UP_TO
# else
# define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION
# endif
#endif
#ifndef QT_DISABLE_DEPRECATED_BEFORE
#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(5, 0, 0)
#ifndef QT_DISABLE_DEPRECATED_UP_TO
#define QT_DISABLE_DEPRECATED_UP_TO QT_VERSION_CHECK(5, 0, 0)
#endif
/*
@ -61,7 +66,7 @@ QT_BEGIN_NAMESPACE
*/
#ifdef QT_DEPRECATED
#define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
#define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_UP_TO)
#else
#define QT_DEPRECATED_SINCE(major, minor) 0
#endif
@ -186,7 +191,7 @@ QT_BEGIN_NAMESPACE
/*
QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) expands to
\a whenTrue if the specified (\a major, \a minor) version is less than or
equal to the deprecation version defined by QT_DISABLE_DEPRECATED_BEFORE,
equal to the deprecation version defined by QT_DISABLE_DEPRECATED_UP_TO,
and to \a whenFalse otherwise.
Currently used for QT_INLINE_SINCE(maj, min), but can also be helpful for

View File

@ -21,12 +21,12 @@ set_target_properties(qlogging_helper PROPERTIES CXX_VISIBILITY_PRESET default)
qt_internal_add_test(tst_qlogging SOURCES tst_qlogging.cpp
DEFINES
QT_MESSAGELOGCONTEXT
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper"
)
qt_internal_add_test(tst_qmessagelogger SOURCES tst_qmessagelogger.cpp
DEFINES
QT_MESSAGELOGCONTEXT
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
)

View File

@ -10,7 +10,7 @@
qt_internal_add_executable(qdir
GUI
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::Gui
)

View File

@ -1,3 +1,3 @@
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0

View File

@ -12,7 +12,7 @@ qt_internal_add_test(tst_qabstractitemmodel
../../../other/qabstractitemmodelutils/dynamictreemodel.cpp ../../../other/qabstractitemmodelutils/dynamictreemodel.h
tst_qabstractitemmodel.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
INCLUDE_DIRECTORIES
../../../other/qabstractitemmodelutils
LIBRARIES

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qabstractproxymodel
SOURCES
tst_qabstractproxymodel.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::Gui
Qt::TestPrivate

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qsfpm_recursive
SOURCES
tst_qsortfilterproxymodel_recursive.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::Gui
)

View File

@ -44,7 +44,7 @@ qt_internal_add_test(tst_qmetatype
tst_qmetatype.h tst_qmetatype.cpp tst_qmetatype2.cpp
tst_qmetatype3.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
INCLUDE_DIRECTORIES
../../../other/qvariant_common
LIBRARIES

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qobject
SOURCES
tst_qobject.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::CorePrivate
Qt::Network

View File

@ -17,7 +17,7 @@ qt_internal_add_test(tst_qvariant
SOURCES
tst_qvariant.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
INCLUDE_DIRECTORIES
../../../other/qvariant_common
LIBRARIES

View File

@ -9,7 +9,7 @@ qt_internal_add_test(tst_qlatin1stringview
SOURCES
tst_qlatin1stringview.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
QT_NO_CAST_TO_ASCII
)

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qstring
SOURCES
tst_qstring.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::CorePrivate
)

View File

@ -27,7 +27,7 @@ qt_internal_add_test(tst_qguiapplication
../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case
tst_qguiapplication.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0x050E00
QT_DISABLE_DEPRECATED_UP_TO=0x050E00
QT_QGUIAPPLICATIONTEST=1
INCLUDE_DIRECTORIES
../../../corelib/kernel/qcoreapplication

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qmatrixnxn
SOURCES
tst_qmatrixnxn.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::Gui
)

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qdesktopservices
SOURCES
tst_qdesktopservices.cpp
DEFINES
# QT_DISABLE_DEPRECATED_BEFORE=0 # special case
# QT_DISABLE_DEPRECATED_UP_TO=0 # special case
LIBRARIES
Qt::Gui
)

View File

@ -19,7 +19,7 @@ qt_internal_add_test(tst_macnativeevents
qnativeevents_mac.cpp
tst_macnativeevents.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
${FWAppKit}
Qt::Gui

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qheaderview
SOURCES
tst_qheaderview.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::CorePrivate
Qt::Gui

View File

@ -13,7 +13,7 @@ qt_internal_add_manual_test(qt_on_cocoa
main.mm
rasterwindow.cpp rasterwindow.h
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
${FWAppKit}
Qt::Gui

View File

@ -8,4 +8,4 @@ LIBS += -framework AppKit
QT += gui widgets quick
QT += quick
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0

View File

@ -12,7 +12,7 @@ qt_internal_add_manual_test(tst_network_stresstest
minihttpserver.cpp minihttpserver.h
tst_network_stresstest.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES
Qt::CorePrivate
Qt::NetworkPrivate

View File

@ -11,4 +11,4 @@ HEADERS += \
RESOURCES += wwwfiles.qrc
QMAKE_RESOURCE_FLAGS += -no-compress
LIBS += $$QMAKE_LIBS_NETWORK
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0

View File

@ -6,7 +6,7 @@ CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier
SOURCES += \
main.cpp \

View File

@ -18,7 +18,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier
SOURCES += \

View File

@ -14,7 +14,7 @@ qt_internal_add_manual_test(windowchildgeometry
controllerwidget.cpp controllerwidget.h
main.cpp
DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0
QT_DISABLE_DEPRECATED_UP_TO=0
INCLUDE_DIRECTORIES
../windowflags
LIBRARIES

View File

@ -6,4 +6,4 @@ INCLUDEPATH += ../windowflags
SOURCES += $$PWD/main.cpp controllerwidget.cpp ../windowflags/controls.cpp
HEADERS += controllerwidget.h ../windowflags/controls.h
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0

View File

@ -10,7 +10,7 @@ QMAKE_USE += gtk3
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier
# Input
SOURCES += gtk-container.cpp