Skip to content

Cannot use protobuf with cmake due to "The following imported targets are referenced, but are missing" re. absl targets #24785

@W35170

Description

@W35170

Built protobuf myself w/o issues using cmake. But when I try to use it in my projects, cmake complains about missing absl targets.

CMake Warning at CMakeLists.txt:39 (find_package):
  Found package configuration file:

    /opt/protobuf-v28.3/lib64/cmake/protobuf/protobuf-config.cmake

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

  The following imported targets are referenced, but are missing:
  absl::absl_check absl::absl_log absl::algorithm absl::base absl::bind_front
  absl::bits absl::btree absl::cleanup absl::cord absl::core_headers
  absl::debugging absl::die_if_null absl::dynamic_annotations absl::flags
  absl::flat_hash_map absl::flat_hash_set absl::function_ref absl::hash
  absl::if_constexpr absl::layout absl::log_initialize absl::log_globals
  absl::log_severity absl::memory absl::node_hash_map absl::node_hash_set
  absl::optional absl::random_distributions absl::random_random absl::span
  absl::status absl::statusor absl::strings absl::synchronization absl::time
  absl::type_traits absl::utility absl::variant utf8_range::utf8_validity
  utf8_range::utf8_range

What version of protobuf and what language are you using?
Protobuf version v28.3
Language: C++

What operating system (Linux, Windows, ...) and version?
RHEL 8 with gcc 8.10

What did you do?
Steps to reproduce the behavior:

git clone -b v28.3 https://github.com/protocolbuffers/protobuf
cd protobuf
mkdir build
cmake -DCMAKE_INSTALL_PREFIX=/opt/protobuf-v28.3 -S. -B build
# absl not found so it's built in-line
cd build
make -j
sudo make install

Then, on my project's CMakeLists.txt I have:

set(PROTOBUF_REQUIRED_VERSION 28.3 CACHE STRING "Which version of protobuf to use")
find_package(protobuf ${PROTOBUF_REQURED_VERSION} CONFIG)

But when I try to run cmake

cd /path/to/my/project
cmake -S . -B build/

I get this error:

CMake Warning at CMakeLists.txt:39 (find_package):
  Found package configuration file:

    /opt/protobuf-v28.3/lib64/cmake/protobuf/protobuf-config.cmake

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

  The following imported targets are referenced, but are missing:
  absl::absl_check absl::absl_log absl::algorithm absl::base absl::bind_front
  absl::bits absl::btree absl::cleanup absl::cord absl::core_headers
  absl::debugging absl::die_if_null absl::dynamic_annotations absl::flags
  absl::flat_hash_map absl::flat_hash_set absl::function_ref absl::hash
  absl::if_constexpr absl::layout absl::log_initialize absl::log_globals
  absl::log_severity absl::memory absl::node_hash_map absl::node_hash_set
  absl::optional absl::random_distributions absl::random_random absl::span
  absl::status absl::statusor absl::strings absl::synchronization absl::time
  absl::type_traits absl::utility absl::variant utf8_range::utf8_validity
  utf8_range::utf8_range

Re-building and reinstalling protobuf with ABSL_ENABLE_INSTALL=OFF did not help.

What did you expect to see
cmake to find protobuf and complete without error

What did you see instead?

  Found package configuration file:

    /opt/protobuf-v28.3/lib64/cmake/protobuf/protobuf-config.cmake

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

  The following imported targets are referenced, but are missing:
  absl::absl_check absl::absl_log absl::algorithm absl::base absl::bind_front
  absl::bits absl::btree absl::cleanup absl::cord absl::core_headers
  absl::debugging absl::die_if_null absl::dynamic_annotations absl::flags
  absl::flat_hash_map absl::flat_hash_set absl::function_ref absl::hash
  absl::if_constexpr absl::layout absl::log_initialize absl::log_globals
  absl::log_severity absl::memory absl::node_hash_map absl::node_hash_set
  absl::optional absl::random_distributions absl::random_random absl::span
  absl::status absl::statusor absl::strings absl::synchronization absl::time
  absl::type_traits absl::utility absl::variant utf8_range::utf8_validity
  utf8_range::utf8_range

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions