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>
This commit is contained in:
parent
9ae91ac318
commit
c146d25a87
@ -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()
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user