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

142 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?
Reply all
Reply to author
Forward
0 new messages