Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmake/SetupProtobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ if(NOT USERVER_FORCE_DOWNLOAD_PROTOBUF)
if(USERVER_DOWNLOAD_PACKAGE_PROTOBUF)
find_package(Protobuf QUIET)
else()
find_package(Protobuf)
find_package(Protobuf CONFIG QUIET)
if (NOT Protobuf_FOUND)
find_package(Protobuf)
endif()
if(NOT Protobuf_FOUND)
message(
FATAL_ERROR
Expand All @@ -57,7 +60,11 @@ if(NOT USERVER_FORCE_DOWNLOAD_PROTOBUF)

if(Protobuf_FOUND)
_userver_set_protobuf_version_category()
set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}")
if (Protobuf_PROTOC_EXECUTABLE)
set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}")
elseif (TARGET protobuf::protoc)
set(PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()
return()
endif()
endif()
Expand Down
8 changes: 7 additions & 1 deletion cmake/UserverGrpcTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ function(_userver_prepare_grpc)
elseif(protobuf_INCLUDE_DIRS)
set_property(GLOBAL PROPERTY userver_protobuf_import_dir "${protobuf_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "Invalid Protobuf package")
# maybe we found the protobuf config
get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
if (Protobuf_INCLUDE_DIR)
set_property(GLOBAL PROPERTY userver_protobuf_import_dir "${Protobuf_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Invalid Protobuf package")
endif()
endif()

if(NOT Protobuf_VERSION)
Expand Down
Loading