CMake: Warn on creation of private modules without private headers
Private modules without private headers don't make much sense and needlessly create CMake packages and QMake module pri files. In qt_finalize_module we check whether the module has any private headers. But the private module was already created before in qt_internal_add_module. Moving the creation of the private module or the CMake package files to the finalization phase would be a bigger refactoring that's probably not worth the hassle. An easier way to avoid the package creation issue is to mandate that a Qt module must be created with NO_PRIVATE_MODULE if it doesn't have any private headers. Add a warning if a Qt module without private headers is created without NO_PRIVATE_MODULE. Also warn if a Qt module with private headers is created with NO_PRIVATE_MODULE. This allows us to easily spot the places where NO_PRIVATE_MODULE is missing. Task-number: QTBUG-132526 Change-Id: I897f25790a99eaa320c39cd8c2728f26bceb824e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
7d22a9c75a
commit
58be29388d
@ -1147,8 +1147,37 @@ function(qt_internal_apply_apple_privacy_manifest target)
|
||||
endfunction()
|
||||
|
||||
function(qt_finalize_module target)
|
||||
set(no_value_options
|
||||
INTERNAL_MODULE
|
||||
NO_PRIVATE_MODULE
|
||||
)
|
||||
set(single_value_options "")
|
||||
set(multi_value_options "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg
|
||||
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
|
||||
)
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
qt_internal_collect_module_headers(module_headers ${target})
|
||||
|
||||
# Issue a warning if we
|
||||
# - suppressed creation of the private module but have private headers
|
||||
# - created a private module but don't have any private headers
|
||||
if(NOT arg_INTERNAL_MODULE)
|
||||
get_target_property(has_private_headers ${target} _qt_module_has_private_headers)
|
||||
if(arg_NO_PRIVATE_MODULE AND has_private_headers)
|
||||
message(AUTHOR_WARNING
|
||||
"Module ${target} has private headers. "
|
||||
"Please remove NO_PRIVATE_MODULE from its creation flags."
|
||||
)
|
||||
elseif(NOT arg_NO_PRIVATE_MODULE AND NOT has_private_headers)
|
||||
message(AUTHOR_WARNING
|
||||
"Module ${target} does not have private headers. "
|
||||
"Please add NO_PRIVATE_MODULE to its creation flags."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# qt_internal_install_module_headers needs to be called before
|
||||
# qt_finalize_framework_headers_copy, because the last uses the QT_COPIED_FRAMEWORK_HEADERS
|
||||
# property which supposed to be updated inside every qt_internal_install_module_headers
|
||||
|
Loading…
x
Reference in New Issue
Block a user