From b954a79e25f15bbce499afaa4304e7ab71648cd5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 13 Aug 2021 13:50:48 +0200 Subject: [PATCH] CMake: Run export(EXPORT) for prefixed and top-level builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is necessary to be able to find Qt6 modules in CMake ExternalProjects before Qt is installed, regardless of top-level or per-repo builds. One use case is examples that are built as ExternalProjects. Pick-to: 6.2 6.3 Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: Ic6a9bfd1c52a04e34b221deab40f419a6fee9463 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Qt CI Bot Reviewed-by: Jörg Bornemann --- cmake/QtInstallHelpers.cmake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/QtInstallHelpers.cmake b/cmake/QtInstallHelpers.cmake index 50b2534fba2..97a2ecc1649 100644 --- a/cmake/QtInstallHelpers.cmake +++ b/cmake/QtInstallHelpers.cmake @@ -18,14 +18,18 @@ function(qt_install) install(${ARGV}) endif() - # Exit early if this is a prefix build. - if(QT_WILL_INSTALL) - return() - endif() - - # In a non-prefix build, when install(EXPORT) is called, - # also call export(EXPORT) to generate build tree target files. + # When install(EXPORT) is called, also call export(EXPORT) + # to generate build tree target files. if(NOT is_install_targets AND arg_EXPORT) + # For prefixed builds (both top-level and per-repo) export build tree CMake Targets files so + # they can be used in CMake ExternalProjects. One such case is examples built as + # ExternalProjects as part of the Qt build. + # In a top-level build the exported config files are placed under qtbase/lib/cmake. + # In a per-repo build, they will be placed in each repo's build dir/lib/cmake. + if(QT_WILL_INSTALL) + qt_path_join(arg_DESTINATION "${QT_BUILD_DIR}" "${arg_DESTINATION}") + endif() + set(namespace_option "") if(arg_NAMESPACE) set(namespace_option NAMESPACE ${arg_NAMESPACE})