summaryrefslogtreecommitdiffstats
path: root/cmake/QtModuleConfig.cmake.in
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2024-12-09 21:14:50 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2024-12-19 12:11:30 +0100
commitfbbf4ace0188b9718b6d7808021c0b887fd52d9f (patch)
tree4f641f14308a2be32341a9d510c02f72b7cd73de /cmake/QtModuleConfig.cmake.in
parent44366d07dca047f096d1366c43ba549c97150074 (diff)
CMake: Split off private module config packages
[ChangeLog][CMake] Private Qt modules have been split off into separate Qt6FooPrivate CMake config packages. A call to find_package(Qt6Foo) will now implicitly find_package(Qt6FooPrivate). It's not an error if Qt6FooPrivate isn't available as it may be the case on certain Linux distros that split their Qt module packages into private and public parts. For every public module Qt6Foo that has an associated Qt6FooPrivate module, create a separate Qt6FooPrivate CMake config package. Let Qt6FooPrivate find Qt6Foo. This is a required dependency. Let Qt6Foo find Qt6FooPrivate if it's available. A message of log level VERBOSE is issued if Qt6FooPrivate is not found. Implementation notes: In QtModuleConfig.cmake.in, we pull in the private module. This is not part of the *Dependencies.cmake file, because 1. The Qt6FooPrivate package references the Qt6::Foo target, therefore it must be available. And Qt6FooDependencies.cmake is loaded before creating targets. 2. The dependency needs to be optional, and we don't have facilities for optional dependencies in Qt6FooDependencies yet. 3. We'd have to avoid recursion, because of the Qt6FooPrivate -> Qt6Foo dependency. Fixes: QTBUG-87776 Pick-to: 6.9 Change-Id: I8f23f07da7ca76486f87b759e197174c11e13534 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake/QtModuleConfig.cmake.in')
-rw-r--r--cmake/QtModuleConfig.cmake.in40
1 files changed, 40 insertions, 0 deletions
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
index 501e1780dc5..93185857162 100644
--- a/cmake/QtModuleConfig.cmake.in
+++ b/cmake/QtModuleConfig.cmake.in
@@ -29,7 +29,47 @@ if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@ExtraProperties.cmake"
OPTIONAL)
+endif()
+# Find the private module counterpart.
+if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND AND NOT @arg_NO_PRIVATE_MODULE@)
+ if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
+ if("${_qt_cmake_dir}" STREQUAL "")
+ set(_qt_cmake_dir "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
+ endif()
+ set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
+ if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
+ set(__qt_use_no_default_path_for_qt_packages "")
+ endif()
+ find_package(@INSTALL_CMAKE_NAMESPACE@@target_private@ "@PROJECT_VERSION@" EXACT
+ QUIET
+ CONFIG
+ PATHS
+ ${QT_BUILD_CMAKE_PREFIX_PATH}
+ "${CMAKE_CURRENT_LIST_DIR}/.."
+ "${_qt_cmake_dir}"
+ ${_qt_additional_packages_prefix_paths}
+ ${__qt_use_no_default_path_for_qt_packages}
+ )
+ endif()
+ if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
+ get_property(@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown GLOBAL PROPERTY
+ @INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown
+ )
+ if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown)
+ message(VERBOSE
+ "The private module package '@INSTALL_CMAKE_NAMESPACE@@target_private@' "
+ "could not be found. It possibly needs to be installed separately with your "
+ "package manager."
+ )
+ set_property(GLOBAL PROPERTY
+ @INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown ON
+ )
+ endif()
+ endif()
+endif()
+
+if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
# DEPRECATED
# Provide old style variables for includes, compile definitions, etc.
# These variables are deprecated and only provided on a best-effort basis to facilitate porting.