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() endfunction()
function(qt_internal_library_deprecation_level result) 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 # 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. # code which was deprecated before QT_VERSION will be compiled in.
if(WIN32) if(WIN32)
# On Windows, due to the way DLLs work, we need to export all functions, # On Windows, due to the way DLLs work, we need to export all functions,
# including the inlines # including the inlines
list(APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x040800") list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=0x040800")
else() else()
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API # 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() endif()
# QT_DEPRECATED_WARNINGS_SINCE controls the upper-bound of deprecation # 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 # 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" "# Please consult the documentation of the deprecated API in order to know\n"
"# how to port your code away from it.\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" "# 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 << "# Input" << "\n";
t << getWritableVar("HEADERS") t << getWritableVar("HEADERS")

View File

@ -1527,23 +1527,33 @@ bool qSharedBuild() noexcept
*/ */
/*! /*!
\macro QT_DISABLE_DEPRECATED_BEFORE \macro QT_DISABLE_DEPRECATED_BEFORE
\relates <QtGlobal> \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 \sa QT_DISABLE_DEPRECATED_UP_TO
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
*/ */
/*!
\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 \macro QT_DEPRECATED_WARNINGS

View File

@ -36,16 +36,21 @@ QT_BEGIN_NAMESPACE
# define Q_DECL_ENUMERATOR_DEPRECATED # define Q_DECL_ENUMERATOR_DEPRECATED
#endif #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 #ifndef QT_DEPRECATED_WARNINGS_SINCE
# ifdef QT_DISABLE_DEPRECATED_BEFORE # ifdef QT_DISABLE_DEPRECATED_UP_TO
# define QT_DEPRECATED_WARNINGS_SINCE QT_DISABLE_DEPRECATED_BEFORE # define QT_DEPRECATED_WARNINGS_SINCE QT_DISABLE_DEPRECATED_UP_TO
# else # else
# define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION # define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION
# endif # endif
#endif #endif
#ifndef QT_DISABLE_DEPRECATED_BEFORE #ifndef QT_DISABLE_DEPRECATED_UP_TO
#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(5, 0, 0) #define QT_DISABLE_DEPRECATED_UP_TO QT_VERSION_CHECK(5, 0, 0)
#endif #endif
/* /*
@ -61,7 +66,7 @@ QT_BEGIN_NAMESPACE
*/ */
#ifdef QT_DEPRECATED #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 #else
#define QT_DEPRECATED_SINCE(major, minor) 0 #define QT_DEPRECATED_SINCE(major, minor) 0
#endif #endif
@ -186,7 +191,7 @@ QT_BEGIN_NAMESPACE
/* /*
QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) expands to QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) expands to
\a whenTrue if the specified (\a major, \a minor) version is less than or \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. and to \a whenFalse otherwise.
Currently used for QT_INLINE_SINCE(maj, min), but can also be helpful for 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 qt_internal_add_test(tst_qlogging SOURCES tst_qlogging.cpp
DEFINES DEFINES
QT_MESSAGELOGCONTEXT QT_MESSAGELOGCONTEXT
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper" HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper"
) )
qt_internal_add_test(tst_qmessagelogger SOURCES tst_qmessagelogger.cpp qt_internal_add_test(tst_qmessagelogger SOURCES tst_qmessagelogger.cpp
DEFINES DEFINES
QT_MESSAGELOGCONTEXT QT_MESSAGELOGCONTEXT
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
) )

View File

@ -10,7 +10,7 @@
qt_internal_add_executable(qdir qt_internal_add_executable(qdir
GUI GUI
DEFINES DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES LIBRARIES
Qt::Gui 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 ../../../other/qabstractitemmodelutils/dynamictreemodel.cpp ../../../other/qabstractitemmodelutils/dynamictreemodel.h
tst_qabstractitemmodel.cpp tst_qabstractitemmodel.cpp
DEFINES DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
../../../other/qabstractitemmodelutils ../../../other/qabstractitemmodelutils
LIBRARIES LIBRARIES

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ qt_internal_add_test(tst_qstring
SOURCES SOURCES
tst_qstring.cpp tst_qstring.cpp
DEFINES DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES LIBRARIES
Qt::CorePrivate 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 ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case
tst_qguiapplication.cpp tst_qguiapplication.cpp
DEFINES DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0x050E00 QT_DISABLE_DEPRECATED_UP_TO=0x050E00
QT_QGUIAPPLICATIONTEST=1 QT_QGUIAPPLICATIONTEST=1
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
../../../corelib/kernel/qcoreapplication ../../../corelib/kernel/qcoreapplication

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,4 +8,4 @@ LIBS += -framework AppKit
QT += gui widgets quick QT += gui widgets quick
QT += 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 minihttpserver.cpp minihttpserver.h
tst_network_stresstest.cpp tst_network_stresstest.cpp
DEFINES DEFINES
QT_DISABLE_DEPRECATED_BEFORE=0 QT_DISABLE_DEPRECATED_UP_TO=0
LIBRARIES LIBRARIES
Qt::CorePrivate Qt::CorePrivate
Qt::NetworkPrivate Qt::NetworkPrivate

View File

@ -11,4 +11,4 @@ HEADERS += \
RESOURCES += wwwfiles.qrc RESOURCES += wwwfiles.qrc
QMAKE_RESOURCE_FLAGS += -no-compress QMAKE_RESOURCE_FLAGS += -no-compress
LIBS += $$QMAKE_LIBS_NETWORK 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. # You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line. # 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 += \ SOURCES += \
main.cpp \ 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. # You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line. # 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. # 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 += \ SOURCES += \

View File

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

View File

@ -6,4 +6,4 @@ INCLUDEPATH += ../windowflags
SOURCES += $$PWD/main.cpp controllerwidget.cpp ../windowflags/controls.cpp SOURCES += $$PWD/main.cpp controllerwidget.cpp ../windowflags/controls.cpp
HEADERS += controllerwidget.h ../windowflags/controls.h 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 # Please consult the documentation of the deprecated API in order to know
# how to port your code away from it. # how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt. # 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 # Input
SOURCES += gtk-container.cpp SOURCES += gtk-container.cpp