CMake: Warn when PRIVATE_MODULE_INTERFACE is provided with no target

Warn if the PRIVATE_MODULE_INTERFACE option is provided a value, but
there is no ${target}Private target to set the interface dependencies
on.

Pick-to: 6.2
Task-number: QTBUG-95921
Change-Id: I7d4df9cb3aa9b7746d836b82019ecdd9c8f50fdc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Alexandru Croitor 2021-08-23 20:47:05 +02:00
parent 80705298ca
commit 0dbf73e3de
1 changed files with 10 additions and 2 deletions

View File

@ -108,8 +108,16 @@ function(qt_internal_extend_target target)
set(target_private "${target}")
endif()
if(TARGET "${target_private}")
target_link_libraries("${target_private}"
INTERFACE ${arg_PRIVATE_MODULE_INTERFACE})
target_link_libraries("${target_private}"
INTERFACE ${arg_PRIVATE_MODULE_INTERFACE})
elseif(arg_PRIVATE_MODULE_INTERFACE)
set(warning_message "")
string(APPEND warning_message
"The PRIVATE_MODULE_INTERFACE option was provided the values:"
"'${arg_PRIVATE_MODULE_INTERFACE}' "
"but there is no ${target}Private target to assign them to."
"Ensure the target exists or remove the option.")
message(AUTHOR_WARNING "${warning_message}")
endif()
qt_register_target_dependencies("${target}"
"${arg_PUBLIC_LIBRARIES}"