[CMake] How to find/run external host executables when using cross compiling

Eric Noulard eric.noulard at gmail.com
Tue Dec 10 03:02:09 EST 2013


2013/12/10 Eric Wing <ewmailing at gmail.com>:
> On 12/4/13, Eric Wing <ewmailing at gmail.com> wrote:
>> I'm currently trying to port a rather large, complex project to
>> Android. It has an existing CMake project so I'm trying to leverage
>> that. I've taken and enhanced one of the Android-CMake toolchains I've
>> found.
>>
>> This particular project I'm porting has unfortunate dependencies on
>> running the host system's Perl, Python, and Ruby interpreters to do
>> various kinds of on-the-fly code generation.
>>
>> The problem I'm having is that with the cross-compilation toolchain,
>> none of these (host) dependencies are found with CMake (I think it
>> uses FindPackage) because the cross-compilation toolchain has
>> sandboxed off everything to look in the target toolchain which won't
>> have Perl/Python/Ruby (which is completely reasonable; I'm not
>> complaining).
>>
>> But I need to solve this problem and figure out how to find/invoke the
>> host Perl/Python/Ruby/etc so my cross-compile can work.
>>
>> Can anybody give me suggestions on how I should approach this?
>
> Bump.
> I have a temporary workaround in place where I comment out the
> find_package calls for Perl/Python/Ruby, and then use -D switches with
> CMake to pre-populate the correct values for my host system.

find_package may not work entirely (because it looking for headers, lib etc...)
but find_program should if you set

CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
to NEVER (or may be BOTH)
see:
http://www.cmake.org/Wiki/CMake_Cross_Compiling

host executable should be found.

-- 
Erk
L'élection n'est pas la démocratie -- http://www.le-message.org


More information about the CMake mailing list