title: Detect Endianness with CMake
body: <p>My library needs to read-in big-endian integers (4-bytes) and convert them to the endian order of the host for processing.  While on *nix <code>ntohl</code> has worked a treat under Windows use of <code>ntohl</code> requires the use of <code>Ws2_32.dll</code> (Winsock).</p>
  
  <p>Such a dependency is one which I would rather eliminate.  The simplest way to do this appears to be to write my own endian-swapping function (a trivial exercise, considering performance is not a real concern).  However, this requires a way to determine the endianness of the system my library is being compiled on (so I can <code>#ifdef</code> out the swapping function on big endian systems).</p>
  
  <p>As there appears to be no standard preprocessor definition for endianness it appears as if it is necessary to determine it using my build system (cmake).  What is the best means of doing this?  (I am weary of 'compile a test file and see' type solutions as they would appear to inhibit cross-compiling.)</p>