[CMake] cmake, lex & yacc

Tristan Carel tristan.carel at gmail.com
Mon Jul 30 12:30:58 EDT 2007


On 7/30/07, Timur Ivanov <timur.ivanov at gmail.com> wrote:
> Hello!
>
> Sorry if it was discussed already but I can't find anything really
> useful for me.
>
> In current project I use lex & yacc and Makefile rules looks like:
>
> YACC=bison
> LEX=flex
>
> config_yacc.c: config_yacc.y config.h
>         $(YACC) -d -o config_yacc.c config_yacc.y
>
> config_lex.c: config_lex.l config_yacc.c
>         $(LEX) -oconfig_lex.c config_lex.l
>
> then compile config_yacc.c and config_lex.c
>
> Now I want to port all of that to cmake but can't find how to express
> dependences for yacc and lex sources, that is if .y or .l file changes
> proper .c file will be regenerated by yacc or lex.

You can find 2 modules `FindBison.cmake' and `FindFlex.cmake' on the
CMake bug tracker that have not been integrated yet.

http://www.cmake.org/Bug/bug.php?op=show&bugid=4018&pos=3

These 2 modules provide the necessary to find the tools on the system
(location, version) and very easily create custom targets thanks to
the macros FLEX_TARGET and BISON_TARGET. They support a set of options
to pass additional flags, or to generate a `verbose output file' to
debug conflicts.
Another macro named `ADD_FLEX_BISON_DEPENDENCY' can be used when a
Flex scanner uses tokens defined by Bison where in this case the
scanner depends on the header file generated by Bison.

These modules have been tested on many systems, but by only one developer.

Hope this help.
-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list