From ffe088941378e32ea30c142cca7e63c537a41ff1 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 19 Sep 2019 13:46:37 +0200 Subject: Fix examples find_package calls to work in prefix builds To build examples as part of a non-installed Qt prefix build, not-yet-installed Config files need to be found by find_package() calls inside example projects. Facilitate that by propagating the CMAKE_PREFIX_PATH and QT_EXAMPLES_CMAKE_PREFIX_PATH paths in all relevant find_package() calls where NO_DEFAULT_PATH is used. Also adjust the inclusion of the QtFeature.cmake file to be relative to the qt6 directory, rather than the current list directory. This is needed to successfully find the file when parsing a Config file from a non-installed build directory. Change-Id: I36031279628f1f7741d8f4d7571484a6545227f7 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann --- cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmake/QtBuildInternals/QtBuildInternalsConfig.cmake') diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index e8002b5550..cfd11cd6f9 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -151,8 +151,13 @@ macro(qt_build_tests) endmacro() macro(qt_examples_build_begin) - # It is part of a Qt build => Use the CMake config files from the binary dir + # Examples that are built as part of the Qt build need to use the CMake config files from the + # build dir, because they are not installed yet in a prefix build. + # Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake. + # Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those + # find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored. list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") + list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") # Also make sure the CMake config files do not recreate the already-existing targets set(QT_NO_CREATE_TARGETS TRUE) set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) -- cgit v1.2.3