[CMake] pkgconfig and cross compiling

Hendrik Sattler post at hendrik-sattler.de
Tue Nov 4 04:13:24 EST 2008


Alexander Neundorf schrieb:
> -Once it found the correct pc-file, it returns the result. Problem: the 
> results don't contain the target architecture prefix, e.g. here incdir 
> gives "/usr/include" while it should be 
> /opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP/usr/include .
> So what to do ? Try to automatically adjust it by adding some appropriate path 
> in the beginning ? Ignore it and use the wrong include dir ? Sounds even 
> worse.

$export PKGCONFIG_LIB_DIR=/opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP
$pkg-config \
  --define-variable=prefix=/opt/eldk-4.1/ppc_4xxFP/ppc_4xxFP/usr/ \
  some_package

should give you the correct result as the other paths should be defined
relative to prefix.

BTW: <cross>-pkg-config as proposed here should indeed be used if
present. However(!) and like the one above, it will also fail if you
have more than one root prefix.
The right fix would be to do the same as on Windows and automatically
define prefix relative to the location of the .pc file that is currently
in use (and remove the prefix variable from all those files). And then,
the <cross>-pkg-config is just useful for the case that the build host
does not have pkg-config itself.

HS


More information about the CMake mailing list