Qt Extended Home · Build System Home · Reference · User Guide · Internals codeless banner

Generate sources

It is somewhat tricky to get your code to run before the target is built. The easiest way is to create a compiler that outputs to the HEADERS or SOURCES variable.

    # This crap is needed to generate datasets.h
    GENERATOR=make_test_data.pl
    dataset.commands=$$COMMAND_HEADER\
        $$PWD/make_test_data.pl ${QMAKE_FILE_OUT}
    dataset.output=$$OUT_PWD/datasets.h
    dataset.input=GENERATOR
    dataset.variable_out=HEADERS
    dataset.name=Generate ${QMAKE_FILE_OUT}
    QMAKE_EXTRA_COMPILERS+=dataset

You need to #include the generated file in some other file to force this to run first.

See also Advanced Tasks.


Copyright © 2009 Nokia
Qt Extended - Build System Documentation