CheckSizeOf.cmake 702 B

12345678910111213141516171819
  1. #
  2. # Check if the type exists and determine size of type. if the type
  3. # exists, the size will be stored to the variable.
  4. #
  5. # CHECK_TYPE_SIZE - macro which checks the size of type
  6. # VARIABLE - variable to store size if the type exists.
  7. #
  8. MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
  9. TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
  10. ${PROJECT_BINARY_DIR}
  11. ${CMAKE_ROOT}/Modules/CheckSizeOf.c
  12. COMPILE_DEFINITIONS -DCHECK_SIZE_OF="${TYPE}"
  13. OUTPUT_VARIABLE OUTPUT)
  14. IF(NOT HAVE_${VARIABLE})
  15. WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log
  16. "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\n")
  17. ENDIF(NOT HAVE_${VARIABLE})
  18. ENDMACRO(CHECK_TYPE_SIZE)