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

Olivier Gambier olivier at webitup.fr
Wed Jan 25 10:49:42 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
> CMAKE_SYSTEM_NAME
>> 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 wanted to be sure this patch altered as little as possible of the existing behavior. Now, if you think we can ditch that, fair enough.

The bottom line being (in my understanding) that if we use CMAKE_SYSTEM_NAME, cmake will assume we are cross-compiling and will try to find tools in the specified C compiler toolchain instead of using the system ones, and I'm not currently at ease with the possible consequences (I experienced some weird behavior when fiddling with CMAKE - for example, specifying explicitly some other variables in the toolchain file, like CMAKE_LINKER, results in failure to cache the linker name for the lack of having searched for it…).
Note that I'm not a CMAKE wizard...

On the other hand, if we were to use CMAKE_SYSTEM_NAME generally (and not only when cross-compiling), I guess this patch is not enough (the only list I found is here: http://synergy-foss.org/tracker/projects/synergy/repository/revisions/413/entry/trunk/tool/win/cmake/share/cmake-2.8/Modules/CMakeDetermineSystem.cmake)

Either way, am still curious of what happens when building for Android. Does anyone knows if it actually works for taglib?


What do you think?


Best regards,

- Olivier



More information about the vlc-devel mailing list