From 140b65e36f71189fee181330018ed9fe8479fc6b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 16 May 2019 11:34:06 +0200 Subject: [PATCH] Propagate QT_CMAKE_EXPORT_NAMESPACE via QtCore package QT_CMAKE_EXPORT_NAMESPACE is used by the Qt packages to make features available to the consuming CMake project. The value was moved to the BuildInternals Config file, but that's wrong because consuming applications not including the BuildInternals component would fail to use any other Qt package. Move QT_CMAKE_EXPORT_NAMESPACE to be propagated with QtCore package again. Amends 9542e78525b422159406d8fa63e30dcd0f926411. Change-Id: I9841ac8c2828b00c0111d59e8976c889554e0ce1 Reviewed-by: Tobias Hunger --- cmake/QtBuild.cmake | 10 ++++++++++ cmake/QtModuleConfig.cmake.in | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index cc5b9e63e15..50722a54758 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -930,6 +930,16 @@ function(add_qt_module target) list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake") endif() + set(extra_cmake_code "") + + if(target STREQUAL Core) + # Propagate non-build related variables that are needed for consuming Qt packages. + # Do this in CoreConfig instead of Qt5Config, so that consumers can also use + # find_package(Qt5Core) instead of find_package(Qt5 COMPONENTS Core) + string(APPEND extra_cmake_code " +set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") + endif() + configure_package_config_file( "${QT_CMAKE_DIR}/QtModuleConfig.cmake.in" "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake" diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 7baea8cf9cf..6a68fdf3b0f 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -5,6 +5,10 @@ include(CMakeFindDependencyMacro) get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_import_prefix "${_import_prefix}" REALPATH) +# Extra cmake code begin +@extra_cmake_code@ +# Extra cmake code end + # Find required dependencies, if any. if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")