qmakercmidlparallel-builds

QMake / jom force extra MIDL compiler to run before RC


I'm converting an old OCX project to QMake (as it's getting the "new" standard in my company). In my Button.pro file, I add the MIDL compiler by the means of

idl_c.output = $${DESTDIR}/${QMAKE_FILE_BASE}.tlb
idl_c.input = IDL
idl_c.commands = $${QMAKE_IDL} ${QMAKE_FILE_IN} $${IDLFLAGS} \
                 /tlb ${QMAKE_FILE_OUT}
idl_c.variable_out = GENERATED_FILES
idl_c.CONFIG += target_predeps
idl_c.name = MIDL

QMAKE_EXTRA_COMPILERS += idl_c

IDL += $$PWD/Button.odl

The .pro file also mentions that I have a RC file

RC_FILE += $$PWD/Button.rc

This RC file contains a TYPELIB for this tlb file, meaning that it has to be available before rc.exe runs

1 TYPELIB "Button.tlb"

I then generate a makefile through QMake and build my project using nmake. Everything runs fine: the console shows no error and the output OCX is generated (and works). I can clearly see that MIDL is executed first, the RC, then the rest. If I try to build using jom, the order is not satisfied anymore. jom seems to try to execute MIDL and RC in parallel: Button.tlb is then not yet existing at the time RC.exe needs it and the build fails.

Is there a way to force jom to wait for midl to be done before starting rc?

I'm using QT 5.3.1 under MSVC2013.


Solution

  • QMake is nothing more than a makefile generator. And your issue is due to make (or jom) parallel job execution. To fix this you only have to induce a single dependency (w/o any recipe) in a Makefile between res/obj and tlb files. This could be done with:

    dep_restlb.target = $(RES_FILE)
    dep_restlb.depends = $${DESTDIR}/Button.tlb # QMAKE_FILE_BASE is not available here
    QMAKE_EXTRA_TARGETS += dep_restlb