Hi,
I'm trying to use flex with qmake but I can't get the dependencies right. I want to keep the generated code in separate files. Here's a simple test to illustrate the problem:
main.cpp:
#include "parser.h"
int main(int argc, char ** argv)
{
argv++; argc--;
if(--argc > 0)
parserin = fopen(++argv[0], "r");
else parserin = stdin;
parserlex();
return 0;
}
#include "parser.h"
int main(int argc, char ** argv)
{
argv++; argc--;
if(--argc > 0)
parserin = fopen(++argv[0], "r");
else parserin = stdin;
parserlex();
return 0;
}
To copy to clipboard, switch view to plain text mode
parser.l:
%option noyywrap
%%
%%
%option noyywrap
%%
%%
To copy to clipboard, switch view to plain text mode
And finally the makefile:
TEMPLATE = app
SOURCES += main.cpp
LEXSOURCES += parser.l
QMAKE_LEX = flex
QMAKE_LEXFLAGS = --header-file=parser.h
TARGET = ParserTest
LIBS += -lfl
CONFIG -= qt
TEMPLATE = app
SOURCES += main.cpp
LEXSOURCES += parser.l
QMAKE_LEX = flex
QMAKE_LEXFLAGS = --header-file=parser.h
TARGET = ParserTest
LIBS += -lfl
CONFIG -= qt
To copy to clipboard, switch view to plain text mode
The problem is that qmake tries to compile main.cpp first that depends on the generated parser.h (which doesn't exist). How can I tell qmake about this dependency? I tried defining custom compilers for flex, but the dependency problem is still there.
Bookmarks