[CMake] What's the 'Modern' way to determine machine endianness?

Kent Williams norman-k-williams at uiowa.edu
Fri Jun 10 17:45:29 EDT 2005


I just fixed a problem with the CMake files for fltk 1.1.x -- the 
config.h file was always #defining WORDS_BIGENDIAN as zero, which made 
any call to fl_draw_image to look wrong.

But, the only way I found to get the endian-ness into the config.h file 
was to do what ITK still does:

In CMakeLists.txt:
I'm trying to get the CMakeLists.txt files for FLTK to work properly on 
Mac OSX. The real dealbreaker is this:
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)

In configh.cmake.in:
#cmakedefine CMAKE_WORDS_BIGENDIAN
#ifdef CMAKE_WORDS_BIGENDIAN
  #define WORDS_BIGENDIAN 1
#else
  #define WORDS_BIGENDIAN 1
#endif

Now that works just fine but it begs the question: Anything labeled 
'BackwardsCompatibility' is a priori deprecated, but I don't know of any 
way to detect endian-ness in CMake that doesn't depend on the 
CMakeBackwardCompatibility*.cmake files.

Is there something, and I'm just missing it?



More information about the CMake mailing list