[CMake] pkgconfig and cross compiling

Erik de Castro Lopo mle+tools at mega-nerd.com
Mon Nov 3 17:22:44 EST 2008


Alexander Neundorf wrote:

> 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.

I'm not really sure this is the right solution or rather it is a
solution that is quite different from the one that the autotools
are (slowly) heading towards.

The way autotools intend to handle this is follows. When cross
compiling to say an i586-pc-mingw32msvc target, the autoconf
generated configure script will look for a program or script
called i586-pc-mingw32msvc-pkg-config, much the same as it would
look for a C compiler called i586-pc-mingw32msvc-gcc.

Currently if the configure script can't find
<cross-compiler>-pkg-config it defaults to the native version of
the tool "pkg-config", but this is almost always a mistake and
that using the native pkg-config as a fallback is actually
deprecated behaviour.

HTH,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Every 5 minutes you spend writing code in a new language is more useful
than 5 hours reading blog posts about how great the language is."
-- Des Traynor


More information about the CMake mailing list