[CMake] Find* and cross compiling

Alexander Neundorf a.neundorf-work at gmx.net
Sat Dec 29 09:36:19 EST 2007


On Saturday 29 December 2007, Rodolfo Lima wrote:
> Hi all,
> I've been exercising cmake-cvs's cross-compiling capabilities and I've
> noticed that the way several Find* scripts work doesn't behave well with
> cross-compiling.
>
> Usually when doing this kind of builds (at least in linux), one have a
> place (for instance /usr/i686-mingw32-pc) where all binaries compiled to
>  run on the target platform resides.
>
> When looking for installed libraries, the Find* first try to look into
> this prefix (/usr/i686-mingw32-pc), but it it doesn't find, they
> continue by looking into /usr, picking the incorrect binaries, since
> these are compiled to the native system.
>
> I've found those issues in FindLua*.cmake, FindFreetype.cmake and
> others. The reason is that they specify '/usr', '/usr/local', ... as
> search paths, instead of relying on the correct cmake's default.
>
> If the developers agree that this is a major blocker for cross-compiling
> with cmake, I could help by correcting some scripts. Just let me know.

I guess you read the wiki page:
http://www.cmake.org/Wiki/CMake_Cross_Compiling

Do you have the following in your toolchain file ?

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

By setting the mode to ONLY cmake will look ONLY in the directories with the 
CMAKE_FIND_ROOT_PATH prefix.

Doesn't that work / did I minunderstand something ?

Alex



More information about the CMake mailing list