From 0c38013c71f28015e00b29852a2f20f40aab65c8 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 6 Mar 2024 15:12:33 +0100 Subject: [PATCH] CMake: Adjust CMAKE_MODULE_PATH for ExternalProject examples When building EP examples for a repo that defines a bundled library, we need to make sure the relevant FindWrapBundledFooConfigExtra.cmake file is found when looking up dependencies. For a prefix build, that file is placed in the build dir of the repo. Use the list of qt_prefixes that includes the build dir of the repo, append lib/cmake/Qt6 to it and pass that as additional values to the CMAKE_MODULE_PATH variable of the external project. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: I85d5f360380856fcfb8be7235b8365dcf15aa0c0 Reviewed-by: Alexey Edelev (cherry picked from commit 31c5d50e84b210843ccdec58a86c4fce3125b679) Reviewed-by: Alexey Edelev --- cmake/QtBuildRepoExamplesHelpers.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/QtBuildRepoExamplesHelpers.cmake b/cmake/QtBuildRepoExamplesHelpers.cmake index 9c243a104db..da8a44e4d0d 100644 --- a/cmake/QtBuildRepoExamplesHelpers.cmake +++ b/cmake/QtBuildRepoExamplesHelpers.cmake @@ -306,6 +306,12 @@ function(qt_internal_add_example_external_project subdir) endif() endif() + # We we need to augment the CMAKE_MODULE_PATH with the current repo cmake build dir, to find + # files like FindWrapBundledFooConfigExtra.cmake. + set(module_paths "${qt_prefixes}") + list(TRANSFORM module_paths APPEND "/${INSTALL_LIBDIR}/cmake/${QT_CMAKE_EXPORT_NAMESPACE}") + list(APPEND CMAKE_MODULE_PATH ${module_paths}) + # In multi-config mode by default we exclude building tools for configs other than the main one. # Trying to build an example in a non-default config using the non-installed # QtFooConfig.cmake files would error out saying moc is not found.