[CMake] pkg-config and Cross_compiling

Hendrik Sattler post at hendrik-sattler.de
Wed Jul 2 13:39:17 EDT 2008


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!

Additionally, I found that the include paths are another source of problems, 
not fully covered by the cmake cross compiling, yet. You really have to -I 
any path that is not known and specific to the cross compiler, using 
INCLUDE_DIRECTORIES(). This is not done automatically for the changed 
ROOT_PATH, yet. So eventually, the cross-compiled programs ends up including 
the wrong files :-(
You have to be careful with that...

The CMAKE_TOOLCHAIN_FILE can be used to set both, but this could also be 
handled automatically.

HS


More information about the CMake mailing list