diff --git a/cmake/Protobuf.cmake b/cmake/Protobuf.cmake index 943cf37b07..31c9c16a4c 100644 --- a/cmake/Protobuf.cmake +++ b/cmake/Protobuf.cmake @@ -11,10 +11,15 @@ macro(p4c_obtain_protobuf) set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES .a) endif() - find_package(Protobuf 3.0.0 REQUIRED) + find_package(Protobuf CONFIG) + if(NOT Protobuf_FOUND) + find_package(Protobuf REQUIRED) + endif() if(ENABLE_PROTOBUF_STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES ${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() + set(PROTOBUF_LIBRARY "protobuf::libprotobuf") + set(PROTOBUF_PROTOC_EXECUTABLE "protobuf::protoc") else() # Google introduced another breaking change with protobuf 22.x by adding abseil as a new # dependency. https://protobuf.dev/news/2022-08-03/#abseil-dep We do not want abseil, so we stay