Skip to content

Incorrect pkg-config metadata for windows with shared abseil builds #15883

@h-vetinari

Description

@h-vetinari

I realize that using -Dprotobuf_ABSL_PROVIDER="package" (much less with shared abseil) is not the most common scenario, but it's very important in our distribution which serves many thousands of users (e.g. the most recent libprotobuf build has >160k downloads in the last two weeks).

And for the purposes of a distribution, where the builds of protobuf will themselves again be built against by other libraries (sometimes with different build systems), it's good to have accurate pkg-config data.

However, protobuf currently generates incorrect metadata in the above-mentioned scenario, mainly because shared abseil does something weird on windows, which is to stick everything into one abseil_dll.dll, thus breaking the absl_foo pattern. The end result is that the pkg-config file contains

Requires: absl_abseil_dll ...

which then results in something like:

Package absl_abseil_dll was not found in the pkg-config search path.

What version of protobuf and what language are you using?

Version: v25.1 / v25.2
Language: C++

What operating system (Linux, Windows, ...) and version?

Windows

What runtime / compiler are you using (e.g., python version or gcc version)

VS2019 (16.11 / 14.29.30139)

What did you do?

Steps to reproduce the behavior:
Run conda-forge recipe, which mainly does:

cmake -G "Ninja" ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_CXX_STANDARD=17 ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -Dprotobuf_ABSL_PROVIDER="package" ^
    -Dprotobuf_BUILD_SHARED_LIBS=ON ^
    -Dprotobuf_JSONCPP_PROVIDER="package" ^
    -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^
    -Dprotobuf_USE_EXTERNAL_GTEST=ON ^
    -Dprotobuf_WITH_ZLIB=ON ^
    ..

What did you expect to see

Correct pkg-config metadata

What did you see instead?

content of installed protobuf.pc (similar for protobuf-lite.pc):

prefix=<snip>
exec_prefix=<snip>
libdir=<snip>
includedir=<snip>

Name: Protocol Buffers
Description: Google's Data Interchange Format
Version: 25.1.0
Requires: absl_abseil_dll utf8_range        # <-- wrong
Libs: -L${libdir} -lprotobuf 
Cflags: -I${includedir} -DPROTOBUF_USE_DLLS
Conflicts: protobuf-lite

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions