From ec20fd6cabdd9f414c5a7a85cfd8c3b6e3405eae Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 11 Dec 2025 16:35:20 +0100 Subject: [PATCH] init-repository: Fix passing relative path to --alternates When using --alternates with a relative path, nested submodules (e.g., qtdeclarative/tests/auto/qml/ecmascripttests/test262) failed because the alternates path wasn't adjusted for the changed working directory depth. The --alternates option worked correctly with absolute paths. Fix by converting the passed alternates path to an absolute path. Pick-to: 6.10 6.8 Fixes: QTBUG-142712 Change-Id: Ief7a87768d9ff17bb2832ae363f573ecae58d5ee Reviewed-by: Alexandru Croitor (cherry picked from commit d6918d7ac516ff6cb72a99197a58cc182375916a) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtIRCommandLineHelpers.cmake | 14 ++++++++++++++ cmake/QtIRHelpers.cmake | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/QtIRCommandLineHelpers.cmake b/cmake/QtIRCommandLineHelpers.cmake index d3569dd7..b932fcdf 100644 --- a/cmake/QtIRCommandLineHelpers.cmake +++ b/cmake/QtIRCommandLineHelpers.cmake @@ -421,3 +421,17 @@ function(qt_ir_get_option_as_cmake_flag_option cli_name cmake_option_name out_va endif() set(${out_var} "${cmake_option}" PARENT_SCOPE) endfunction() + +# Get the value of a command line option as existing absolute path. +# Yield error if the path does not exist. +# Convert to absolute path if necessary. +function(qt_ir_get_option_as_existing_absolute_path name value) + qt_ir_get_option_value("${name}" path) + if(NOT EXISTS "${abspath}") + qt_ir_add_error("The path '${path}' passed with -${name} does not exist.") + endif() + if(NOT IS_ABSOLUTE "${path}") + get_filename_component(path "${path}" ABSOLUTE) + endif() + set("${value}" "${path}" PARENT_SCOPE) +endfunction() diff --git a/cmake/QtIRHelpers.cmake b/cmake/QtIRHelpers.cmake index c305ae80..c4d8b7f2 100644 --- a/cmake/QtIRHelpers.cmake +++ b/cmake/QtIRHelpers.cmake @@ -295,7 +295,7 @@ function(qt_ir_run_after_args_parsed top_level_src_path out_var_exit_reason) "${working_directory}") # Get some additional options to pass down. - qt_ir_get_option_value(alternates alternates) + qt_ir_get_option_as_existing_absolute_path(alternates alternates) qt_ir_get_option_as_cmake_flag_option(branch "CHECKOUT_BRANCH" checkout_branch_option) # The prefix for the cmake-style 'dictionary' that will be used by various functions.