[CMake] pkg-config and Cross_compiling

Enrico Scholz enrico.scholz at informatik.tu-chemnitz.de
Sat Jul 5 18:30:16 EDT 2008


Wookey <wookey at wookware.org> writes:

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

You should use a target specific version of 'pkgconfig'
(e.g. arm-linux-gnu-pkgconfig) which is configured with a proper
searchpath.  Dunno about the cmake cross stuff (-> effect of
find_program()), but autoconf probes for programs (AC_CHECK_TOOLS) by
prefixing the target tuple when crosscompiling (e.g. check for
'arm-xscale-linux-gnu-FOO' instead of 'FOO').

Another way might be to provide a $PATH which prefers cross-tools to native
ones (e.g. /usr/arm-xscale-linux-gnu/bin/gcc instead of /usr/bin/gcc).

In both ways, the cross-pkgconfig can be specified on the cmake
commandline:

| cmake -DPKG_CONFIG_EXECUTABLE=arm-xscale-linux-gnu-pkgconfig



Enrico



More information about the CMake mailing list