
MACRO(CHECK_CHECKSUM_FILE CRC_LOCATION FILE_CRC CHECKSUM_FILE )
    EXECUTE_PROCESS (
        COMMAND ${CRC_LOCATION} -q -c ${FILE_CRC} -f ${CHECKSUM_FILE}
        RESULT_VARIABLE PROCESS_RESULT
        ERROR_VARIABLE  PROCESS_ERROR
        OUTPUT_QUIET
    )

    IF ( NOT ${PROCESS_RESULT} EQUAL 0 )
        IF ( ${CRC_CHECK} STREQUAL "ON" )
            MESSAGE ( STATUS "WARNING: The CRC checksum file (${CHECKSUM_FILE}) has been manipulated" )
        ELSE ( ${CRC_CHECK} STREQUAL "ON" )
            MESSAGE ( FATAL_ERROR "FATAL: The CRC checksum file (${CHECKSUM_FILE}) has been manipulated" )
        ENDIF ( ${CRC_CHECK} STREQUAL "ON" )

    ENDIF ( NOT ${PROCESS_RESULT} EQUAL 0 )
ENDMACRO()

IF ( NOT EXISTS ${CRC_LOCATION} )
    MESSAGE ( FATAL_ERROR "checkcrc could not be found at location: ${CRC_LOCATION}" )
    RETURN ()
ENDIF ( NOT EXISTS ${CRC_LOCATION} )

CHECK_CHECKSUM_FILE ( "${CRC_LOCATION}" "${openSAFETY_STACK_CRC}" "${openSAFETY_STACK_FILE}" )
