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. Fixes: QTBUG-109678 Change-Id: I81510f37eacb409eb5c03e3ff032926c3ca25a1f Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit c146d25a87bcb94ed4eefae749a96ed3550b7af2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4d5c470f1c
commit
6fc1214133
@ -1737,6 +1737,7 @@ function(_qt_internal_expose_deferred_files_to_ide target)
|
|||||||
list(APPEND new_sources_real ${realf})
|
list(APPEND new_sources_real ${realf})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(filtered_new_sources "")
|
||||||
get_target_property(target_source_dir ${target} SOURCE_DIR)
|
get_target_property(target_source_dir ${target} SOURCE_DIR)
|
||||||
get_filename_component(target_source_dir "${target_source_dir}" REALPATH)
|
get_filename_component(target_source_dir "${target_source_dir}" REALPATH)
|
||||||
get_target_property(existing_sources ${target} SOURCES)
|
get_target_property(existing_sources ${target} SOURCES)
|
||||||
@ -1747,25 +1748,28 @@ function(_qt_internal_expose_deferred_files_to_ide target)
|
|||||||
get_filename_component(realf "${f}" REALPATH BASE_DIR ${target_source_dir})
|
get_filename_component(realf "${f}" REALPATH BASE_DIR ${target_source_dir})
|
||||||
list(APPEND existing_sources_real ${realf})
|
list(APPEND existing_sources_real ${realf})
|
||||||
endforeach()
|
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()
|
endif()
|
||||||
if("${new_sources_real}" STREQUAL "")
|
if("${filtered_new_sources}" STREQUAL "")
|
||||||
return()
|
return()
|
||||||
endif()
|
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)
|
set(scope_args)
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||||
set(scope_args TARGET_DIRECTORY "${target}")
|
set(scope_args TARGET_DIRECTORY "${target}")
|
||||||
endif()
|
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()
|
endfunction()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user