Use the relative header path when checking if it's 3rdparty

If source or build directry contain '3rdparty' in their path, all
header files are marked as 3rdparty and will never be installed.
This commit is CMake counterpart of
ea4a3d78a776e10955caf6cf9b1054ddb50f40d3

Amends ea4a3d78a776e10955caf6cf9b1054ddb50f40d3

Fixes: QTBUG-116137
Pick-to: 6.5 6.6
Change-Id: Ib93fb879867e3aeb6e44193c4253e73173c141d2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2023-08-16 17:01:23 +02:00
parent bc0c44d4cd
commit 7544d91ae1

View File

@ -1238,10 +1238,13 @@ function(qt_internal_collect_module_headers out_var target)
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
set(source_dir "${CMAKE_CURRENT_SOURCE_DIR}")
set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}")
else()
get_target_property(source_dir ${target} SOURCE_DIR)
get_target_property(binary_dir ${target} BINARY_DIR)
endif()
get_filename_component(source_dir "${source_dir}" ABSOLUTE)
get_filename_component(binary_dir "${binary_dir}" ABSOLUTE)
get_target_property(is_3rdparty_library ${target} _qt_module_is_3rdparty_header_library)
@ -1285,7 +1288,14 @@ function(qt_internal_collect_module_headers out_var target)
"\nCondition:\n ${condition_string}")
endif()
if(file_path MATCHES "3rdparty/.+" AND NOT is_3rdparty_library)
if(is_outside_module_source_dir)
set(base_dir "${binary_dir}")
else()
set(base_dir "${source_dir}")
endif()
file(RELATIVE_PATH file_path_rel "${base_dir}" "${file_path}")
if(file_path_rel MATCHES "3rdparty/.+" AND NOT is_3rdparty_library)
set(is_3rdparty_header TRUE)
else()
set(is_3rdparty_header FALSE)