Fix comment to use llvm 2.x syntax.
[llvm/stm8.git] / cmake / modules / FindBison.cmake
blob0320ae3ce142eed0e4cfd61778b44aa6540d5a16
1 # - Try to find Bison
2 # Once done this will define
4 #  BISON_FOUND - system has Bison
5 #  BISON_EXECUTABLE - path of the bison executable
6 #  BISON_VERSION - the version string, like "2.5.31"
9 MACRO(FIND_BISON)
10         FIND_PROGRAM(BISON_EXECUTABLE NAMES bison)
12         IF(BISON_EXECUTABLE)
13                 SET(BISON_FOUND TRUE)
15                 EXECUTE_PROCESS(COMMAND ${BISON_EXECUTABLE} --version
16                         OUTPUT_VARIABLE _BISON_VERSION
17                 )
18                 string (REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" BISON_VERSION "${_bison_VERSION}")
19         ENDIF(BISON_EXECUTABLE)
21         IF(BISON_FOUND)
22           IF(NOT Bison_FIND_QUIETLY)
23                 MESSAGE(STATUS "Found Bison: ${BISON_EXECUTABLE}")
24           ENDIF(NOT Bison_FIND_QUIETLY)
25         ELSE(BISON_FOUND)
26           IF(Bison_FIND_REQUIRED)
27                 MESSAGE(FATAL_ERROR "Could not find Bison")
28           ENDIF(Bison_FIND_REQUIRED)
29         ENDIF(BISON_FOUND)
30 ENDMACRO(FIND_BISON)
32 MACRO(BISON_GENERATOR _PREFIX _Y_INPUT _H_OUTPUT _CPP_OUTPUT)
33         IF(BISON_EXECUTABLE)
34                 GET_FILENAME_COMPONENT(_Y_DIR ${_Y_INPUT} PATH)
35                 ADD_CUSTOM_COMMAND(
36                         OUTPUT  ${_CPP_OUTPUT}
37                         OUTPUT  ${_H_OUTPUT}
38                         DEPENDS ${_Y_INPUT}
39                         COMMAND ${BISON_EXECUTABLE}
40                         ARGS
41                                 -p ${_PREFIX} -o"${_CPP_OUTPUT}"
42                                 --defines="${_H_OUTPUT}" ${_Y_INPUT}
43                         WORKING_DIRECTORY ${_Y_DIR}
44                 )
45                 SET_SOURCE_FILES_PROPERTIES(
46                         ${_CPP_OUTPUT} ${_H_OUTPUT}
47                         GENERATED
48                 )
49         ELSE(BISON_EXECUTABLE)
50                 MESSAGE(SEND_ERROR "Can't find bison program, and it's required")
51         ENDIF(BISON_EXECUTABLE)
52 ENDMACRO(BISON_GENERATOR)