2 IF(NOT RAGEL_EXECUTABLE)
3 MESSAGE(STATUS "Looking for ragel")
4 FIND_PROGRAM(RAGEL_EXECUTABLE ragel)
6 EXECUTE_PROCESS(COMMAND "${RAGEL_EXECUTABLE}" -v OUTPUT_VARIABLE _version)
7 STRING(REGEX MATCH "[0-9.]+" RAGEL_VERSION ${_version})
8 SET(RagelForTrojita_FOUND TRUE)
9 ENDIF(RAGEL_EXECUTABLE)
10 ELSE(NOT RAGEL_EXECUTABLE)
11 EXECUTE_PROCESS(COMMAND "${RAGEL_EXECUTABLE}" -v OUTPUT_VARIABLE _version)
12 STRING(REGEX MATCH "[0-9.]+" RAGEL_VERSION ${_version})
13 SET(RagelForTrojita_FOUND TRUE)
14 ENDIF(NOT RAGEL_EXECUTABLE)
16 IF(RagelForTrojita_FOUND)
17 IF (NOT RagelForTrojita_FIND_QUIETLY)
18 MESSAGE(STATUS "Found ragel: ${RAGEL_EXECUTABLE} (${RAGEL_VERSION})")
19 ENDIF (NOT RagelForTrojita_FIND_QUIETLY)
22 SET(RAGEL_FLAGS "-T1")
23 ENDIF(NOT RAGEL_FLAGS)
25 MACRO(RAGEL_PARSER SRCFILE)
26 GET_FILENAME_COMPONENT(SRCPATH "${SRCFILE}" PATH)
27 GET_FILENAME_COMPONENT(SRCBASE "${SRCFILE}" NAME_WE)
28 SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/${SRCBASE}.generated.cpp")
29 SET(INFILE "${SRCFILE}")
32 SET(_flags ${RAGEL_FLAGS})
34 ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILE}
35 COMMAND "${RAGEL_EXECUTABLE}"
36 ARGS -C ${_flags} -o "${OUTFILE}" "${INFILE}"
38 COMMENT "Generating ${SRCBASE}.generated.cpp from ${SRCFILE}"
40 ENDMACRO(RAGEL_PARSER)
42 ELSE(RagelForTrojita_FOUND)
44 IF(Ragel_FIND_REQUIRED)
45 MESSAGE(FATAL_ERROR "Could not find ragel")
46 ENDIF(Ragel_FIND_REQUIRED)
47 ENDIF(RagelForTrojita_FOUND)