{"action":"created","issue":{"url":"https://api.github.com/repos/mesonbuild/meson/issues/2169","repository_url":"https://api.github.com/repos/mesonbuild/meson","labels_url":"https://api.github.com/repos/mesonbuild/meson/issues/2169/labels{/name}","comments_url":"https://api.github.com/repos/mesonbuild/meson/issues/2169/comments","events_url":"https://api.github.com/repos/mesonbuild/meson/issues/2169/events","html_url":"https://github.com/mesonbuild/meson/pull/2169","id":249208877,"number":2169,"title":"Add option to search for .pc files in $prefix/$libdir/pkgconfig","user":{"login":"zeehio","id":75441,"avatar_url":"https://avatars2.githubusercontent.com/u/75441?v=4","gravatar_id":"","url":"https://api.github.com/users/zeehio","html_url":"https://github.com/zeehio","followers_url":"https://api.github.com/users/zeehio/followers","following_url":"https://api.github.com/users/zeehio/following{/other_user}","gists_url":"https://api.github.com/users/zeehio/gists{/gist_id}","starred_url":"https://api.github.com/users/zeehio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeehio/subscriptions","organizations_url":"https://api.github.com/users/zeehio/orgs","repos_url":"https://api.github.com/users/zeehio/repos","events_url":"https://api.github.com/users/zeehio/events{/privacy}","received_events_url":"https://api.github.com/users/zeehio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-10T01:41:15Z","updated_at":"2017-08-10T02:47:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mesonbuild/meson/pulls/2169","html_url":"https://github.com/mesonbuild/meson/pull/2169","diff_url":"https://github.com/mesonbuild/meson/pull/2169.diff","patch_url":"https://github.com/mesonbuild/meson/pull/2169.patch"},"body":"pgk-config `.pc` files are written by meson to `$prefix/$libdir/pkgconfig`. However, that same path is not used by meson to look for dependencies.\r\n\r\nWhen multiple projects are installed to the same custom prefix, meson knows how to write .pc files to\r\n`$prefix/$libdir/pkgconfig` in all projects, but meson is not able to find already installed .pc files in that prefix.\r\n\r\nThe use of subprojects (and wraps) to install missing dependencies automatically to the `$prefix` directory is not practical, as the `dependency()` will not be detected and it will always be reported as missing (because meson does not tell pkg-config to look into `$prefix/$libdir/pkgconfig`).\r\n\r\nAs a workaround, the user building the projects needs to be smart enough to know where meson is installing the .pc files and define in advance the environment variable `PKG_CONFIG_PATH=$prefix/$libdir/pkgconfig`, so .pc files can be found.\r\n\r\nGiven that meson *decides* where to write the .pc files inside the `$prefix`, it is reasonable that meson checks *that same path* when looking for dependencies.\r\n\r\nTelling the user to find the right `PKG_CONFIG_PATH` value is counter-intuitive, as if meson ever decided to change the installation path it would force all users to fix their extra environment variables, and meson can easily take care of reporting the prefix to pkg-config, if desired.\r\n\r\npkg-config by design gives a special treatment to the `/usr/local` and `/usr` prefixes over the rest, as they are always searched for .pc files. `pkg-config` is not aware of the `$prefix`, unless the user (or meson) reports the path to it.\r\n\r\nmeson currently gives a special treatment to the `$prefix` when writing .pc files, but does not give the equivalent treatment when looking for .pc files. This pull request addresses that, by allowing the\r\ndefinition of a `search_prefix` argument to `dependency()`. The meson instruction:\r\n\r\n    dep = dependency('core_project', search_prefix: true)\r\n\r\nlooks for `core_project.pc` in the `PKG_CONFIG_PATH` (if defined by the user),\r\nin `$prefix/$libdir/pkgconfig` and in `PKG_CONFIG_LIBS` (in that order).\r\n\r\nThe default value for `search_prefix` is false, in order to preserve backwards compatibility. A test case is included.\r\n\r\nFeel free to close the pull request if you don't like the patch or the idea behind it. Thanks for meson and for your time reading this."},"comment":{"url":"https://api.github.com/repos/mesonbuild/meson/issues/comments/321435662","html_url":"https://github.com/mesonbuild/meson/pull/2169#issuecomment-321435662","issue_url":"https://api.github.com/repos/mesonbuild/meson/issues/2169","id":321435662,"user":{"login":"arteymix","id":1318477,"avatar_url":"https://avatars1.githubusercontent.com/u/1318477?v=4","gravatar_id":"","url":"https://api.github.com/users/arteymix","html_url":"https://github.com/arteymix","followers_url":"https://api.github.com/users/arteymix/followers","following_url":"https://api.github.com/users/arteymix/following{/other_user}","gists_url":"https://api.github.com/users/arteymix/gists{/gist_id}","starred_url":"https://api.github.com/users/arteymix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arteymix/subscriptions","organizations_url":"https://api.github.com/users/arteymix/orgs","repos_url":"https://api.github.com/users/arteymix/repos","events_url":"https://api.github.com/users/arteymix/events{/privacy}","received_events_url":"https://api.github.com/users/arteymix/received_events","type":"User","site_admin":false},"created_at":"2017-08-10T02:47:28Z","updated_at":"2017-08-10T02:47:28Z","body":"While the idea is great, I don't think it generalize well because there could be many more variables we could define at configure-time this way (e.g. `GI_TYPELIB_PATH`, `LD_LIBRARY_PATH`, ...). Thus having them explicitly when you call `meson` seems to be the best approach, not a workaround."}}
{"actor":{"display_login":"arteymix"}}