GUI: improve systray tooltips
[trojita.git] / cmake / FindRagelForTrojita.cmake
blob162ae7c4c6d075468121bb6e00edfac7c6bc3273
2 IF(NOT RAGEL_EXECUTABLE)
3         MESSAGE(STATUS "Looking for ragel")
4         FIND_PROGRAM(RAGEL_EXECUTABLE ragel)
5         IF(RAGEL_EXECUTABLE)
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)
21         IF(NOT RAGEL_FLAGS)
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}")
30                 SET(_flags ${ARGV1})
31                 IF(NOT _flags)
32                         SET(_flags ${RAGEL_FLAGS})
33                 ENDIF(NOT _flags)
34                 ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILE}
35                         COMMAND "${RAGEL_EXECUTABLE}"
36                         ARGS -C ${_flags} -o "${OUTFILE}" "${INFILE}"
37                         DEPENDS "${INFILE}"
38                         COMMENT "Generating ${SRCBASE}.generated.cpp from ${SRCFILE}"
39                 )
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)