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 <alexey.edelev@qt.io>
(cherry picked from commit 31c5d50e84b210843ccdec58a86c4fce3125b679)
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2024-03-06 15:12:33 +01:00
parent a94fef3e04
commit 0c38013c71

View File

@ -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.