Bug 40008

Summary: Detect telepathy-glib in right directory
Product: Telepathy Reporter: Stef Walter <stefw>
Component: tp-qtAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: drf54321
Version: git masterKeywords: patch
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/stefw/telepathy-qt4.git/log/?h=build-fixes
Whiteboard:
i915 platform: i915 features:
Attachments: Ignore telepathy-glib installs in system when using another prefix

Description Stef Walter 2011-08-11 05:52:34 UTC
If PKG_CONFIG_PATH is set (such as during jhbuild) telepathy-glib is detected in the alternate directory, but the libraries and include files are then used from the system directories.

example:


$ pkg-config telepathy-glib --modversion
0.14.9
$ PKG_CONFIG_PATH=~/build/telepathy/lib64/pkgconfig pkg-config telepathy-glib --modversion
0.15.4.1
$ cd ~/projects/telepathy-qt4
$ PKG_CONFIG_PATH=~/build/telepathy/lib64/pkgconfig cmake .
<snip>
-- checking for module 'telepathy-glib>=0.15.1'
--   found telepathy-glib, version 0.15.4.1
-- Found TelepathyGlib: /usr/lib64/libtelepathy-glib.so 
<snip>
Comment 1 Stef Walter 2011-08-11 05:55:01 UTC
Created attachment 50123 [details] [review]
Ignore telepathy-glib installs in system when using another prefix

If using another build prefix PKG_CONFIG_PATH is set. This means that
pkg-config finds telepathy-glib.pc in the alternate prefix. However
if telepathy-glib is also installed, the cmake code then goes and uses
find_library/find_path, which by default use system directories.

Remove usage of system directories, in the case where the pkg-config file
is found.
Comment 2 Stef Walter 2011-08-11 05:55:46 UTC
After patch:

$ PKG_CONFIG_PATH=/data/build/telepathy/lib64/pkgconfig cmake .
<snip>
-- checking for module 'telepathy-glib>=0.15.1'
--   found telepathy-glib, version 0.15.4.1
-- Found TelepathyGlib: /data/build/telepathy/lib64/libtelepathy-glib.so 
<snip>
Comment 4 Stef Walter 2011-08-11 06:02:07 UTC
Oh and without this build patch I obviously get build failures for telepathy-glib features used in telepathy-qt4 but not in my system telepathy-glib.
Comment 5 George Kiagiadakis 2016-10-09 09:46:59 UTC
Afaik, find_path() and find_library() are meant to look first in the paths specified on their call, so they *should* use the pkg-config discovered paths BEFORE looking at the system paths. If this bug is still valid, I suspect there is something fishy about those PC_* variables. It may also have been a cmake bug at the time...

In any case, I am not convinced that this patch is the correct approach.
Comment 6 Alexandr Akulich 2019-11-19 09:32:21 UTC
We used to call find_library with PATHS option, but it has the lowest priority, this the standard system environment variables processed first. Use HINTS option to ensure the right order of lookup directories.

See also: https://cmake.org/cmake/help/latest/command/find_library.html

https://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=92d1c0966d52887fe84718d5c769198956053f64

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.