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.

Pick-to: 6.5 6.6
Change-Id: Ic048760390174d1be2f01096d70e84458f1c870f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2023-11-15 13:41:04 +01:00
parent 3d58715e6f
commit 1c82e92202
3 changed files with 53 additions and 65 deletions

View File

@ -284,27 +284,6 @@ macro(qt_build_internals_set_up_private_api)
qt_check_if_tools_will_be_built() qt_check_if_tools_will_be_built()
endmacro() 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 # add toplevel targets for each subdirectory, e.g. qtbase_src
function(qt_build_internals_add_toplevel_targets) function(qt_build_internals_add_toplevel_targets)
set(qt_repo_target_all "") set(qt_repo_target_all "")
@ -312,7 +291,7 @@ function(qt_build_internals_add_toplevel_targets)
foreach(directory IN LISTS directories) foreach(directory IN LISTS directories)
set(qt_repo_targets "") set(qt_repo_targets "")
get_filename_component(qt_repo_target_basename ${directory} NAME) 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) if (qt_repo_targets)
set(qt_repo_target_name "${qt_repo_targets_name}_${qt_repo_target_basename}") set(qt_repo_target_name "${qt_repo_targets_name}_${qt_repo_target_basename}")
message(DEBUG "${qt_repo_target_name} depends on ${qt_repo_targets}") message(DEBUG "${qt_repo_target_name} depends on ${qt_repo_targets}")
@ -828,6 +807,17 @@ macro(qt_build_tests)
endif() endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/manual/CMakeLists.txt" AND QT_BUILD_MANUAL_TESTS) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/manual/CMakeLists.txt" AND QT_BUILD_MANUAL_TESTS)
add_subdirectory(manual) 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()
endif() endif()
@ -1022,26 +1012,8 @@ macro(qt_examples_build_end)
# sure we do not fail on a fresh Qt build (e.g. the moc binary won't exist # 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). # yet because it is created at build time).
# This function gets all targets below this directory (excluding custom targets and aliases) _qt_internal_collect_buildsystem_targets(targets
function(get_all_targets _result _dir) "${CMAKE_CURRENT_SOURCE_DIR}" EXCLUDE UTILITY ALIAS)
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}")
foreach(target ${targets}) foreach(target ${targets})
qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "rcc") qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "rcc")

View File

@ -91,3 +91,40 @@ function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
endforeach() endforeach()
set("${out_var}" "${result}" PARENT_SCOPE) set("${out_var}" "${result}" PARENT_SCOPE)
endfunction() 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()

View File

@ -640,7 +640,8 @@ function(_qt_internal_collect_apk_dependencies)
get_property(apk_targets GLOBAL PROPERTY _qt_apk_targets) 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) list(REMOVE_DUPLICATES libs)
if(NOT TARGET qt_internal_plugins) if(NOT TARGET qt_internal_plugins)
@ -669,28 +670,6 @@ function(_qt_internal_collect_apk_dependencies)
) )
endfunction() 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 # 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 # the main apk targets. The actual collection is deferred until the target's directory scope
# is processed. # is processed.