diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-01-13 15:14:03 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-01-16 12:11:50 +0100 |
commit | c146d25a87bcb94ed4eefae749a96ed3550b7af2 (patch) | |
tree | 074aea1278da5391fb4b5d7a190ccda2322c3854 /src | |
parent | 9ae91ac318009cd424465236c4f276df625c52ac (diff) |
CMake: Fix exposing sources with absolute path to IDE
_qt_internal_expose_deferred_files_to_ide must add the source files to
the target exactly as they were passed to
_qt_internal_expose_source_file_to_ide. Otherwise, CMake might be fooled
into thinking that we're adding a new file here, and source file
properties would not be readable.
Instead of back-calculating the relative paths from the absolute paths,
we use the already existing list of relative paths.
Pick-to: 6.5
Fixes: QTBUG-109678
Change-Id: I81510f37eacb409eb5c03e3ff032926c3ca25a1f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index dc5afae6c5..206ce8f21e 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1744,6 +1744,7 @@ function(_qt_internal_expose_deferred_files_to_ide target) list(APPEND new_sources_real ${realf}) endforeach() + set(filtered_new_sources "") get_target_property(target_source_dir ${target} SOURCE_DIR) get_filename_component(target_source_dir "${target_source_dir}" REALPATH) get_target_property(existing_sources ${target} SOURCES) @@ -1754,25 +1755,28 @@ function(_qt_internal_expose_deferred_files_to_ide target) get_filename_component(realf "${f}" REALPATH BASE_DIR ${target_source_dir}) list(APPEND existing_sources_real ${realf}) endforeach() - list(REMOVE_ITEM new_sources_real ${existing_sources_real}) + + list(LENGTH new_sources max_i) + math(EXPR max_i "${max_i} - 1") + foreach(i RANGE 0 ${max_i}) + list(GET new_sources_real ${i} realf) + if(NOT realf IN_LIST existing_sources_real) + list(GET new_sources ${i} f) + list(APPEND filtered_new_sources ${f}) + endif() + endforeach() endif() - if("${new_sources_real}" STREQUAL "") + if("${filtered_new_sources}" STREQUAL "") return() endif() - # Need to convert real paths back to relative paths because the use of absolute paths for these - # files causes invalid generation of build.ninja on Windows platforms. - set(new_sources "") - foreach(realf IN LISTS new_sources_real) - file(RELATIVE_PATH f "${target_source_dir}" "${realf}") - list(APPEND new_sources "${f}") - endforeach() - target_sources(${target} PRIVATE ${new_sources}) + target_sources(${target} PRIVATE ${filtered_new_sources}) set(scope_args) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") set(scope_args TARGET_DIRECTORY "${target}") endif() - set_source_files_properties(${new_sources} ${scope_args} PROPERTIES HEADER_FILE_ONLY ON) + set_source_files_properties(${filtered_new_sources} + ${scope_args} PROPERTIES HEADER_FILE_ONLY ON) endfunction() # |