March 10, 2009

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

by orzel
Categories: Gentoo, KDE
Tags: ,
Comments: 9 Comments

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 know 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).

    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.CONFIG += no_link
PRE_TARGETDEPS += compiler_updateqm_make_all


  1. Ian Monroe says:

    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. 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. 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 says:

    @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 says:

    @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. @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.., that I already use on some projects.

  7. Ian Monroe says:

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

  8. 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

  9. Mathieu says:

    Thanks a lot for the tip, it saved my day !

Leave a Reply

Your email address will not be published. Required fields are marked *