FindBISONΒΆ
Find bison
executable and provide a macro to generate custom build rules.
The module defines the following variables:
BISON_EXECUTABLE
path to the
bison
programBISON_VERSION
version of
bison
BISON_FOUND
"True" if the program was found
The minimum required version of bison
can be specified using the
standard CMake syntax, e.g. find_package(BISON 2.1.3)
.
If bison
is found, the module defines the macro:
BISON_TARGET(<Name> <YaccInput> <CodeOutput>
[COMPILE_FLAGS <flags>]
[DEFINES_FILE <file>]
[VERBOSE [<file>]]
[REPORT_FILE <file>]
)
which will create a custom rule to generate a parser. <YaccInput>
is
the path to a yacc file. <CodeOutput>
is the name of the source file
generated by bison. A header file is also be generated, and contains
the token list.
Changed in version 3.14: When CMP0088
is set to NEW
, bison
runs in the
CMAKE_CURRENT_BINARY_DIR
directory.
The options are:
COMPILE_FLAGS <flags>
Specify flags to be added to the
bison
command line.DEFINES_FILE <file>
New in version 3.4.
Specify a non-default header
<file>
to be generated bybison
.VERBOSE [<file>]
Tell
bison
to write a report file of the grammar and parser.Deprecated since version 3.7: If
<file>
is given, it specifies path the report file is copied to.[<file>]
is left for backward compatibility of this module. UseVERBOSE REPORT_FILE <file>
.REPORT_FILE <file>
New in version 3.7.
Specify a non-default report
<file>
, if generated.
The macro defines the following variables:
BISON_<Name>_DEFINED
True
is the macro ran successfullyBISON_<Name>_INPUT
The input source file, an alias for <YaccInput>
BISON_<Name>_OUTPUT_SOURCE
The source file generated by bison
BISON_<Name>_OUTPUT_HEADER
The header file generated by bison
BISON_<Name>_OUTPUTS
All files generated by bison including the source, the header and the report
BISON_<Name>_COMPILE_FLAGS
Options used in the
bison
command line
Example usage:
find_package(BISON)
BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h)
add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})