Add -disable-deprecated-up-to parameter to configure script

And also teach CMake to treat it properly instead of hardcoding the
version number.

[ChangeLog][Build System] The configure script now accepts a new
parameter -disable-deprecated-up-to which is used to remove all
deprecated code from API and ABI while building the libraries.
The version number must be specified in a hex format.
For example, it can be used like this:
 /path/to/qt/configure -disable-deprecated-up-to 0x060500
to remove all code deprecated in Qt 6.5.0 or earlier releases.

Task-number: QTBUG-101510
Change-Id: I557cf83e29b867fa1052bb097985e144b5eaf34d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Ivan Solovev 2022-08-16 13:02:27 +02:00
parent 18f0484a0e
commit 2625a3a01a
5 changed files with 36 additions and 6 deletions

View File

@ -183,13 +183,17 @@ function(qt_internal_library_deprecation_level result)
# 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_UP_TO=0x040800")
if (NOT DEFINED QT_DISABLE_DEPRECATED_UP_TO)
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_UP_TO=0x040800")
else()
# On other platforms, Qt's own compilation does need to compile the Qt 5.0 API
list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=0x050000")
endif()
else()
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=0x050000")
list(APPEND deprecations "QT_DISABLE_DEPRECATED_UP_TO=${QT_DISABLE_DEPRECATED_UP_TO}")
endif()
# QT_WARN_DEPRECATED_UP_TO controls the upper-bound of deprecation
# warnings that are emitted. E.g. if it is set to 0x060500 then all use of

View File

@ -685,6 +685,11 @@ endif()\n")
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
"set(QT_EXTRA_RPATHS \"${QT_EXTRA_RPATHS}\" CACHE STRING \"\")\n")
endif()
if(DEFINED QT_DISABLE_DEPRECATED_UP_TO)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
"set(QT_DISABLE_DEPRECATED_UP_TO \"${QT_DISABLE_DEPRECATED_UP_TO}\""
" CACHE STRING \"\")\n")
endif()
# Save pkg-config feature value to be able to query it internally as soon as BuildInternals
# package is loaded. This is to avoid any pkg-config package from being found when

View File

@ -43,6 +43,12 @@ function(warn_in_per_repo_build arg)
endif()
endfunction()
function(is_valid_qt_hex_version arg version)
if(NOT version MATCHES "^0x[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$")
message(FATAL_ERROR "Incorrect version ${version} specified for ${arg}")
endif()
endfunction()
if("${MODULE_ROOT}" STREQUAL "")
# If MODULE_ROOT is not set, assume that we want to build qtbase or top-level.
get_filename_component(MODULE_ROOT ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
@ -125,6 +131,10 @@ while(NOT "${configure_args}" STREQUAL "")
set(cmake_file_api FALSE)
elseif(arg STREQUAL "-verbose")
list(APPEND cmake_args "--log-level=STATUS")
elseif(arg STREQUAL "-disable-deprecated-up-to")
list(POP_FRONT configure_args version)
is_valid_qt_hex_version("${arg}" "${version}")
push("-DQT_DISABLE_DEPRECATED_UP_TO=${version}")
elseif(arg STREQUAL "--")
# Everything after this argument will be passed to CMake verbatim.
list(APPEND cmake_args "${configure_args}")

View File

@ -169,3 +169,4 @@ The following table describes the mapping of configure options to CMake argument
| -libjpeg | -DFEATURE_libjpeg=ON | |
| -sql-<driver> | -DFEATURE_sql_<driver>=ON | |
| -sqlite [qt/system] | -DFEATURE_system_sqlite=OFF/ON | |
| -disable-deprecated-up-to <hex_version> | -DQT_DISABLE_DEPRECATED_UP_TO=<hex_version> | |

View File

@ -141,6 +141,16 @@ Build options:
-warnings-are-errors . Treat warnings as errors [no; yes if -developer-build]
-disable-deprecated-up-to <version>
Set the QT_DISABLE_DEPRECATED_UP_TO value to <version>.
QT_DISABLE_DEPRECATED_UP_TO is used to remove
deprecated methods from both API and ABI.
<version> is a hex value, for example 0x060500 can be
used to remove all code deprecated in Qt 6.5.0 or
earlier releases.
By default <version> is set to 0x040000 and 0x050000 on
Windows, and non-Windows respectively.
Build environment:
-sysroot <dir> ....... Set <dir> as the target sysroot