summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <[email protected]>2025-08-05 16:30:41 +0200
committerJoerg Bornemann <[email protected]>2025-08-13 10:39:31 +0200
commit9e6e621029389214867e5e3d7c92145889f0c490 (patch)
tree204319e5749bdcc26e00067864cbb8deca5cbb34
parent262316d1ce2d27fc17eb20af3f742ac16952f671 (diff)
CMake: Don't install incomplete Qt6BundledFoo packages
Assume a prefix build and a qt_internal_add_3rdparty_library(BundledFoo) call without passing INSTALL. Then we installed a Qt6BundledFooDependencies.cmake even though installation for this package was not requested. This happened, because we create the dependencies file in the post-processing step which didn't have knowledge whether INSTALL was passed or not. The code solely relied on the QT_WILL_INSTALL variable. We now let qt_internal_add_3rdparty_library and qt_internal_add_module set a target property _qt_will_install on created targets. This property specifies whether installation is requested for that target. In the post-processing step we read that target property. Pick-to: 6.10 Fixes: QTBUG-138580 Change-Id: I7f0df6242e0ab7b433cab4e4e2850e99e67c85a7 Reviewed-by: Alexandru Croitor <[email protected]>
-rw-r--r--cmake/Qt3rdPartyLibraryHelpers.cmake1
-rw-r--r--cmake/QtModuleHelpers.cmake6
-rw-r--r--cmake/QtPostProcessHelpers.cmake13
3 files changed, 15 insertions, 5 deletions
diff --git a/cmake/Qt3rdPartyLibraryHelpers.cmake b/cmake/Qt3rdPartyLibraryHelpers.cmake
index fb41ded3150..19fd8551d11 100644
--- a/cmake/Qt3rdPartyLibraryHelpers.cmake
+++ b/cmake/Qt3rdPartyLibraryHelpers.cmake
@@ -263,6 +263,7 @@ function(qt_internal_add_3rdparty_library target)
else()
set(will_install FALSE)
endif()
+ set_target_properties("${target}" PROPERTIES _qt_will_install ${will_install})
if(will_install)
qt_generate_3rdparty_lib_pri_file("${target}" "${arg_QMAKE_LIB_NAME}" pri_file)
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index e9b1989c460..bab68c86d19 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -257,6 +257,9 @@ function(qt_internal_add_module target)
set_property(TARGET ${target} APPEND PROPERTY EXPORT_PROPERTIES _qt_is_header_module)
endif()
+ # Record whether the target will be installed. We don't have to export this property.
+ set_target_properties(${target} PROPERTIES _qt_will_install "${QT_WILL_INSTALL}")
+
if(NOT arg_CONFIG_MODULE_NAME)
set(arg_CONFIG_MODULE_NAME "${module_lower}")
endif()
@@ -354,6 +357,9 @@ function(qt_internal_add_module target)
set_property(TARGET "${target_private}" APPEND PROPERTY
EXPORT_PROPERTIES "${export_properties}")
+ # Record whether the target will be installed. We don't have to export this property.
+ set_target_properties(${target_private} PROPERTIES _qt_will_install "${QT_WILL_INSTALL}")
+
# Let find_package(Qt6FooPrivate) also find_package(Qt6Foo).
qt_internal_register_target_dependencies("${target_private}" PUBLIC "Qt::${target}")
endif()
diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake
index 07fcdee268b..68502ad23a7 100644
--- a/cmake/QtPostProcessHelpers.cmake
+++ b/cmake/QtPostProcessHelpers.cmake
@@ -318,11 +318,14 @@ function(qt_internal_create_module_depends_file target)
@ONLY
)
- qt_install(FILES
- "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
- DESTINATION "${config_install_dir}"
- COMPONENT Devel
- )
+ get_target_property(will_install "${target}" _qt_will_install)
+ if(will_install)
+ qt_install(FILES
+ "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+ endif()
message(TRACE "Recorded dependencies for module: ${target}\n"
" Qt dependencies: ${target_deps}\n"