CMake: Fix exposing source files after target finalization
Calling _qt_internal_expose_source_file_to_ide after a target has already been finalized did run the function's fallback code for targets that are not finalized at all. That added the source files under a new ${target}_other_files target, which is a tad ugly in an IDE. A situation where this occurs is for instance: - qt_add_executable in a subdirectory - adding additional files (licenses, documentation, .ts files) to the "main" target in the top-level CMakeLists.txt The code flow is like this: - enter subdirectory - qt6_add_executable(foo) - leave subdirectory - qt6_finalize_target(foo) - calls _qt_internal_expose_deferred_files_to_ide(foo) - _qt_internal_expose_source_file_to_ide(foo bar.txt) - sees that the target does not need finalization and runs the fallback code Fix this by immediately running _qt_internal_expose_deferred_files_to_ide if a target was already finalized. Task-number: QTBUG-127052 Change-Id: I1eda9acd48442ba35c6c61d9a185f6ed9ed6307f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 469533fe8108cc56e90201919126502235c5cee6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4091f4ede0
commit
c359af7bfb
@ -2115,8 +2115,17 @@ endfunction()
|
||||
function(_qt_internal_expose_source_file_to_ide target file)
|
||||
get_target_property(target_expects_finalization ${target} _qt_expects_finalization)
|
||||
if(target_expects_finalization AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
|
||||
# The target is not yet finalized. The target finalizer will call the exposure function.
|
||||
set_property(TARGET ${target} APPEND PROPERTY _qt_deferred_files ${file})
|
||||
return()
|
||||
else()
|
||||
get_target_property(is_finalized "${target}" _qt_is_finalized)
|
||||
if(is_finalized)
|
||||
# The target already has been finalized. Run the exposure function immediately.
|
||||
set_property(TARGET ${target} APPEND PROPERTY _qt_deferred_files ${file})
|
||||
_qt_internal_expose_deferred_files_to_ide(${target})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Fallback for targets that are not finalized: Create fake target under which the file is added.
|
||||
|
Loading…
x
Reference in New Issue
Block a user