CMake: Add a way to mark modules as "load the private module too"
Add FIND_PRIVATE_MODULE argument to qt_internal_add_module. If this argument is set for Qt6Foo, then find_package(Qt6Foo) will also find_package(Qt6FooPrivate). This should only be necessary in exceptional cases like Qt6Qml where Qt6QmlPrivate is used unconditionally. Task-number: QTBUG-87776 Change-Id: I8d6fbd0624c0008fc42294ff2d2ed36848963508 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
befce757fa
commit
61c6e90401
@ -32,7 +32,7 @@ if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find the private module counterpart.
|
# Find the private module counterpart.
|
||||||
set(__qt_@target@_always_load_private_module OFF)
|
set(__qt_@target@_always_load_private_module @always_load_private_module@)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@-build.cmake" OPTIONAL)
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@-build.cmake" OPTIONAL)
|
||||||
if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND
|
if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND
|
||||||
AND NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND
|
AND NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND
|
||||||
|
@ -5,6 +5,7 @@ macro(qt_internal_get_internal_add_module_keywords option_args single_args multi
|
|||||||
set(${option_args}
|
set(${option_args}
|
||||||
STATIC
|
STATIC
|
||||||
EXCEPTIONS
|
EXCEPTIONS
|
||||||
|
FIND_PRIVATE_MODULE
|
||||||
INTERNAL_MODULE
|
INTERNAL_MODULE
|
||||||
HEADER_MODULE
|
HEADER_MODULE
|
||||||
DISABLE_TOOLS_EXPORT
|
DISABLE_TOOLS_EXPORT
|
||||||
@ -131,6 +132,9 @@ endfunction()
|
|||||||
# ignored by syncqt. The specifying this directory allows to skip the parsing of the whole
|
# ignored by syncqt. The specifying this directory allows to skip the parsing of the whole
|
||||||
# CMAKE_CURRENT_SOURCE_DIR for the header files that needs to be synced and only parse the
|
# CMAKE_CURRENT_SOURCE_DIR for the header files that needs to be synced and only parse the
|
||||||
# single subdirectory, that meanwhile can be outside the CMAKE_CURRENT_SOURCE_DIR tree.
|
# single subdirectory, that meanwhile can be outside the CMAKE_CURRENT_SOURCE_DIR tree.
|
||||||
|
#
|
||||||
|
# FIND_PRIVATE_MODULE
|
||||||
|
# A call to find_package(Qt6Foo) will imply a call to find_package(Qt6FooPrivate).
|
||||||
function(qt_internal_add_module target)
|
function(qt_internal_add_module target)
|
||||||
qt_internal_get_internal_add_module_keywords(
|
qt_internal_get_internal_add_module_keywords(
|
||||||
module_option_args
|
module_option_args
|
||||||
@ -796,8 +800,16 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
|
|||||||
else()
|
else()
|
||||||
set(write_basic_module_package_args "")
|
set(write_basic_module_package_args "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(arg_FIND_PRIVATE_MODULE)
|
||||||
|
set(write_basic_public_module_package_args FIND_PRIVATE_MODULE)
|
||||||
|
else()
|
||||||
|
set(write_basic_public_module_package_args "")
|
||||||
|
endif()
|
||||||
|
|
||||||
qt_internal_write_basic_module_package("${target}" "${target_private}"
|
qt_internal_write_basic_module_package("${target}" "${target_private}"
|
||||||
${write_basic_module_package_args}
|
${write_basic_module_package_args}
|
||||||
|
${write_basic_public_module_package_args}
|
||||||
CONFIG_BUILD_DIR ${config_build_dir}
|
CONFIG_BUILD_DIR ${config_build_dir}
|
||||||
CONFIG_INSTALL_DIR ${config_install_dir}
|
CONFIG_INSTALL_DIR ${config_install_dir}
|
||||||
)
|
)
|
||||||
@ -991,6 +1003,7 @@ endfunction()
|
|||||||
# Otherwise write its public counterpart.
|
# Otherwise write its public counterpart.
|
||||||
function(qt_internal_write_basic_module_package target target_private)
|
function(qt_internal_write_basic_module_package target target_private)
|
||||||
set(no_value_options
|
set(no_value_options
|
||||||
|
FIND_PRIVATE_MODULE
|
||||||
IS_STATIC_LIB
|
IS_STATIC_LIB
|
||||||
PRIVATE
|
PRIVATE
|
||||||
)
|
)
|
||||||
@ -1003,12 +1016,16 @@ function(qt_internal_write_basic_module_package target target_private)
|
|||||||
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
|
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(always_load_private_module OFF)
|
||||||
if(arg_PRIVATE)
|
if(arg_PRIVATE)
|
||||||
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target_private}")
|
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target_private}")
|
||||||
set(module_config_input_file "QtModuleConfigPrivate.cmake.in")
|
set(module_config_input_file "QtModuleConfigPrivate.cmake.in")
|
||||||
else()
|
else()
|
||||||
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target}")
|
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target}")
|
||||||
set(module_config_input_file "QtModuleConfig.cmake.in")
|
set(module_config_input_file "QtModuleConfig.cmake.in")
|
||||||
|
if(arg_FIND_PRIVATE_MODULE)
|
||||||
|
set(always_load_private_module ON)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(arg_IS_STATIC_LIB AND NOT arg_PRIVATE AND CMAKE_VERSION VERSION_LESS "3.26")
|
if(arg_IS_STATIC_LIB AND NOT arg_PRIVATE AND CMAKE_VERSION VERSION_LESS "3.26")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user