Use separate Qt5Config.cmake inside build directory
Qt5Config restricts search paths of Qt components to ${_qt5_install_prefix} to prevent accidentally using system Qt modules in case of restricted Qt configuration. However this does not work properly when Qt is used without installation, in particular when building cmake-based QtWebKit as a Qt submodule, because ${_qt5_install_prefix} resolves to QtBase and does not contain components from other modules. This patch changes search path from ${_qt5_install_prefix} to all qt5 subdirectories. Change-Id: Icf01a256097710889573ad69d847b9c3bffa1449 Reviewed-by: Kevin Funk <kevin.funk@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
parent
8a2f544523
commit
5cd4001bf2
@ -22,18 +22,24 @@ get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/..\" ABSO
|
||||
|
||||
set(_Qt5_NOTFOUND_MESSAGE)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Qt5ModuleLocation.cmake)
|
||||
|
||||
foreach(module ${Qt5_FIND_COMPONENTS})
|
||||
find_package(Qt5${module}
|
||||
${_Qt5_FIND_PARTS_QUIET}
|
||||
${_Qt5_FIND_PARTS_REQUIRED}
|
||||
PATHS \"${_qt5_install_prefix}\" NO_DEFAULT_PATH
|
||||
PATHS ${_qt5_module_paths} NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT Qt5${module}_FOUND)
|
||||
string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
|
||||
|
||||
if (Qt5_FIND_REQUIRED_${module})
|
||||
set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/Qt5${module}/Qt5${module}Config.cmake\\\"\\n\")
|
||||
set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\\n\")
|
||||
elseif(NOT Qt5_FIND_QUIETLY)
|
||||
message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_qt5_install_prefix}/Qt5${module}/Qt5${module}Config.cmake\\\"\")
|
||||
message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\")
|
||||
endif()
|
||||
|
||||
unset(_expected_module_location)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
15
src/corelib/Qt5ModuleLocation.cmake.in
Normal file
15
src/corelib/Qt5ModuleLocation.cmake.in
Normal file
@ -0,0 +1,15 @@
|
||||
!!IF !isEmpty(_QMAKE_SUPER_CACHE_)
|
||||
get_filename_component(_qt5_root_dir \"${CMAKE_CURRENT_LIST_DIR}/../../../..\" ABSOLUTE)
|
||||
|
||||
file(GLOB qtmodules ${_qt5_root_dir} "${_qt5_root_dir}/*")
|
||||
foreach(qtmodule ${qtmodules})
|
||||
if(IS_DIRECTORY ${qtmodule})
|
||||
list(APPEND _qt5_module_paths ${qtmodule})
|
||||
endif()
|
||||
endforeach()
|
||||
!!ELSE
|
||||
set(_qt5_root_dir ${_qt5_install_prefix})
|
||||
set(_qt5_module_paths ${_qt5_install_prefix})
|
||||
!!ENDIF
|
||||
|
||||
set(_qt5_module_location_template ${_qt5_root_dir})
|
4
src/corelib/Qt5ModuleLocationForInstall.cmake.in
Normal file
4
src/corelib/Qt5ModuleLocationForInstall.cmake.in
Normal file
@ -0,0 +1,4 @@
|
||||
set(_qt5_root_dir ${_qt5_install_prefix})
|
||||
set(_qt5_module_paths ${_qt5_install_prefix})
|
||||
|
||||
set(_qt5_module_location_template ${_qt5_install_prefix}/Qt5@module@/Qt5@module@Config.cmake)
|
@ -93,6 +93,12 @@ ctest_macros_file.CONFIG = verbatim
|
||||
cmake_umbrella_config_file.input = $$PWD/Qt5Config.cmake.in
|
||||
cmake_umbrella_config_file.output = $$DESTDIR/cmake/Qt5/Qt5Config.cmake
|
||||
|
||||
cmake_umbrella_config_module_location.input = $$PWD/Qt5ModuleLocation.cmake.in
|
||||
cmake_umbrella_config_module_location.output = $$DESTDIR/cmake/Qt5/Qt5ModuleLocation.cmake
|
||||
|
||||
cmake_umbrella_config_module_location_for_install.input = $$PWD/Qt5ModuleLocationForInstall.cmake.in
|
||||
cmake_umbrella_config_module_location_for_install.output = $$DESTDIR/cmake/install/Qt5/Qt5ModuleLocation.cmake
|
||||
|
||||
cmake_umbrella_config_version_file.input = $$PWD/../../mkspecs/features/data/cmake/Qt5ConfigVersion.cmake.in
|
||||
cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion.cmake
|
||||
|
||||
@ -119,10 +125,21 @@ contains(CMAKE_INSTALL_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_INSTALL_DATA_DIR)
|
||||
cmake_extras_mkspec_dir_for_install.input = $$PWD/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
|
||||
cmake_extras_mkspec_dir_for_install.output = $$DESTDIR/cmake/install/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake
|
||||
|
||||
cmake_qt5_umbrella_module_files.files = $$cmake_umbrella_config_file.output $$cmake_umbrella_config_version_file.output
|
||||
cmake_qt5_umbrella_module_files.files = \
|
||||
$$cmake_umbrella_config_file.output \
|
||||
$$cmake_umbrella_config_version_file.output \
|
||||
$$cmake_umbrella_config_module_location_for_install.output
|
||||
|
||||
cmake_qt5_umbrella_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5
|
||||
|
||||
QMAKE_SUBSTITUTES += ctest_macros_file cmake_umbrella_config_file cmake_umbrella_config_version_file cmake_extras_mkspec_dir cmake_extras_mkspec_dir_for_install
|
||||
QMAKE_SUBSTITUTES += \
|
||||
ctest_macros_file \
|
||||
cmake_umbrella_config_file \
|
||||
cmake_umbrella_config_module_location \
|
||||
cmake_umbrella_config_module_location_for_install \
|
||||
cmake_umbrella_config_version_file \
|
||||
cmake_extras_mkspec_dir \
|
||||
cmake_extras_mkspec_dir_for_install
|
||||
|
||||
ctest_qt5_module_files.files += $$ctest_macros_file.output $$cmake_extras_mkspec_dir_for_install.output
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user