[CMake] pkg-config and Cross_compiling

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jul 5 17:44:03 EDT 2008


On Thursday 03 July 2008, Wookey wrote:
> On 2008-07-02 19:39 +0200, Hendrik Sattler wrote:
> > Am Mittwoch, 2. Juli 2008 18:59:37 schrieb Wookey:
> > > I tried to fix the FindPkgConfig.cmake file to automaticaly do this,
> > > but found that it uses execute_process to call pkg-config and there
> > > seems to be no way to set an environment variable with this call. Am I
> > > missing something? Fixing this module to look in
> > > CMAKE_FIND_ROOT_PATH when cross-compiling seems like the best fix to
> > > me, but there may be a better way?
> >
> > Yes, that should be fixed. It should work to use SET() to set an
> > environment variable and the child process from EXECUTE_PROCESS should
> > get the copy of that environment. BUT: you must use PKG_CONFIG_LIBDIR
> > instead of PKG_CONFIG_PATH!
>
> Ah, so I do - well done. That will avoid native libs being found.
>
> I got the impression that SET() only set CMAKE variables, not
> environment ones, but maybe they ammount to the same thing?
> <fx: reads docs again> Ah, yes there is the ENV{} syntax. Brill. that
> means I can now add
>
> IF (CMAKE_CROSSCOMPILING)
>   SET(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig/)
>
> to the toolchain file and that works fine.
>
> Putting that in FindPkgConfig.cmake should do the trick.

Can you please do that, test it and send a patch ?
I wanted to do this since quite some time but haven't got around to do it 
actually.

Alex


More information about the CMake mailing list