QMAKE_EXTRA_COMPILERS - problems with dependencies between header files

I am creating a Qt project using flex and bison. There is a relationship between the header file _CMPL_Parser.hh(generated by the bison) and the header file compile.hh( #include _CMPL_Parser.hh).

I use QMAKE_EXTRA_COMPILERSto include flex and bison in my project (see part of my project file below). Unfortunately, it _CMPL_Parser.hhis created after the compiler needs this file to include it in compiler.hh -> compiler.cc.

...

FLEX_SOURCES = src/cmpl/CMPL_Scanner.l
BISON_SOURCES = src/cmpl/CMPL_Parser.yy

flex.commands=flex -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
flex.output= $$OUT_PWD/_CMPL_Scanner.cc
flex.input=FLEX_SOURCES
flex.variable_out=SOURCES
flex.name=flex ${QMAKE_FILE_IN}
QMAKE_EXTRA_COMPILERS+=flex

bisonsource.commands=bison -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
bisonsource.output= $$OUT_PWD/_CMPL_Parser.cc
bisonsource.input=BISON_SOURCES
bisonsource.variable_out=SOURCES
bisonsource.name=bisonsource ${QMAKE_FILE_IN}
QMAKE_EXTRA_COMPILERS+=bisonsource

bisonheader.commands=@true
bisonheader.output= $$OUT_PWD/_CMPL_Parser.hh
bisonheader.input=BISON_SOURCES
bisonheader.variable_out=HEADERS
bisonheader.name=bisonheader ${QMAKE_FILE_IN}
#bisonheader.depends= bin/_CMPL_Parser.cc
QMAKE_EXTRA_COMPILERS+=bisonheader

...

HEADERS += src/cmpl/Compiler.hh \
           src/cmpl/FileIO.hh \
     ...

SOURCES += src/cmpl/Compiler.cc \
           src/cmpl/FileIO.cc \
       ...

I also tried to define the following dependencies in the project file. But this also failed.

chh.input = src/cmpl/Compiler.hh
chh.depends = $$OUT_PWD/_CMPL_Parser.hh
chh.name = chh
chh.dependency_type = TYPE_C
chh.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += chh

How can I express what _CMPL_Parser.hhneeds to be created before it is used by other files?

Thank.

+3
1
  • QMake lex/yacc, flex , . flex, :

    CONFIG += lex
    LEXSOURCES += src/cmpl/CMPL_Scanner.l
    
  • QMake . , , yacc bison , :

    QMAKE_YACC=bison
    # maybe adjust some other QMAKE_YACC* variables
    CONFIG += yacc    
    YACCSOURCES += src/cmpl/CMPL_Parser.yy
    
  • , , (, qmake), :

    lex.CONFIG += target_predeps
    yacc_impl.CONFIG += target_predeps
    yacc_decl.CONFIG += target_predeps
    

    QMAKE_EXTRA_COMPILERS () , , .

+2

Source: https://habr.com/ru/post/1781466/


All Articles