Fix protobuf find_package fallback when config mode unavailable

When CMake's FindProtobuf module is used as a fallback (e.g. when building
as a git submodule without vcpkg), it creates Protobuf::libprotobuf (capital
P) rather than protobuf::libprotobuf. Add an alias so both code paths work.

This fixes #367
This commit is contained in:
Fletcher Dunn
2026-05-03 22:20:27 -07:00
parent 303272bcdd
commit db30f1b139
+5
View File
@@ -13,6 +13,11 @@ find_package(Protobuf QUIET CONFIG)
if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif()
# Module mode (FindProtobuf.cmake) creates Protobuf::libprotobuf (capital P);
# config mode creates protobuf::libprotobuf (lowercase). Alias so either works.
if(NOT TARGET protobuf::libprotobuf AND TARGET Protobuf::libprotobuf)
add_library(protobuf::libprotobuf ALIAS Protobuf::libprotobuf)
endif()
find_package(Threads REQUIRED)
set(GNS_COMMON_PROTOS