Allow specifying extra protobuf include directories for protobuf modules

Iterate the _<Module>_proto_external_include_dir variable in
<Module>ProtobufProperties.cmake and add the existing paths to
the QT_PROTO_INCLUDES property. This allow specifying extra paths
in <Module>Config.cmake.

If the respecive paths are not found or are not absolute, the
respective warning is raised.
Setting QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES to ON suppresses the
warning.

Pick-to: 6.8 6.9
Change-Id: I4b6971e84f35b2986d187fb5d1766ed0cf3390f5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-03-19 11:32:58 +01:00
parent cf750df488
commit 18bb2ba5e1
1 changed files with 23 additions and 0 deletions

View File

@ -11,5 +11,28 @@ if(NOT QT_NO_CREATE_TARGETS)
QT_PROTO_INCLUDES "${CMAKE_STAGING_PREFIX}/${proto_include_dir}") QT_PROTO_INCLUDES "${CMAKE_STAGING_PREFIX}/${proto_include_dir}")
endif() endif()
endforeach() endforeach()
foreach(proto_include_dir IN LISTS _@target@_proto_external_include_dirs)
if(NOT IS_ABSOLUTE "${proto_include_dir}")
if(NOT QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES)
message(WRANING "The protobuf include directory ${proto_include_dir} must be an"
" absolute path. Skipping adding it to the @target@ module QT_PROTO_INCLUDES."
" Use QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES to suppress this warning.")
endif()
continue()
endif()
if(NOT EXISTS "${proto_include_dir}")
if(NOT QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES)
message(WARNING "The protobuf include directory ${proto_include_dir} doesn't exist."
" Skipping adding it to the @target@ module QT_PROTO_INCLUDES."
" Use QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES to suppress this warning.")
endif()
continue()
endif()
set_property(TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::@target@ APPEND PROPERTY
QT_PROTO_INCLUDES "${proto_include_dir}")
endforeach()
unset(_@target@_proto_include_dirs) unset(_@target@_proto_include_dirs)
endif() endif()