Qt World Summit: Register Today!

QMAKE_EXTRA_COMPILERS fails when migrating form Qt 4 to Qt 5

  • I am migrating some code from Qt 4 to Qt 5 and all has gone smoothly except for when I use QMAKE_EXTRA_COMPILERS in my .pro file. Compiling with Qt 4 works no problem. But when I compile with Qt 5 then my extra compiler is never called when I call make like it is with Qt 4. I have to call it manually. I have compared the generated Makefiles and they are identical with regards to calling the extra compiler. I'm not sure what is wrong. The code in question is:

    MYFILE_SH_INPUT = myfile.sh
    myfile_sh.input = MYFILE_SH_INPUT
    #myfile.sh creates MyFile.cpp
    myfile_sh.commands += $$PWD/myfile.sh $(OBJECTS_DIR)MyFile.cpp;
    myfile_sh.commands += $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJECTS_DIR)MyFile.o $(OBJECTS_DIR)MyFile.cpp;
    myfile_sh.output = $(OBJECTS_DIR)/MyFile.o
    myfile_sh.dependency_type = TYPE_C
    myfile_sh.depends = FORCE
    QMAKE_EXTRA_COMPILERS += myfile_sh

    I have tried this with Qt 5.5.1 on Xubuntu 16.04 and with Qt 5.6.1 on RHEL 7.3 and it fails with:

     "No rule to make target 'myfile_sh', needed by 'MyApp'. Stop.


  • Found the problem. For some reason in Qt 5 $(OBJECTS_DIR) returns an empty string in the command:

    myfile_sh.output = $(OBJECTS_DIR)/MyFile.o

Log in to reply