Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Allow arbitrary sections in pkg_config .pc files #7661

Closed
madebr opened this issue Sep 5, 2020 · 6 comments · Fixed by #8727
Closed

[feature] Allow arbitrary sections in pkg_config .pc files #7661

madebr opened this issue Sep 5, 2020 · 6 comments · Fixed by #8727
Assignees

Comments

@madebr
Copy link
Contributor

madebr commented Sep 5, 2020

pkg_config files can contain extra information, next to include paths/library paths/libs/cflags/requires/...
This is used by some programs to pass around configuration paths.

Because the generated .pc files by conan, are missing this information, configuration fails.

e.g. glib uses this. When using the files generated by conan, the following error appears:

Run-time dependency gio-2.0 found: YES 2.65.1
Dependency gio-2.0 found: YES 2.65.1 (cached)
Using 'PKG_CONFIG_PATH' from environment with value: '/home/maarten/.conan/data/glib-networking/2.65.1/_/_/build/eac566419e1470979e589f72ef984a2778d4785a'
Run-time dependency gmodule-2.0 found: YES 2.65.1
WARNING: pkgconfig variable 'giomoduledir' not defined for dependency gio-2.0.

source_subfolder/meson.build:68:0: ERROR: Assert failed: GIO_MODULE_DIR is missing from gio-2.0.pc

The gio-2.0.pc file, installed in my system contains:

prefix=/usr
libdir=${prefix}/lib64
includedir=${prefix}/include

datadir=${prefix}/share
schemasdir=${datadir}/glib-2.0/schemas
bindir=${prefix}/bin
giomoduledir=${libdir}/gio/modules
glib_compile_schemas=${bindir}/glib-compile-schemas
glib_compile_resources=${bindir}/glib-compile-resources
gdbus_codegen=${bindir}/gdbus-codegen

Name: GIO
Description: glib I/O library
Version: 2.60.7
Requires: glib-2.0, gobject-2.0
Requires.private: gmodule-no-export-2.0, zlib, mount >= 2.23, libselinux
Libs: -L${libdir} -lgio-2.0
Libs.private: -ldl -pthread -lresolv
Cflags: -I${includedir}
[maarten@localhost eac5664

The generated gio-2.0.pc contains:

prefix=/home/maarten/.conan/data/glib/2.65.1/_/_/package/f9b484c68439b8cf20fdfbb3f876d6cf74a4f970
libdir=${prefix}/lib
includedir=${prefix}/include

Name: glib-gio-2.0
Description: Conan package: glib-gio-2.0
Version: 2.65.1
Libs: -L${libdir} -lgio-2.0  -lresolv  -ldl  -Wl,-rpath="${libdir}"
Cflags: -I${includedir}
Requires: glib-2.0 gobject-2.0 gmodule-2.0 zlib mount libselinux

The generated pc file is missing a lot of keys, of which some are custom.
So it would be useful to add custom key/values to pkg_config files.

This feature is used by glib/glib-networking.

@ericLemanissier
Copy link
Contributor

this blocks conan-io/conan-center-index#3663

@KristianJerpetjon
Copy link

This prevents generation of proper .pc files like the gst-plugins-base's gstreamer-video-1.0.pc

@ericLemanissier
Copy link
Contributor

@memsharded
Copy link
Member

Thanks for the feedback. I am trying to understand the scope of this information, and why would it be exclusive to the .pc files. How is CMake dealing with this library, is it even possible to consume it at all without using those .pc files? How CMake maps those giomoduledir=${libdir}/gio/modules, glib_compile_schemas=${bindir}/glib-compile-schemas, glib_compile_resources=${bindir}/glib-compile-resources variables?

Because the recipe in ConanCenter maybe could add one of the new build_modules specific for the pkgconfig generator, though we would need a way to inject it, I think this is done at the moment only by the CMake generators.

@ericLemanissier
Copy link
Contributor

ericLemanissier commented Mar 15, 2021

regarding gobject-introspection, the information is probably never consumed from cmake : https://ubuntu.pkgs.org/20.10/ubuntu-main-amd64/libgirepository1.0-dev_1.66.1-1_amd64.deb.html
Wayland-protocols too: https://ubuntu.pkgs.org/20.10/ubuntu-main-arm64/wayland-protocols_1.20-1_all.deb.html
gst-plugins-base too: https://ubuntu.pkgs.org/20.04/ubuntu-main-amd64/libgstreamer-plugins-base1.0-dev_1.16.2-4_amd64.deb.html
glib too: https://ubuntu.pkgs.org/20.04/ubuntu-main-amd64/libglib2.0-dev_2.64.2-1~fakesync1_amd64.deb.html

On the other hand, the pkg-config variables can be consumed from cmake (via pkg-config) using https://cmake.org/cmake/help/latest/module/FindPkgConfig.html#command:pkg_get_variable

EDIT: I don't think build_modules is a proper solution to this problem, because we need to add simple key-value pairs to .pc files already generated by conan, not add new .pc files to existing recipes. Something like self.cpp_info.variables['pkg_config'].variable_name = "variable value". The values are always simple strings, because pkg-config has its own expansion system

@ericLemanissier
Copy link
Contributor

Meson has a semi-portable (across build systems) way to retrieve variable from dependencies: https://mesonbuild.com/Release-notes-for-0-51-0.html#dependency-objects-now-have-a-get_variable-method and https://mesonbuild.com/Dependencies.html#arbitrary-variables-from-dependencies-that-can-be-found-multiple-ways
dep.get_variable(pkgconfig : 'var-name', cmake : 'COP_VAR_NAME', default_value : 'NO')) you still have to specify the variable name for each build system you want to support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants