diff options
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 7 | ||||
-rw-r--r-- | cmake/QtConfig.cmake.in | 3 | ||||
-rw-r--r-- | cmake/QtModuleConfig.cmake.in | 2 | ||||
-rw-r--r-- | cmake/QtModuleDependencies.cmake.in | 2 | ||||
-rw-r--r-- | cmake/QtPluginDependencies.cmake.in | 2 |
5 files changed, 11 insertions, 5 deletions
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}) diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index 1212c191b9..2a3c862d94 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -6,6 +6,7 @@ if (CMAKE_VERSION VERSION_LESS 3.1.0) endif() get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") if (NOT QT_NO_CREATE_TARGETS) include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake") @@ -28,7 +29,7 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS}) find_package(@INSTALL_CMAKE_NAMESPACE@${module} ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET} ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED} - PATHS ${_qt_cmake_dir} NO_DEFAULT_PATH + PATHS ${_qt_cmake_dir} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND) string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY) diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 2f042e6b2c..b24bcb9561 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -28,7 +28,7 @@ foreach(extra_cmake_include @extra_cmake_includes@) include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}") endforeach() -include(${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/QtFeature.cmake) +include(${_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir}/QtFeature.cmake) qt_make_features_available(@QT_CMAKE_EXPORT_NAMESPACE@::@target@) diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in index 81d6431c67..c9cfa9e752 100644 --- a/cmake/QtModuleDependencies.cmake.in +++ b/cmake/QtModuleDependencies.cmake.in @@ -63,7 +63,7 @@ foreach(_target_dep ${_target_deps}) if (NOT ${pkg}_FOUND) find_dependency(${pkg} ${version} - PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH + PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) endif() diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in index 6ca392ec64..0dd6ba5a08 100644 --- a/cmake/QtPluginDependencies.cmake.in +++ b/cmake/QtPluginDependencies.cmake.in @@ -43,7 +43,7 @@ foreach(_target_dep ${_target_deps}) if (NOT ${pkg}_FOUND) find_dependency(${pkg} ${version} - PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH + PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) endif() |