From 8155bd54261688f333b2d68e2d76f0fc076a0fb4 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 18 Nov 2022 09:54:45 +0100 Subject: [PATCH] Avoid converting paths to relative for headersclean comment if they are relative When calling file (RELATIVE_PATH), check if the base directory and header path are absolute. Use the original file path if the paths are relative to avoid critical errors. Fixes: QTBUG-108617 Change-Id: I6daddd5c1553cdbfd965650b7c469673c62f0a3d Reviewed-by: Alexandru Croitor Reviewed-by: Thiago Macieira Reviewed-by: Amir Masoud Abdol --- cmake/QtHeadersClean.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/QtHeadersClean.cmake b/cmake/QtHeadersClean.cmake index cda874eade9..5fc257913fe 100644 --- a/cmake/QtHeadersClean.cmake +++ b/cmake/QtHeadersClean.cmake @@ -241,12 +241,18 @@ function(qt_internal_add_headersclean_target module_target module_headers) get_filename_component(input_file_name ${input_path} NAME) set(artifact_path "${CMAKE_CURRENT_BINARY_DIR}/header_check/${input_file_name}.o") + unset(input_base_dir) if(input_path MATCHES "${CMAKE_BINARY_DIR}") set(input_base_dir "${CMAKE_BINARY_DIR}") elseif(input_path MATCHES "${CMAKE_SOURCE_DIR}") set(input_base_dir "${CMAKE_SOURCE_DIR}") endif() - file(RELATIVE_PATH comment_header_path "${input_base_dir}" "${input_path}") + + if(input_base_dir AND IS_ABSOLUTE "${input_base_dir}" AND IS_ABSOLUTE "${input_path}") + file(RELATIVE_PATH comment_header_path "${input_base_dir}" "${input_path}") + else() + set(comment_header_path "${input_path}") + endif() add_custom_command( OUTPUT "${artifact_path}"