MACRO (FINDRESTRICT)
  GET_PROPERTY(source_dir_set GLOBAL PROPERTY MYPACKAGE_SOURCE_DIR SET)
  IF (NOT ${source_dir_set})
    MESSAGE (WARNING "Cannot check restrict, property MYPACKAGE_SOURCE_DIR is not set")
  ELSE ()
    IF (NOT C_RESTRICT_SINGLETON)
      GET_PROPERTY(source_dir GLOBAL PROPERTY MYPACKAGE_SOURCE_DIR)
      SET (_C_RESTRICT_FOUND FALSE)
      #
      # Test
      #
      FOREACH (KEYWORD "__restrict" "__restrict__" "_Restrict" "restrict")
        MESSAGE(STATUS "Looking for ${KEYWORD}")
        TRY_COMPILE (C_HAS_${KEYWORD} ${CMAKE_CURRENT_BINARY_DIR}
          ${source_dir}/restrict.c
          COMPILE_DEFINITIONS -DC_RESTRICT=${KEYWORD})
        IF (C_HAS_${KEYWORD})
          MESSAGE(STATUS "Looking for ${KEYWORD} - found")
          SET (_C_RESTRICT ${KEYWORD})
          SET (_C_RESTRICT_FOUND TRUE)
          BREAK ()
        ENDIF ()
      ENDFOREACH ()
    ENDIF ()
    IF (_C_RESTRICT_FOUND)
      SET (C_RESTRICT "${_C_RESTRICT}" CACHE STRING "C restrict implementation")
      MARK_AS_ADVANCED (C_RESTRICT)
    ENDIF ()
    SET (C_RESTRICT_SINGLETON TRUE CACHE BOOL "C restrict check singleton")
    MARK_AS_ADVANCED (C_RESTRICT_SINGLETON)
  ENDIF ()
ENDMACRO()
