[CMake] anybody crosscompiling and using pkg_config ?

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jul 19 04:25:11 EDT 2008


On Saturday 19 July 2008, you wrote:
> On 2008-07-19 00:04+0200 Alexander Neundorf wrote:
> > Hi,
> >
> > when crosscompiling, pkg_config shouldn't find packages for the host
> > system, but for the target system.
> > Attached is a patch against current cmake cvs which tries to do that by
> > setting the env var PKG_CONFIG_LIBDIR to /usr/lib/pkgconfig
> > and /usr/local/lib/pkgconfig inside the directories of
> > CMAKE_FIND_ROOT_PATH.
>
> Just an "overview" question about this proposed approach.  Is this
> complication really necessary?  Why not just let the user who needs
> cross-compilation simply set the pkg-config environment variables he needs
> without messing with them inside CMake?

Well, we had complaints that the pkg_config stuff finds host packages when 
cross compiling, this should fix it (not sure we actually have a bug report 
for this).
Also the user (the one who cross compiles a package) may not be aware that the 
cmake files use pkg-config internally, so he might get wrong results. It is 
not obvious from e.g.
find_package(LibXml2)
that you need to adjust PKG_CONFIG_LIBDIR externally.

Maybe better than just setting would be to read it, if it's empty, set it, if 
it's not empty
-set it nevertheless
-do nothing
-append the dirs
-prepend the dirs

I think I'd prefer the last option, since the dirs added by cmake will be 
inside the target environment and so really shouldn't produce wrong results.

> I set PKG_CONFIG_PATH a lot in my normal use of my various CMake-based
> build systems, and it is no trouble at all. 

Hmm, I never do. 

Alex


More information about the CMake mailing list