[Qt-interest] flex/bison on qmake project?

Rui Maciel rui.maciel at gmail.com
Fri Nov 20 10:54:14 CET 2009


Rui Maciel wrote:

> Is it possible to get flex & bison files to work with qmake? I haven't got
> much luck and what I can gather from google is that the only approach is
> to set qmake to deal with flex & bison as custom compilers[1]. Isn't there
> a better way?
> 
> 
> Rui Maciel
> 
> [1]
> [http://www.qtcentre.org/forum/f-qt-programming-2/t-flex-bison-and-qmake-3557.html

It appears there isn't a better way. I've added the following code to a project file and, after a lot of bug 
hunting, I've managed to force qmake to handle flex & bison files. Yet, this is a flimsy hack that just 
barely manages to successfully generate and compile flex&bison source files.

The code, which was added to qmake's project file, is as follows:
<code>
FlexOutput.target = lex.msh_yy.h
FlexOutput.commands = flex --header-file=lex.msh_yy.h msh.l; mv lex.msh_yy.c lex.msh_yy.c++
FlexOutput.depends = msh.l
FlexOutput.output = lex.msh_yy.c++ lex.msh_yy.h

BisonOutput.target = msh.tab.h
BisonOutput.commands = bison -d --debug msh.y
BisonOutput.depends = msh.y
BisonOutput.output = msh.tab.c msh.tab.h

BisonCompile.target = msh.tab.o
BisonCompile.commands = g++ -c msh.tab.c
BisonCompile.depends = msh.tab.c msh.tab.h
BisonCompile.output = msh.tab.o

OBJECTS += msh.tab.o

QMAKE_EXTRA_TARGETS += FlexOutput BisonOutput BisonCompile
</code>


Rui Maciel



More information about the Qt-interest-old mailing list