Error out if Protobuf|GrpcQuick components are not found

QML option of both qt_add_protobuf and qt_add_grpc calls requires
ProtobufQuick and GrpcQuick targets to be found, accordingly.
Currently calls will fail with non-intuitive error that points to
the missing linking dependencies. Trigger a FATAL_ERROR at configure
time and give a hint on how to solve this.

Fixes: QTBUG-131780
Pick-to: 6.8 6.9
Change-Id: I571aa35839a6b68b54f5a71f0ee1947445b5eb2c
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-01-10 12:44:19 +01:00
parent 4ffa1fe6ff
commit 6d28b38872
2 changed files with 12 additions and 0 deletions

View File

@ -195,6 +195,12 @@ function(qt6_add_grpc target type)
${QT_CMAKE_EXPORT_NAMESPACE}::Grpc
)
if(arg_QML)
if(NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::GrpcQuick)
message(FATAL_ERROR "QML option of the qt_add_grpc command requires"
" ${QT_CMAKE_EXPORT_NAMESPACE}::GrpcQuick target. Please make sure that you"
" have the respective Qt component found by adding it to the find_package call:"
" find_package(${QT_CMAKE_EXPORT_NAMESPACE} COMPONENTS GrpcQuick)")
endif()
target_link_libraries(${target} PRIVATE
${QT_CMAKE_EXPORT_NAMESPACE}::GrpcQuick)
endif()

View File

@ -654,6 +654,12 @@ function(qt6_add_protobuf target)
)
endif()
if(NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::ProtobufQuick)
message(FATAL_ERROR "QML option of the qt_add_protobuf command requires"
" ${QT_CMAKE_EXPORT_NAMESPACE}::ProtobufQuick target. Please make sure that you"
" have the respective Qt component found by adding it to the find_package call:"
" find_package(${QT_CMAKE_EXPORT_NAMESPACE} COMPONENTS ProtobufQuick)")
endif()
target_link_libraries(${target} PRIVATE
${QT_CMAKE_EXPORT_NAMESPACE}::ProtobufQuick
)