CMake project find_package() gives warning about absl missing protobuf::gmock target

193 views
Skip to first unread message

Evan Wegley

unread,
Apr 6, 2024, 5:30:22 PMApr 6
to Protocol Buffers
Protobuf version: v26.1
CMake version: 3.29.0

I built protobuf in a container as follows:

(From the local machine running Docker Desktop)
$ docker pull ubuntu:jammy
$ docker run -it -v /opt/ext:/opt/ext ubuntu:jammy

(From inside the container)
$ apt-get update
$ apt-get install build-essential git cmake
$ cd
$ cd protobuf/
$ git submodule update --init --recursive
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/ext/protobuf .
$ make -j 4 install

Now I have protobuf installed to /opt/ext/protobuf in my local Linux environment (Also Ubuntu 22.04).

In my local environment, I set up a CMake project with the following minimal CMakeLists.txt.

cmake_minimum_required(VERSION 3.29)
project(Demo VERSION 1.0)
list(APPEND CMAKE_PREFIX_PATH "/opt/ext/protobuf")
find_package(Protobuf PATHS "/opt/ext/protobuf" CONFIG REQUIRED)

But when I try to build, I get this warning:

CMake Warning at /opt/ext/protobuf/lib/cmake/protobuf/protobuf-config.cmake:7 (find_package):
  Found package configuration file:

    /opt/ext/protobuf/lib/cmake/absl/abslConfig.cmake

  but it set absl_FOUND to FALSE so package "absl" is considered to be NOT
  FOUND.  Reason given by package:

  The following imported targets are referenced, but are missing:
  protobuf::gmock

Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)



Is this a bug, or is there something wrong with my usage?

Zbigniew Piecuch

unread,
Jun 26, 2024, 5:20:47 AM (7 days ago) Jun 26
to Protocol Buffers
Hello
I have the same problem.
What I've noticed on my machine is that there is a difference between find_package(Protobuf CONFIG REQUIRED) and find_package(protobuf CONFIG REQUIRED). Protobuf that starts with small letters contains protobuf::gmock target, however it is  defined in following way:
# Create imported target protobuf::gmock
add_library(protobuf::gmock STATIC IMPORTED)

So it's only gmock target in protobuf namespace. 

Still, I get the same error and it doesn't work. I'm don't know how to install gmock to make it work.

BR,
Piecuch Z.
Reply all
Reply to author
Forward
0 new messages