CMake: prepend build dir for examples build
In cross-compilation, the CMAKE_FIND_ROOT_PATH will have path to the host Qt and examples build will pick up wrong Qt6Config.cmake unless the build dir path is prepended. Fixes: QTBUG-104270 Change-Id: I7fc7499369a2e5446e1c5257155f81c72716fef7 Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 18ed6a8979a1f1910f1285b5b2e5a28c397b37aa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4efe690a97
commit
e0ed5b63a1
@ -751,7 +751,7 @@ endfunction()
|
|||||||
# Mean to be called when configuring examples as part of the main build tree, as well as for CMake
|
# Mean to be called when configuring examples as part of the main build tree, as well as for CMake
|
||||||
# tests (tests that call CMake to try and build CMake applications).
|
# tests (tests that call CMake to try and build CMake applications).
|
||||||
macro(qt_internal_set_up_build_dir_package_paths)
|
macro(qt_internal_set_up_build_dir_package_paths)
|
||||||
list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}")
|
list(PREPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/cmake")
|
||||||
# Make sure the CMake config files do not recreate the already-existing targets
|
# Make sure the CMake config files do not recreate the already-existing targets
|
||||||
set(QT_NO_CREATE_TARGETS TRUE)
|
set(QT_NO_CREATE_TARGETS TRUE)
|
||||||
endmacro()
|
endmacro()
|
||||||
@ -833,15 +833,15 @@ macro(qt_examples_build_begin)
|
|||||||
|
|
||||||
# Examples that are built as part of the Qt build need to use the CMake config files from the
|
# 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.
|
# build dir, because they are not installed yet in a prefix build.
|
||||||
# Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake.
|
# Prepending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake.
|
||||||
# Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those
|
# Prepending 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.
|
# find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored.
|
||||||
# Appending to CMAKE_FIND_ROOT_PATH ensures the components are found while cross-compiling
|
# Prepending to CMAKE_FIND_ROOT_PATH ensures the components are found while cross-compiling
|
||||||
# without setting CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH.
|
# without setting CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH.
|
||||||
if(NOT QT_IS_EXTERNAL_EXAMPLES_BUILD OR NOT __qt_all_examples_ported_to_external_projects)
|
if(NOT QT_IS_EXTERNAL_EXAMPLES_BUILD OR NOT __qt_all_examples_ported_to_external_projects)
|
||||||
qt_internal_set_up_build_dir_package_paths()
|
qt_internal_set_up_build_dir_package_paths()
|
||||||
list(APPEND CMAKE_FIND_ROOT_PATH "${QT_BUILD_DIR}")
|
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_BUILD_DIR}")
|
||||||
list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/cmake")
|
list(PREPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Because CMAKE_INSTALL_RPATH is empty by default in the repo project, examples need to have
|
# Because CMAKE_INSTALL_RPATH is empty by default in the repo project, examples need to have
|
||||||
|
Loading…
x
Reference in New Issue
Block a user