Skip to content

v1.1.0 CMake config leaks shared library dependencies into consumers #2264

@jbeich

Description

@jbeich

Regressed by #1778. Found via sdl2_image and kf5-kimageformats. Affects CMake-based consumers on FreeBSD, other BSDs and maybe even Nix due to using different prefix for each package. To reproduce install libavif and its dependencies outside of /usr and /usr/local thus not part of default C/C++ compiler search path.

$ export PKG_CONFIG_PATH=/tmp/test_prefix/lib/pkgconfig
$ export CMAKE_PREFIX_PATH=/tmp/test_prefix

$ pkg-config --libs dav1d
-L/tmp/test_prefix/lib -ldav1d
$ pkg-config --libs libyuv
-L/tmp/test_prefix/lib -lyuv
$ pkg-config --libs aom
-L/tmp/test_prefix/lib -laom

$ git clone https://github.com/AOMediaCodec/libavif
$ cmake -S libavif -B /tmp/libavif_build \
  -DAVIF_CODEC_AOM=SYSTEM \
  -DAVIF_CODEC_DAV1D=SYSTEM \
  -DAVIF_LIBYUV=SYSTEM \
  -DCMAKE_INSTALL_PREFIX=/tmp/test_prefix
$ cmake --build /tmp/libavif_build
$ cmake --install /tmp/libavif_build

$ cat foo.c
int main() {}
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(foo C)
add_executable(foo foo.c)
find_package(libavif)
target_link_libraries(foo avif)
$ cmake -B /tmp/foo_build
$ cmake --build /tmp/foo_build
[...]
ld: error: unable to find library -lyuv
ld: error: unable to find library -ldav1d
ld: error: unable to find library -laom
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions