summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-07-26 15:51:02 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-28 07:28:44 +0000
commit1a01b62f4218f0fcf5be7682e789f678a3c910dc (patch)
tree408238c33ec8ad2d80fbd859f5d060a0fd2e08d2 /cmake
parenteee2246f3aa6fbcfa2b8a2e179e6b45c0d299f26 (diff)
CMake: Fix install destination of in-tree examples
Previously we called _qt_internal_override_example_install_dir_to_dot in Qt6CoreConfigExtras.cmake as part of a find_package(Qt6 COMPONENTS Core) call, and we assumed that the Extras file would always be included in each example project. But our package dependencies handling code skips calling find_package(Qt6Core) if Qt6Core_FOUND is already set to TRUE, which will definitely happen due to root-scope find_package calls when configuring other repos. That means we wouldn't override INSTALL_EXAMPLEDIR to "." and the install destination would end up being something like ${CMAKE_INSTALL_PREFIX}/example_relative_path/example_relative_path aka a double nested path. Make sure we call the _qt_internal_override_example_install_dir_to_dot function in Qt6ConfigConfig.cmake in addition to Qt6CoreConfig.cmake. That way, even if Qt6Core is skipped during dependency resolution, it's still handled by the Qt6 package itself. Because the function is defined in the Core package, guard the call with an if(COMMAND) and only call the function if it wasn't previously called within the current or ancestor scopes. Amends ac4a913f333561803003650817de453f43be924d Fixes: QTBUG-102879 Change-Id: Id47e3ce06faec6d156ae1473942dae0f9b90cb46 Reviewed-by: Christophe Giboudeaux <christophe@krop.fr> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 0e0352ab4d38ca31bb8e488783e35c2f8955e540) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtConfig.cmake.in6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
index 925da8fc22..722ac15923 100644
--- a/cmake/QtConfig.cmake.in
+++ b/cmake/QtConfig.cmake.in
@@ -253,6 +253,12 @@ if(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS AND _Qt_NOTFOUND_MESSAGE)
unset(_Qt_NOTFOUND_MESSAGE)
endif()
+if(@INSTALL_CMAKE_NAMESPACE@_FOUND
+ AND COMMAND _qt_internal_override_example_install_dir_to_dot
+ AND NOT _qt_internal_example_dir_set_to_dot)
+ _qt_internal_override_example_install_dir_to_dot()
+endif()
+
__qt_internal_defer_promote_targets_in_dir_scope_to_global()
if(CMAKE_VERSION VERSION_LESS 3.21)
__qt_internal_check_link_order_matters()