CMake: Clean up _qt_internal_finalize_batch
The _qt_internal_finalize_batch function had a bunch of problems, style-wise and function-wise: - it called find_package(Qt6) in its body, which broke when configuring qtbase with in-tree tests - it constantly rewrote the merged blacklist file on each reconfiguration - it used file(WRITE) to concatenate content - it was in the public API file The changes are: - Move the function to the internal test helpers file. - Change it to use qt_configure_file instead of file(WRITE). - Call it at the end of the qt_build_tests for a repo, or at the end of configuring a super build, instead of relying on a finalizer. - Remove the find_package call. The reason this was added in the first place, was to populate the __qt_core_macros_module_base_dir variable so that qt_internal_add_resource configure_file call doesn't fail in standalone tests build. The variable was unset because the finalized function was called in the top level directory scope, whereas the very first find_package call was in the tests/ scope, meaning the variable was empty. This is still a problem in the top-level build where the tests scope and the top-level scope are different. Work around it by relying on a global property to reset the value if it's empty. Amends 6a9e89121d7766a34c4281d298057bfbe8af36b3 Pick-to: 6.8 Change-Id: Id6fe41ee86d09b8118bea52cac8a59965d7ecb9e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
0ac8ab0d20
commit
c997e3bb8b
@ -69,6 +69,10 @@ macro(qt_internal_top_level_setup_no_create_targets)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(qt_internal_top_level_end)
|
macro(qt_internal_top_level_end)
|
||||||
|
if(QT_BUILD_TESTS)
|
||||||
|
qt_internal_finalize_test_batch_blacklist()
|
||||||
|
endif()
|
||||||
|
|
||||||
qt_internal_print_top_level_info()
|
qt_internal_print_top_level_info()
|
||||||
|
|
||||||
# Depends on QtBuildInternalsConfig being included, which is the case whenver any repo is
|
# Depends on QtBuildInternalsConfig being included, which is the case whenver any repo is
|
||||||
|
@ -783,6 +783,12 @@ macro(qt_build_tests)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT QT_SUPERBUILD)
|
||||||
|
# In a super build, we don't want to finalize the batch blacklist at the end of each repo,
|
||||||
|
# but rather once at the end of the top-level configuration.
|
||||||
|
qt_internal_finalize_test_batch_blacklist()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_UNITY_BUILD ${QT_UNITY_BUILD})
|
set(CMAKE_UNITY_BUILD ${QT_UNITY_BUILD})
|
||||||
unset(QT_INTERNAL_CONFIGURING_TESTS)
|
unset(QT_INTERNAL_CONFIGURING_TESTS)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
@ -825,10 +825,10 @@ function(qt_internal_add_test name)
|
|||||||
if(NOT blacklist_files)
|
if(NOT blacklist_files)
|
||||||
set_target_properties(${name} PROPERTIES _qt_blacklist_files "")
|
set_target_properties(${name} PROPERTIES _qt_blacklist_files "")
|
||||||
set(blacklist_files "")
|
set(blacklist_files "")
|
||||||
cmake_language(EVAL CODE "cmake_language(DEFER DIRECTORY \"${CMAKE_SOURCE_DIR}\" CALL \"_qt_internal_finalize_batch\" \"${name}\") ")
|
|
||||||
endif()
|
endif()
|
||||||
list(PREPEND blacklist_files "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}")
|
list(PREPEND blacklist_files "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}")
|
||||||
set_target_properties(${name} PROPERTIES _qt_blacklist_files "${blacklist_files}")
|
set_target_properties(${name} PROPERTIES
|
||||||
|
_qt_blacklist_files "${blacklist_files}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(blacklist_path "BLACKLIST")
|
set(blacklist_path "BLACKLIST")
|
||||||
@ -891,6 +891,35 @@ function(qt_internal_add_test name)
|
|||||||
qt_internal_add_test_finalizers("${name}")
|
qt_internal_add_test_finalizers("${name}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Generates a blacklist file for the global batched test target.
|
||||||
|
function(qt_internal_finalize_test_batch_blacklist)
|
||||||
|
_qt_internal_test_batch_target_name(batch_target_name)
|
||||||
|
if(NOT TARGET "${batch_target_name}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(generated_blacklist_file "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST")
|
||||||
|
|
||||||
|
set(final_contents "")
|
||||||
|
|
||||||
|
get_target_property(blacklist_files "${batch_target_name}" _qt_blacklist_files)
|
||||||
|
if(blacklist_files)
|
||||||
|
foreach(blacklist_file ${blacklist_files})
|
||||||
|
file(READ "${blacklist_file}" file_contents)
|
||||||
|
if(file_contents)
|
||||||
|
string(APPEND final_contents "${file_contents}\n")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
qt_configure_file(OUTPUT "${generated_blacklist_file}" CONTENT "${final_contents}")
|
||||||
|
|
||||||
|
qt_internal_add_resource(${batch_target_name} "batch_blacklist"
|
||||||
|
PREFIX "/"
|
||||||
|
FILES "${generated_blacklist_file}"
|
||||||
|
BASE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Given an optional test timeout value (specified via qt_internal_add_test's TIMEOUT option)
|
# Given an optional test timeout value (specified via qt_internal_add_test's TIMEOUT option)
|
||||||
# returns a percentage of the final timeout to be passed to the androidtestrunner executable.
|
# returns a percentage of the final timeout to be passed to the androidtestrunner executable.
|
||||||
#
|
#
|
||||||
|
@ -1715,6 +1715,7 @@ function(_qt_internal_android_create_runner_wrapper target)
|
|||||||
set(wrapper_path "${target_binary_dir}/${target}")
|
set(wrapper_path "${target_binary_dir}/${target}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
get_property(__qt_core_macros_module_base_dir GLOBAL PROPERTY __qt_core_macros_module_base_dir)
|
||||||
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
|
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
|
||||||
set(qt_core_configure_file_contents "${script_content}")
|
set(qt_core_configure_file_contents "${script_content}")
|
||||||
configure_file("${template_file}" "${wrapper_path}")
|
configure_file("${template_file}" "${wrapper_path}")
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
#
|
#
|
||||||
######################################
|
######################################
|
||||||
|
|
||||||
set(__qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
|
# Save the 'macros base dir' in a global property instead of a variable, to allow access in a
|
||||||
|
# deferred function where the variable might not be accessible by the function scope.
|
||||||
|
set_property(GLOBAL PROPERTY __qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
|
||||||
# macro used to create the names of output files preserving relative dirs
|
# macro used to create the names of output files preserving relative dirs
|
||||||
macro(_qt_internal_make_output_file infile prefix ext outfile )
|
macro(_qt_internal_make_output_file infile prefix ext outfile )
|
||||||
@ -780,26 +782,6 @@ function(_qt_internal_finalize_executable target)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(_cat IN_FILE OUT_FILE)
|
|
||||||
file(READ ${IN_FILE} CONTENTS)
|
|
||||||
file(APPEND ${OUT_FILE} "${CONTENTS}\n")
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(_qt_internal_finalize_batch name)
|
|
||||||
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core)
|
|
||||||
|
|
||||||
set(generated_blacklist_file "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST")
|
|
||||||
get_target_property(blacklist_files "${name}" _qt_blacklist_files)
|
|
||||||
file(WRITE "${generated_blacklist_file}" "")
|
|
||||||
foreach(blacklist_file ${blacklist_files})
|
|
||||||
_cat("${blacklist_file}" "${generated_blacklist_file}")
|
|
||||||
endforeach()
|
|
||||||
qt_internal_add_resource(${name} "batch_blacklist"
|
|
||||||
PREFIX "/"
|
|
||||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST"
|
|
||||||
BASE ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# If a task needs to run before any targets are finalized in the current directory
|
# If a task needs to run before any targets are finalized in the current directory
|
||||||
# scope, call this function and pass the ID of that task as the argument.
|
# scope, call this function and pass the ID of that task as the argument.
|
||||||
function(_qt_internal_delay_finalization_until_after defer_id)
|
function(_qt_internal_delay_finalization_until_after defer_id)
|
||||||
@ -2110,6 +2092,7 @@ function(__qt_internal_sanitize_resource_name out_var name)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(__qt_internal_generate_init_resource_source_file out_var target resource_name)
|
function(__qt_internal_generate_init_resource_source_file out_var target resource_name)
|
||||||
|
get_property(__qt_core_macros_module_base_dir GLOBAL PROPERTY __qt_core_macros_module_base_dir)
|
||||||
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreResourceInit.in.cpp")
|
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreResourceInit.in.cpp")
|
||||||
|
|
||||||
# Gets replaced in the template
|
# Gets replaced in the template
|
||||||
@ -2378,6 +2361,7 @@ function(_qt_internal_process_resource target resourceName)
|
|||||||
# </qresource></RCC>
|
# </qresource></RCC>
|
||||||
string(APPEND qrcContents " </qresource>\n</RCC>\n")
|
string(APPEND qrcContents " </qresource>\n</RCC>\n")
|
||||||
|
|
||||||
|
get_property(__qt_core_macros_module_base_dir GLOBAL PROPERTY __qt_core_macros_module_base_dir)
|
||||||
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
|
set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
|
||||||
set(qt_core_configure_file_contents "${qrcContents}")
|
set(qt_core_configure_file_contents "${qrcContents}")
|
||||||
configure_file("${template_file}" "${generatedResourceFile}")
|
configure_file("${template_file}" "${generatedResourceFile}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user