Adding a custom build target to QtCreator



  • I'm using QtCreator 3.2.1, based on Qt 5.3.2, running on a Rpi3.
    I'm trying to add a custom build target to create a .c & .h file that will be compiled in and linked to my application.
    Qmake Advanced Usage gives instructions on how to add a custom target and I've followed them:

    makeObjDict.target   = ObjDict.c
    makeObjDict.commands = python ~/CanFestival/canfestival-3-asc/objdictgen/objdictgen.py ObjDict.od ObjDict.c
    makeObjDict.depends  = ObjDict.od
    
    QMAKE_EXTRA_TARGETS += makeObjDict
    PRE_TARGETDEPS      += makeObjDict
    

    But all I get is an error:
    No rule to make target 'makeObjDict'

    Does anyone have an idea what I'm doing wrong?



  • @GregWilsonLindberg, I've figured out how to get it to work, I had to add some clarification to the paths and the PRE_TARGETDEPS was wrong:

    makeObjDict.target   = ObjDict.c
    makeObjDict.commands = python ~/CanFestival/canfestival-3-asc/objdictgen/objdictgen.py $$PWD/ObjDict.od $$PWD/ObjDict.c
    makeObjDict.depends  = $$PWD/ObjDict.od
    
    QMAKE_EXTRA_TARGETS += makeObjDict
    PRE_TARGETDEPS      += ObjDict.c
    

    I guess that I was mis-understanding the line in the instructions about including the target in PRE_TARGETDEPS, it's the actual target file, in my case 'ObjDict.c', not the build target instructions 'makeObjDict'.
    The added '$$PWD/' are needed because the new target instructions don't run in the source directory, so a full path is necessary.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.