summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <[email protected]>2023-11-15 13:41:04 +0100
committerQt Cherry-pick Bot <[email protected]>2023-11-17 06:57:02 +0000
commitf100430e8f26664246b8771c96295ac5c2c386c3 (patch)
treef50f823c068384e43e3a7945c488b35d8092c69c
parentc6a7c1b5e5235be369ec641fbd79035dc416c5eb (diff)
Make sure we initialize moc rcc and uic for manual test targets
If manual test target is created using the standard Qt API but not qt_internal_add_manual_test command, we need initialize autotools for these targets. Add the generic functionality that ensures that autotools are inialized for all manual tests. Change-Id: Ic048760390174d1be2f01096d70e84458f1c870f Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Alexandru Croitor <[email protected]> (cherry picked from commit 1c82e92202c8c359872c08095670c121602094b8) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit 5e5e5911e0d338bdc48391819667aaccb40a8a00)
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake56
-rw-r--r--cmake/QtPublicCMakeHelpers.cmake37
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake25
3 files changed, 53 insertions, 65 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index 9a31882a7c9..997141a7f45 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -263,27 +263,6 @@ macro(qt_build_internals_set_up_private_api)
qt_check_if_tools_will_be_built()
endmacro()
-# find all targets defined in $subdir by recursing through all added subdirectories
-# populates $qt_repo_targets with a ;-list of non-UTILITY targets
-macro(qt_build_internals_get_repo_targets subdir)
- get_directory_property(_targets DIRECTORY "${subdir}" BUILDSYSTEM_TARGETS)
- if(_targets)
- foreach(_target IN LISTS _targets)
- get_target_property(_type ${_target} TYPE)
- if(NOT ${_type} STREQUAL "UTILITY")
- list(APPEND qt_repo_targets "${_target}")
- endif()
- endforeach()
- endif()
-
- get_directory_property(_directories DIRECTORY "${subdir}" SUBDIRECTORIES)
- if (_directories)
- foreach(_directory IN LISTS _directories)
- qt_build_internals_get_repo_targets("${_directory}")
- endforeach()
- endif()
-endmacro()
-
# add toplevel targets for each subdirectory, e.g. qtbase_src
function(qt_build_internals_add_toplevel_targets)
set(qt_repo_target_all "")
@@ -291,7 +270,7 @@ function(qt_build_internals_add_toplevel_targets)
foreach(directory IN LISTS directories)
set(qt_repo_targets "")
get_filename_component(qt_repo_target_basename ${directory} NAME)
- qt_build_internals_get_repo_targets("${directory}")
+ _qt_internal_collect_buildsystem_targets(qt_repo_targets "${directory}" EXCLUDE UTILITY)
if (qt_repo_targets)
set(qt_repo_target_name "${qt_repo_targets_name}_${qt_repo_target_basename}")
message(DEBUG "${qt_repo_target_name} depends on ${qt_repo_targets}")
@@ -752,6 +731,17 @@ macro(qt_build_tests)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/manual/CMakeLists.txt" AND QT_BUILD_MANUAL_TESTS)
add_subdirectory(manual)
+ # Adding this logic to all tests impacts the configure time ~3sec in addition. We still
+ # might want this in the future for other test types since currently we have a moderate
+ # subset of tests that require manual initialization of autotools.
+ _qt_internal_collect_buildsystem_targets(targets
+ "${CMAKE_CURRENT_SOURCE_DIR}/manual" EXCLUDE UTILITY ALIAS)
+ foreach(target ${targets})
+ qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "rcc")
+ if(TARGET Qt::Widgets)
+ qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "uic")
+ endif()
+ endforeach()
endif()
endif()
@@ -946,26 +936,8 @@ macro(qt_examples_build_end)
# sure we do not fail on a fresh Qt build (e.g. the moc binary won't exist
# yet because it is created at build time).
- # This function gets all targets below this directory (excluding custom targets and aliases)
- function(get_all_targets _result _dir)
- get_property(_subdirs DIRECTORY "${_dir}" PROPERTY SUBDIRECTORIES)
- foreach(_subdir IN LISTS _subdirs)
- get_all_targets(${_result} "${_subdir}")
- endforeach()
- get_property(_sub_targets DIRECTORY "${_dir}" PROPERTY BUILDSYSTEM_TARGETS)
- set(_real_targets "")
- if(_sub_targets)
- foreach(__target IN LISTS _sub_targets)
- get_target_property(target_type ${__target} TYPE)
- if(NOT target_type STREQUAL "UTILITY" AND NOT target_type STREQUAL "ALIAS")
- list(APPEND _real_targets ${__target})
- endif()
- endforeach()
- endif()
- set(${_result} ${${_result}} ${_real_targets} PARENT_SCOPE)
- endfunction()
-
- get_all_targets(targets "${CMAKE_CURRENT_SOURCE_DIR}")
+ _qt_internal_collect_buildsystem_targets(targets
+ "${CMAKE_CURRENT_SOURCE_DIR}" EXCLUDE UTILITY ALIAS)
foreach(target ${targets})
qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "rcc")
diff --git a/cmake/QtPublicCMakeHelpers.cmake b/cmake/QtPublicCMakeHelpers.cmake
index 2e469da8cbf..d2af1180a15 100644
--- a/cmake/QtPublicCMakeHelpers.cmake
+++ b/cmake/QtPublicCMakeHelpers.cmake
@@ -91,3 +91,40 @@ function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
endforeach()
set("${out_var}" "${result}" PARENT_SCOPE)
endfunction()
+
+# This function gets all targets below this directory
+#
+# Multi-value Arguments:
+# EXCLUDE list of target types that should be filtered from resulting list.
+#
+# INCLUDE list of target types that should be filtered from resulting list.
+# EXCLUDE has higher priority than INCLUDE.
+function(_qt_internal_collect_buildsystem_targets result dir)
+ cmake_parse_arguments(arg "" "" "EXCLUDE;INCLUDE" ${ARGN})
+
+ set(forward_args "")
+ if(arg_EXCLUDE)
+ set(forward_args APPEND EXCLUDE ${arg_EXCLUDE})
+ endif()
+
+ if(arg_INCLUDE)
+ set(forward_args APPEND INCLUDE ${arg_INCLUDE})
+ endif()
+
+ get_property(subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES)
+ foreach(subdir IN LISTS subdirs)
+ _qt_internal_collect_buildsystem_targets(${result} "${subdir}" ${forward_args})
+ endforeach()
+ get_property(sub_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS)
+ set(real_targets "")
+ if(sub_targets)
+ foreach(target IN LISTS sub_targets)
+ get_target_property(target_type ${target} TYPE)
+ if((NOT arg_INCLUDE OR target_type IN_LIST arg_INCLUDE) AND
+ (NOT arg_EXCLUDE OR (NOT target_type IN_LIST arg_EXCLUDE)))
+ list(APPEND real_targets ${target})
+ endif()
+ endforeach()
+ endif()
+ set(${result} ${${result}} ${real_targets} PARENT_SCOPE)
+endfunction()
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 9a44308a0f6..a337f1ed66c 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -640,7 +640,8 @@ function(_qt_internal_collect_apk_dependencies)
get_property(apk_targets GLOBAL PROPERTY _qt_apk_targets)
- _qt_internal_collect_buildsystem_shared_libraries(libs "${CMAKE_SOURCE_DIR}")
+ _qt_internal_collect_buildsystem_targets(libs
+ "${CMAKE_SOURCE_DIR}" INCLUDE SHARED_LIBRARY MODULE_LIBRARY)
list(REMOVE_DUPLICATES libs)
if(NOT TARGET qt_internal_plugins)
@@ -669,28 +670,6 @@ function(_qt_internal_collect_apk_dependencies)
)
endfunction()
-# This function recursively walks the current directory and its subdirectories to collect shared
-# library targets built in those directories.
-function(_qt_internal_collect_buildsystem_shared_libraries out_var subdir)
- set(result "")
- get_directory_property(buildsystem_targets DIRECTORY ${subdir} BUILDSYSTEM_TARGETS)
- foreach(buildsystem_target IN LISTS buildsystem_targets)
- if(buildsystem_target AND TARGET ${buildsystem_target})
- get_target_property(target_type ${buildsystem_target} TYPE)
- if(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
- list(APPEND result ${buildsystem_target})
- endif()
- endif()
- endforeach()
-
- get_directory_property(subdirs DIRECTORY "${subdir}" SUBDIRECTORIES)
- foreach(dir IN LISTS subdirs)
- _qt_internal_collect_buildsystem_shared_libraries(result_inner "${dir}")
- endforeach()
- list(APPEND result ${result_inner})
- set(${out_var} "${result}" PARENT_SCOPE)
-endfunction()
-
# This function collects all imported shared libraries that might be dependencies for
# the main apk targets. The actual collection is deferred until the target's directory scope
# is processed.