Skip to content

Commit db30f1b

Browse files
committed
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
1 parent 303272b commit db30f1b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ find_package(Protobuf QUIET CONFIG)
1313
if(NOT Protobuf_FOUND)
1414
find_package(Protobuf REQUIRED)
1515
endif()
16+
# Module mode (FindProtobuf.cmake) creates Protobuf::libprotobuf (capital P);
17+
# config mode creates protobuf::libprotobuf (lowercase). Alias so either works.
18+
if(NOT TARGET protobuf::libprotobuf AND TARGET Protobuf::libprotobuf)
19+
add_library(protobuf::libprotobuf ALIAS Protobuf::libprotobuf)
20+
endif()
1621
find_package(Threads REQUIRED)
1722

1823
set(GNS_COMMON_PROTOS

0 commit comments

Comments
 (0)