[CMake] Finding out the Endianness of a system at CMake config
time
Brandon J. Van Every
bvanevery at gmail.com
Wed Nov 22 12:36:25 EST 2006
Mike Jackson wrote:
> I have recently joined a project where I am to do some coding. The
> code base is cross platform HPC type code and the original coders have
> defined their own little/big endian #defines (L_ENDIAN & B_ENDIAN).
> They pass this into the compiler via -DL_ENDIAN during compiles.
>
> Is there a way to automatically have cmake figure this out for me?
> Right now I have an OPTION(....) clause in my CMakeLists.txt file to
> select the right value.. which is stupid and error prone but it worked
> to boot strap the process for the moment.
>
> Any hints would be appreciated..
You could do a TRY_COMPILE with a snippet of C code that tests for
endinanness. I always forget how to write such a snippet off the top of
my head. I typically look at an Autoconf ./configure script to see what
they did, or Google around for it. The Chicken Scheme CMake build has
an example of detecting whether the stack grows downward, in
StackGrowsDownward.c.
Cheers,
Brandon Van Every
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20061122/6794b380/attachment.htm
More information about the CMake
mailing list