CMake: Don't enforce find_package(Qt6FooPrivate) for Qt 6.9

Requiring users to do find_package(Qt6FooPrivate) to use private modules
turned out to be a too invasive change for Qt 6.9. We turn off this
behavior and restrict it to the dev branch.

[ChangeLog][CMake] The requirement to do find_package(Qt6FooPrivate) in
user projects was postponed to a later Qt version.

Task-number: QTBUG-87776
Change-Id: Ifbf676288587ae5fabe100bf3bd93b220ddbc5ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2025-01-27 17:44:57 +01:00
parent 54cb92d58b
commit 7782f2ad14
2 changed files with 8 additions and 3 deletions

View File

@ -35,7 +35,11 @@ if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
endif()
# Find the private module counterpart.
set(__qt_@target@_always_load_private_module OFF)
# For now, always load the private module. In a future Qt version we plan to require users to
# find_package the private module explicitly.
set(__qt_@target@_always_load_private_module ON)
set(__qt_@target@_save_QT_NO_PRIVATE_MODULE_WARNING ${QT_NO_PRIVATE_MODULE_WARNING})
set(QT_NO_PRIVATE_MODULE_WARNING ON)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@-build.cmake" OPTIONAL)
if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND
AND NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND
@ -80,6 +84,8 @@ if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND
endif()
endif()
endif()
set(QT_NO_PRIVATE_MODULE_WARNING ${__qt_@target@_save_QT_NO_PRIVATE_MODULE_WARNING})
unset(__qt_@target@_save_QT_NO_PRIVATE_MODULE_WARNING)
unset(__qt_@target@_always_load_private_module)
if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)

View File

@ -20,8 +20,7 @@ if(NOT DEFINED "@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND")
set("@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND" TRUE)
endif()
if(NOT __qt_@target@_always_load_private_module
AND NOT DEFINED QT_REPO_MODULE_VERSION
if(NOT DEFINED QT_REPO_MODULE_VERSION
AND NOT QT_NO_PRIVATE_MODULE_WARNING
AND NOT __qt_private_module_@target_private@_warning_shown)
message(WARNING