[vlc-devel] [PATCH] Enhance cmake based contribs cross-compilation

Olivier Gambier olivier at webitup.fr
Thu Jan 26 14:24:58 CET 2012

Le 25 janv. 2012 à 09:46, Rémi Denis-Courmont a écrit :

> On Wed, 25 Jan 2012 02:02:50 +0100, Olivier Gambier <olivier at webitup.fr>
> wrote:
>> Hi,
>> If I understand correctly, we are able to cross-compile cmake based
>> contribs only for windows and osx targets - because we don't specify a
>> CMAKE_SYSTEM_NAME for anything else (in main.mak).
>> Actually, this fact does prevent from building correctly at least taglib
>> and musepack from OSX to Linux (compilation partly works, but it fails
>> linking due to cmake thinking this is a native build and trying to use
>> system tools).
>> It seems the needed fix is just to specify explicitly  a
>> in the toolchain file (http://www.vtk.org/Wiki/CMake_Cross_Compiling)
>> If that sounds ok, I would like to propose the attached patch.
>> It should alter the behavior ONLY when cross-compiling to a linux
> target.
>> But I guess that might alter things when targeting android, right? In
> that
>> case, and if that wouldn't be desirable, I guess we could amend the
> patch
>> to exclude android and keep the current state of affairs for that
> platform
>> (whatever it is).
>> What do you think?
> I do not see why you need to check for cross-compilation, but then again I
> have not tested with nor without the check.

I just tested on a Ubuntu oneiric host.
Setting CMAKE_SYSTEM_NAME doesn't seem to make any difference (using the default compiler).

About "why" it does work when crosscompiling for android, I have no idea why. Is it possible that CMake magically inspect the CC variable for the --sysroot param which is set explicitly in main.mak?

I'm sorry I couldn't find more info about CMake behavior in these cases.
I guess we should either be cautious (as suggested) and only set CMAKE_SYSTEM_NAME where we know for sure it will work (the originally sent patch plus a check to exclude Android), or test an android build beforehand (I just started setting-up my environment to build android - but the doc here http://wiki.videolan.org/AndroidCompile seems outdated - correct? - and am not yet there). 

What do you think?

Thanks a lot!


- Olivier

More information about the vlc-devel mailing list