[CMake] pkgconfig and cross compiling

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Nov 3 22:32:36 EST 2008

On 2008-11-03 23:20+0100 Alexander Neundorf wrote:

> Hi,
> I still have an uncommitted patch lying around here, you can find it attached.
> It deals with pkgconfig when cross compiling.
> What it does it sets the environment variable PKG_CONFIG_LIBDIR to the
> pkgconfig subdirs of each of the directories in CMAKE_FIND_ROOT_PATH.
> E.g. if you have /opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP in CMAKE_FIND_ROOT_PATH,
> then PKG_CONFIG_LIBDIR will contain
> /opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP/usr/lib/pkgconfig .
> This has the effect that pkgconfig will now first (?) look in the
> pkgconfig-directories for the target architecture and return the results from
> there.
> But there are some issues:
> -after checking the dirs from PKG_CONFIG_LIBDIR, it checks the dirs from
> PKG_CONFIG_PATH. E.g. on my system, PKG_CONFIG_PATH is set
> to /usr/lib/pkgconfig and /usr/local/lib/pkgconfig. This means that if
> somethign wasn't found in CMAKE_FIND_ROOT_PATH, it will still be found for my
> host system. This is wrong. But always setting PKG_CONFIG_PATH empty also
> doesn't sound good, since it may have been set on purpose. What to do here ?

Hi Alex:

I don't get the behaviour you describe for my version of pkg-config

For that version of pkg-config, if I point PKG_CONFIG_LIBDIR to a directory
then if the required *.pc file is not in that directory, then it gives an
error message and quits, i.e., it finds nothing else regardless of how
PKG_CONFIG_PATH is set. As you have stated that is the ideal behaviour for

I suspect the problem is you are using a really old version of pkg-config.
There is a bug report at https://bugs.freedesktop.org/show_bug.cgi?id=3093
that describes the incorrect behaviour of PKG_CONFIG_LIBDIR that you see on
your system.  That bug was fixed as of version pkg-config 0.18 (released in
June 2005).

So install a recent version of pkg-config, and I think your troubles with
PKG_CONFIG_LIBDIR will be over.

Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project

Linux-powered Science

More information about the CMake mailing list