Main Contents

Fixing qmake missing rule for *.ts -> *.qm

March 10, 2009

We are used to polished and great tools from the trolls, but qmake has always been the big exception to this: ugly documentation, lot of undocumented tricks, and missing features.

For me the biggest one was that it would not automatically create the rule to transform *.ts to *.qm in the generated Makefile. I have been trying for very long to fix this problem. This is especially a shame because this is Qt’s very own translation stuff, and qmake should really knows about it.

Today, thanks to ‘luks’ on #qt, I know have the solution, and I think it’s really worth a blog entry, for my own record, and to help all those having the same problem. : put this in a file updateqm.pri and include it from your *pro(s).

isEmpty(QMAKE_LRELEASE) {
    win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
    else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
updateqm.input = TRANSLATIONS
updateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.CONFIG += no_link
QMAKE_EXTRA_COMPILERS += updateqm
PRE_TARGETDEPS += compiler_updateqm_make_all

Filed under: Gentoo, KDE |

8 Comments

  1. Ian Monroe March 10, 2009 @ 10:55 pm

    Yea I tried to use qmake for my last project but as soon as it get a bit complicated (needed to generated some source) I just switched to cmake.

    Why even use qmake? Though I suppose a bigger question is why the Trolls even develop qmake.

  2. Thomas Capricelli March 10, 2009 @ 11:48 pm

    Well, despite those flaws, qmake is still very useful to quickly setup a project running on Windows/Mac/Linux, with moc handling and such…

  3. Elvis Stansvik March 10, 2009 @ 11:55 pm

    Yea, qmake IMHO is fine for when you just start out with a project, or for toss-away stuff. And if the project grows, just change to something more comprehensive like CMake.

  4. Richard Moore March 11, 2009 @ 12:50 am

    @Thomas yeah, i like qmake for simple examples etc. but lets face it - it’s a poor tool. As soon as you have non-trivial external dependencies or non-trivial build requirements it has problems, for anything complex you need to use a different tool. Even a relatively simple application like qt creator shows the rough edges on qmake, hence helio porting it to cmake.

  5. Ian Monroe March 11, 2009 @ 2:37 am

    @Thomas cmake can also be used quite easily for something quick. Don’t you even have to list all the .h files for qmake? cmake might even be easier due to automoc.

  6. Thomas Capricelli March 11, 2009 @ 3:32 am

    @ian: I use cmake often enough, and I do not find it easy. The language is hackish. Of course, it’s better than auto* (everybody agrees on that i think, no flamewar intended). But I’d rather use something like.. http://code.google.com/p/waf/, that I already use on some projects.

  7. Ian Monroe March 11, 2009 @ 5:06 am

    @Thomas for simple projects cmake is very easy. I’m comparing againist qmake, not againist The Ideal Build System.

  8. Benjamin Meyer March 24, 2009 @ 6:45 am

    To make it so it doesn’t build the binary every single time you run make you want to do the following:

    updateqm.input = TRANSLATIONS
    updateqm.output = .qm/locale/${QMAKE_FILE_BASE}.qm
    updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm .qm/locale/${QMAKE_FILE_BASE}.qm
    updateqm.CONFIG += no_link target_predeps
    QMAKE_EXTRA_COMPILERS += updateqm

Leave a comment

CAPTCHA image