TestBigEndian.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #
  2. # Check if the system is big endian or little endian
  3. #
  4. # VARIABLE - variable to store the result to
  5. #
  6. MACRO(TEST_BIG_ENDIAN VARIABLE)
  7. IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
  8. TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
  9. ${CMAKE_BINARY_DIR}
  10. ${CMAKE_ROOT}/Modules/TestBigEndian.c
  11. OUTPUT_VARIABLE OUTPUT)
  12. MESSAGE(STATUS "Check if the system is big endian")
  13. IF(HAVE_${VARIABLE})
  14. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  15. "Determining the endianes of the system passed. The system is ")
  16. IF(${VARIABLE})
  17. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  18. "big endian")
  19. MESSAGE(STATUS "Check if the system is big endian - big endian")
  20. ELSE(${VARIABLE})
  21. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  22. "little endian")
  23. MESSAGE(STATUS "Check if the system is big endian - little endian")
  24. ENDIF(${VARIABLE})
  25. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  26. "Test produced following output:\n${OUTPUT}\n\n")
  27. ELSE(HAVE_${VARIABLE})
  28. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  29. "Determining the endianes of the system failed with the following output:\n${OUTPUT}\n\n")
  30. MESSAGE("Check if the system is big endian - failed")
  31. ENDIF(HAVE_${VARIABLE})
  32. ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
  33. ENDMACRO(TEST_BIG_ENDIAN)