QMAKE_EXTRA_COMPILERS dependency issue

All

I have a Qt project containing a .ts-file and a .qrc file containing a link to a generated .qm file . We do not store .qm files in our version control system. The problem here is that when I check the source code and run "make" I get the error

RCC: Error in 'CoreGeneral.qrc': Cannot find file 'core.general_en.qm'

      

I created the updateqm.pri files to get the .qm files generated before the build, this file I include in my .pro files

!contains(QMAKE_EXTRA_COMPILERS, updateqm) {
    updateqm.input         = TRANSLATIONS
    updateqm.output        = ${QMAKE_FILE_BASE}.qm
    updateqm.commands      = $$[QT_INSTALL_BINS]/lrelease -idbased ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_BASE}.qm
    updateqm.CONFIG       += no_link target_predeps
    QMAKE_EXTRA_COMPILERS += updateqm
    PRE_TARGETDEPS        += compiler_updateqm_make_all }

      

But then again, I am getting this error even though the .qm files end up being generated. The compilation result looks like this:

 C:\Qt\Qt5.2.1\5.2.1\msvc2012\bin\lrelease -idbased core.general_en.ts -qm core.general_en.qm
    C:\Qt\Qt5.2.1\5.2.1\msvc2012\bin\uic.exe PSGHTMLDisplay.ui -o GeneratedFiles\ui_PSGHTMLDisplay.h
    C:\Qt\Qt5.2.1\5.2.1\msvc2012\bin\rcc.exe -name CoreGeneral CoreGeneral.qrc -o GeneratedFiles\qrc_CoreGeneral.cpp
RCC: Error in 'CoreGeneral.qrc': Cannot find file 'core.general_en.qm'

Updating 'core.general_en.qm'...
    Generated 108 translation(s) (0 finished and 108 unfinished)

      

So, to me it looks like RCC starts processing the .qrc file before lrelease has finished generating .qm files.

Is there any approach to avoid this problem?

PS I tried to use QMAKE_EXTRA_TARGETS to create a pre-build event that will generate .qm files before any other target starts, but that didn't work for me. I used the approach described here to enter link description here

In short, the approach for creating a pre-build event is as follows

    #  -
!exists($$OUT_PWD/.beforebuild) {
  system(@echo aaa > $$system_path($${OUT_PWD}/.beforebuild))
}

QMAKE_EXTRA_TARGETS += before_build makefilehook

makefilehook.target = $(MAKEFILE)
makefilehook.depends = .beforebuild

POST_TARGETDEPS += .beforebuild

before_build.target = .beforebuild
before_build.depends = FORCE
before_build.commands = @echo our command

      

+3


source to share





All Articles