Ensure versionless wrappers do not introduce a new variable scope

Using function instead of macro prevented the wrappers from being able
to pass back any variables set in the wrapped function. In some cases,
these variables were being explicitly passed back to the caller, but
that isn't needed if you just make each wrapper a macro. This also
makes things more future-proof because any newly introduced output
variables will work without having to update the wrappers.

Task-number: QTBUG-96121
Pick-to: 6.2
Change-Id: Ic4486de668694c06b47e466587b2cdcb969ea047
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Craig Scott 2021-08-31 15:56:00 +10:00
parent d54d91c0ad
commit 08180e76e6
4 changed files with 60 additions and 69 deletions

View File

@ -262,9 +262,9 @@ function(qt6_android_generate_deployment_settings target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_android_generate_deployment_settings)
macro(qt_android_generate_deployment_settings)
qt6_android_generate_deployment_settings(${ARGV})
endfunction()
endmacro()
endif()
function(qt6_android_apply_arch_suffix target)
@ -277,9 +277,9 @@ function(qt6_android_apply_arch_suffix target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_android_apply_arch_suffix)
macro(qt_android_apply_arch_suffix)
qt6_android_apply_arch_suffix(${ARGV})
endfunction()
endmacro()
endif()
# Add custom target to package the APK
@ -397,7 +397,7 @@ function(_qt_internal_create_global_apk_all_target_if_needed)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_android_add_apk_target)
macro(qt_android_add_apk_target)
qt6_android_add_apk_target(${ARGV})
endfunction()
endmacro()
endif()

View File

@ -164,13 +164,13 @@ function(qt6_generate_moc infile outfile )
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_generate_moc)
macro(qt_generate_moc)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_generate_moc(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_generate_moc(${ARGV})
endif()
endfunction()
endmacro()
endif()
@ -203,14 +203,13 @@ endfunction()
# This will override the CMake upstream command, because that one is for Qt 3.
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_wrap_cpp outfiles)
macro(qt_wrap_cpp)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_wrap_cpp("${outfiles}" ${ARGN})
qt5_wrap_cpp(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_wrap_cpp("${outfiles}" ${ARGN})
qt6_wrap_cpp(${ARGV})
endif()
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()
@ -291,13 +290,13 @@ function(qt6_add_binary_resources target )
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_binary_resources)
macro(qt_add_binary_resources)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_binary_resources(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_binary_resources(${ARGV})
endif()
endfunction()
endmacro()
endif()
@ -349,16 +348,13 @@ function(qt6_add_resources outfiles )
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_resources outfiles)
macro(qt_add_resources)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_resources("${outfiles}" ${ARGN})
qt5_add_resources(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_resources("${outfiles}" ${ARGN})
qt6_add_resources(${ARGV})
endif()
if(NOT TARGET ${outfiles})
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
endif()
endfunction()
endmacro()
endif()
@ -427,14 +423,13 @@ function(qt6_add_big_resources outfiles )
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_big_resources outfiles)
macro(qt_add_big_resources)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_big_resources(${outfiles} ${ARGN})
qt5_add_big_resources(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_big_resources(${outfiles} ${ARGN})
qt6_add_big_resources(${ARGV})
endif()
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()
function(_qt_internal_apply_win_prefix_and_suffix target)
@ -778,17 +773,17 @@ function(_qt_internal_finalize_ios_app target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_executable)
macro(qt_add_executable)
qt6_add_executable(${ARGV})
endfunction()
function(qt_finalize_target)
endmacro()
macro(qt_finalize_target)
qt6_finalize_target(${ARGV})
endfunction()
endmacro()
# Kept for compatibility with Qt Creator 4.15 wizards
function(qt_finalize_executable)
macro(qt_finalize_executable)
qt6_finalize_target(${ARGV})
endfunction()
endmacro()
endif()
function(_qt_get_plugin_name_with_version target out_var)
@ -898,13 +893,13 @@ function(qt6_import_plugins target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_import_plugins)
macro(qt_import_plugins)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_import_plugins(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_import_plugins(${ARGV})
endif()
endfunction()
endmacro()
endif()
# This function is currently in Technical Preview. It's signature may change or be removed entirely.
@ -951,9 +946,9 @@ function(qt6_set_finalizer_mode target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_set_finalizer_mode)
macro(qt_set_finalizer_mode)
qt6_set_finalizer_mode(${ARGV})
endfunction()
endmacro()
endif()
# Extracts metatypes from a Qt target and generates a metatypes.json for it.
@ -1232,9 +1227,9 @@ function(qt6_extract_metatypes target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_extract_metatypes)
macro(qt_extract_metatypes)
qt6_extract_metatypes(${ARGV})
endfunction()
endmacro()
endif()
# Generate Win32 RC files for a target. All entries in the RC file are generated
@ -1982,9 +1977,9 @@ function(qt6_add_plugin target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_plugin)
macro(qt_add_plugin)
qt6_add_plugin(${ARGV})
endfunction()
endmacro()
endif()
# Creates a library by forwarding arguments to add_library, applies some Qt naming file name naming
@ -2084,9 +2079,9 @@ function(_qt_internal_add_library target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_library)
macro(qt_add_library)
qt6_add_library(${ARGV})
endfunction()
endmacro()
endif()
# By default Qt6 forces usage of utf8 sources for consumers of Qt.
@ -2097,9 +2092,9 @@ function(qt6_allow_non_utf8_sources target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_allow_non_utf8_sources)
macro(qt_allow_non_utf8_sources)
qt6_allow_non_utf8_sources(${ARGV})
endfunction()
endmacro()
endif()
function(_qt_internal_apply_strict_cpp target)
@ -2197,7 +2192,7 @@ function(qt6_disable_unicode_defines target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_disable_unicode_defines)
macro(qt_disable_unicode_defines)
qt6_disable_unicode_defines(${ARGV})
endfunction()
endmacro()
endif()

View File

@ -76,14 +76,13 @@ function(qt6_add_dbus_interface _sources _interface _basename)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_dbus_interface sources)
macro(qt_add_dbus_interface)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_dbus_interface("${sources}" ${ARGN})
qt5_add_dbus_interface(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_dbus_interface("${sources}" ${ARGN})
qt6_add_dbus_interface(${ARGV})
endif()
set("${sources}" "${${sources}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()
@ -100,14 +99,13 @@ function(qt6_add_dbus_interfaces _sources)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_dbus_interfaces sources)
macro(qt_add_dbus_interfaces)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_dbus_interfaces("${sources}" ${ARGN})
qt5_add_dbus_interfaces(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_dbus_interfaces("${sources}" ${ARGN})
qt6_add_dbus_interfaces(${ARGV})
endif()
set("${sources}" "${${sources}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()
@ -145,13 +143,13 @@ function(qt6_generate_dbus_interface _header) # _customName OPTIONS -some -optio
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_generate_dbus_interface)
macro(qt_generate_dbus_interface)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_generate_dbus_interface(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_generate_dbus_interface(${ARGV})
endif()
endfunction()
endmacro()
endif()
@ -203,12 +201,11 @@ function(qt6_add_dbus_adaptor _sources _xml_file _include) # _optionalParentClas
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_dbus_adaptor sources)
macro(qt_add_dbus_adaptor)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_add_dbus_adaptor("${sources}" ${ARGN})
qt5_add_dbus_adaptor(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_add_dbus_adaptor("${sources}" ${ARGN})
qt6_add_dbus_adaptor(${ARGV})
endif()
set("${sources}" "${${sources}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()

View File

@ -70,12 +70,11 @@ endfunction()
# This will override the CMake upstream command, because that one is for Qt 3.
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_wrap_ui outfiles)
macro(qt_wrap_ui)
if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
qt5_wrap_ui("${outfiles}" ${ARGN})
qt5_wrap_ui(${ARGV})
elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
qt6_wrap_ui("${outfiles}" ${ARGN})
qt6_wrap_ui(${ARGV})
endif()
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
endfunction()
endmacro()
endif()