CMake: Deprecate some android public APIs
Deprecate usage of: - qt_android_add_apk_target - qt_android_apply_arch_suffix - qt_android_generate_deployment_settings when used by user projects directly. Instead, projects should use qt_add_executable / qt_add_library. Show a deprecation warning when the commands are used directly. The deprecation warnings can be silenced using cmake's -Wno-deprecated command line option. To detect non-direct usage from inside our own function implementations, we set some target properties which are then read to decide whether to show the message. Pick-to: 6.5 Fixes: QTBUG-108508 Change-Id: Ib039cc5f3a01c2276173abb1e43f4eed216d0170 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
5e00c0c5e5
commit
b43a39977b
@ -73,6 +73,17 @@ function(qt6_android_generate_deployment_settings target)
|
||||
_qt_is_android_generate_deployment_settings_called TRUE
|
||||
)
|
||||
|
||||
get_target_property(android_executable_finalizer_called
|
||||
${target} _qt_android_executable_finalizer_called)
|
||||
|
||||
if(android_executable_finalizer_called)
|
||||
# Don't show deprecation when called by our own function implementations.
|
||||
else()
|
||||
message(DEPRECATION
|
||||
"Calling qt_android_generate_deployment_settings directly is deprecated since Qt 6.5. "
|
||||
"Use qt_add_executable instead.")
|
||||
endif()
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
|
||||
if (NOT "${target_type}" STREQUAL "MODULE_LIBRARY")
|
||||
@ -327,6 +338,16 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
|
||||
endif()
|
||||
|
||||
function(qt6_android_apply_arch_suffix target)
|
||||
get_target_property(called_from_qt_impl
|
||||
${target} _qt_android_apply_arch_suffix_called_from_qt_impl)
|
||||
if(called_from_qt_impl)
|
||||
# Don't show deprecation when called by our own function implementations.
|
||||
else()
|
||||
message(DEPRECATION
|
||||
"Calling qt_android_apply_arch_suffix directly is deprecated since Qt 6.5. "
|
||||
"Use qt_add_executable or qt_add_library instead.")
|
||||
endif()
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if (target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
|
||||
set_property(TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.so")
|
||||
@ -349,6 +370,17 @@ function(qt6_android_add_apk_target target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(android_executable_finalizer_called
|
||||
${target} _qt_android_executable_finalizer_called)
|
||||
|
||||
if(android_executable_finalizer_called)
|
||||
# Don't show deprecation when called by our own function implementations.
|
||||
else()
|
||||
message(DEPRECATION
|
||||
"Calling qt_android_add_apk_target directly is deprecated since Qt 6.5. "
|
||||
"Use qt_add_executable instead.")
|
||||
endif()
|
||||
|
||||
get_target_property(deployment_file ${target} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
|
||||
if (NOT deployment_file)
|
||||
message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")
|
||||
@ -1198,6 +1230,8 @@ endfunction()
|
||||
# package for the executable 'target'. The function is added to the finalizer list of the Core
|
||||
# module and is executed implicitly when configuring user projects.
|
||||
function(_qt_internal_android_executable_finalizer target)
|
||||
set_property(TARGET ${target} PROPERTY _qt_android_executable_finalizer_called TRUE)
|
||||
|
||||
_qt_internal_configure_android_multiabi_target("${target}")
|
||||
qt6_android_generate_deployment_settings("${target}")
|
||||
qt6_android_add_apk_target("${target}")
|
||||
|
@ -580,6 +580,8 @@ function(_qt_internal_create_executable target)
|
||||
set_property(TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default)
|
||||
set_property(TARGET "${target}"
|
||||
PROPERTY _qt_android_apply_arch_suffix_called_from_qt_impl TRUE)
|
||||
qt6_android_apply_arch_suffix("${target}")
|
||||
set_property(TARGET "${target}" PROPERTY _qt_is_android_executable TRUE)
|
||||
else()
|
||||
@ -2282,6 +2284,8 @@ function(_qt_internal_add_library target)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set_property(TARGET "${target}"
|
||||
PROPERTY _qt_android_apply_arch_suffix_called_from_qt_impl TRUE)
|
||||
qt6_android_apply_arch_suffix("${target}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -13,7 +13,7 @@
|
||||
\include cmake-find-package-core.qdocinc
|
||||
|
||||
\cmakecommandsince 6.0
|
||||
\preliminarycmakecommand
|
||||
\warning This command is deprecated since Qt 6.5. Use \l qt_add_executable instead.
|
||||
\cmakecommandandroidonly
|
||||
|
||||
\section1 Synopsis
|
||||
|
@ -13,7 +13,8 @@
|
||||
\include cmake-find-package-core.qdocinc
|
||||
|
||||
\cmakecommandsince 6.0
|
||||
\preliminarycmakecommand
|
||||
\warning This command is deprecated since Qt 6.5. Use \l qt_add_executable
|
||||
or \l qt_add_library instead.
|
||||
\cmakecommandandroidonly
|
||||
|
||||
\section1 Synopsis
|
||||
|
@ -13,7 +13,7 @@
|
||||
\include cmake-find-package-core.qdocinc
|
||||
|
||||
\cmakecommandsince 6.0
|
||||
\preliminarycmakecommand
|
||||
\warning This command is deprecated since Qt 6.5. Use \l qt_add_executable instead.
|
||||
\cmakecommandandroidonly
|
||||
|
||||
\section1 Synopsis
|
||||
|
Loading…
Reference in New Issue
Block a user