SUMMARY Consider following pkgconfig for libcanberra compiled statically: prefix=${pcfiledir}/../.. exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: libcanberra Description: Event Sound API Version: 0.30 Libs: -L"${libdir}" -lcanberra -L/opt/homebrew/opt/libtool/lib -lltdl Cflags: -D_REENTRANT -I"${includedir}" -I/opt/homebrew/opt/libtool/include Requires: The pkg_check_modules(PC_Canberra libcanberra QUIET) in FindCanberra.cmake sets up all the extra information in following variables: PC_Canberra_LDFLAGS: -L/Users/cromo/Documents/Sourcecode/vcpkg/installed/arm64-osx/debug/lib/pkgconfig/../../lib;-L/opt/homebrew/opt/libtool/lib;-lcanberra;-lltdl PC_Canberra_LIBRARIES: canberra;ltdl PC_Canberra_CFLAGS: -D_REENTRANT;-I/Users/cromo/Documents/Sourcecode/vcpkg/installed/arm64-osx/debug/lib/pkgconfig/../../../include;-I/opt/homebrew/opt/libtool/include However, only the PC_Canberra_CFLAGS is passed down as INTERFACE_COMPILE_OPTIONS, effectively ignoring the information about the additional libraries that need to be linked against.
https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/187
Could you show what the resulting linker invocation looks like and what you expect it to be?
(In reply to Nicolas Fella from comment #2) > Could you show what the resulting linker invocation looks like and what you > expect it to be? I don't have it handy right now, but before making the proposed change, the -lltdl was missing from the linker invocation, and is correctly applied after the change.
If it's a static lib, why would it have to link to anything else? sounds like something is broken is the canberra build system
(In reply to Christophe Giboudeaux from comment #4) > If it's a static lib, why would it have to link to anything else? sounds > like something is broken is the canberra build system Linking happens at build time of the static app, not of the library itself. That information must be conveyed to the linker so it knows which libraries are needed, including the indirect dependencies of the direct ones. Please refer to https://people.freedesktop.org/~dbn/pkg-config-guide.html on the Requires.private, Libs.private and Requires.private explanation.
Static libraries are not supposed to have external link dependencies. If linking fails if ltdl isn't also linked, that's a strong indication that it's a public link target.
Git commit 028d2afde1b5ec765c206bf3db6574c85d200e5e by Christoph Cullmann, on behalf of Dawid Wróbel. Committed on 14/05/2023 at 19:59. Pushed by cullmann into branch 'master'. FindCanberra: link against target provided by pkgconfig target_link_libraries() against the target generated by pkg_check_modules() so that the additional linker options are not lost, such as the additional libraries to link against when building statically. M +4 -1 find-modules/FindCanberra.cmake https://invent.kde.org/frameworks/extra-cmake-modules/commit/028d2afde1b5ec765c206bf3db6574c85d200e5e