qmakexxd

qmake: extra compilers (processing steps)?


In my qmake-based project, I want to run 'xxd' on some files before compilation. Following the documentation, the relevant part in my pro file looks as following:

SHADERS = shader/tone.frag \
          shader/trans.frag \
          shader/hue.frag

# xxd
xxd.output = ${QMAKE_FILE_NAME}.xxd
xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
xxd.depends = SHADERS
xxd.input = $$SHADERS
xxd.variable_out = HEADERS

QMAKE_EXTRA_COMPILERS += xxd

Qmake doesn't complain, but it also doesn't run xxd at all. Do I have to create special targets for each file I want to have pre-processed? (The resulting *.xxd files will not be compiled afterwards by me, only included in other cpp files)

Edit: With smokris's help, this is how I fixed the part in my pro file:

# xxd
xxd.output = ${QMAKE_FILE_NAME}.xxd
xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
xxd.depends = $$SHADERS
xxd.input = SHADERS
xxd.variable_out = HEADERS

Solution

  • The .input attribute expects the name of a variable, not a list of files. Try taking away the $$ and just use xxd.input = SHADERS.

    .depends, on the other hand, expects a list of files, so use xxd.depends = $$SHADERS.

    If you set .variable_out to HEADERS, SOURCES, or OBJECTS, the compiler will run. However, if you set .variable_out to another variable name, you must also set .CONFIG = target_predeps in order for the compiler to run.