CheckFunctionExists.cmake 746 B

12345678910111213141516171819202122
  1. #
  2. # Check if the function exists.
  3. #
  4. # CHECK_FUNCTION_EXISTS - macro which checks if the function exists
  5. # FUNCTION - the name of the function
  6. # VARIABLE - variable to store the result
  7. #
  8. MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
  9. TRY_COMPILE(COMPILE_OK
  10. ${PROJECT_BINARY_DIR}
  11. ${CMAKE_ROOT}/Modules/CheckFunctionExists.c
  12. COMPILE_DEFINITIONS -DCHECK_FUNCTION_EXISTS=${FUNCTION}
  13. OUTPUT_VARIABLE OUTPUT)
  14. IF(COMPILE_OK)
  15. SET(${VARIABLE} ${COMPILE_OK})
  16. ELSE(COMPILE_OK)
  17. WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log
  18. "Determining if the function ${FUNCTION} exists failed with the following output:\n"
  19. "${OUTPUT}\n")
  20. ENDIF(COMPILE_OK)
  21. ENDMACRO(CHECK_FUNCTION_EXISTS)