How to use CMake big-endian test?

Michael Hansen zrax0111 at gmail.com
Thu Feb 24 17:19:51 GMT 2011


You need to actually forward the variable to your compiler defines, for 
example:

INCLUDE(TestBigEndian)

TEST_BIG_ENDIAN(BIGENDIAN)
IF(${BIGENDIAN})
     ADD_DEFINITIONS(-DBIGENDIAN)
ENDIF(${BIGENDIAN})


- Michael



On 2/15/2011 2:17 PM, Pierre Abbat wrote:
> I don't know where to ask, but I recently converted a project to CMake as a
> result of switching to KDevelop 4, so I figured I'd ask here.
>
> I have a project in KDevelop 4.1.0 with the following CMakeLists file:
> ---
> project(tone12)
>
> add_executable(tone12 tone12.cpp midi.cpp midi.h riffwave.cpp riffwave.cpp
> tonegen.cpp tonegen.h)
>
> INCLUDE(CPack)
> INCLUDE(TestBigEndian)
>
> TEST_BIG_ENDIAN(BIGENDIAN)
> ---
> I am starting to write the MIDI file reading routine, which requires knowing
> the endianness, as the size of chunks is stored big-endian, and I need to
> know whether to flip it. I succeeded in getting the endian test result in
> CMakeCache, but I don't know how to let the source code know what it is. How
> do I make a config.h, or the equivalent, containing the result of the test?
>
> Pierre





More information about the KDevelop mailing list