Keeping the autotools guys happy with qmake

I’m still figuring out how to do the same thing with cmake, but various bloggers and comments appear to be promising that it’ll be even more easy.

But this is a message for probably all Nokia teams who are making Qt-based libraries:

First open your src/ file and add this stuff:

CONFIG += create_pc create_prl
INSTALLS += target headers

Now open your debian/$package-dev.install file and add this line:


You’ll be doing all the autotools people a tremendous favor.

Next, open the README file and document that you need to use qmake-qt4 on Debian or make either qmake-qt3 or qmake-qt4 work flawlessly with your build environment. Perhaps also mention how to set the install prefix, how to make qmake find and install .pc files in another location, stuff like that. I find that this is lacking for almost every Qt-based library.

You’ll be doing everybody who wants to use your software a tremendous favor.

10 thoughts on “Keeping the autotools guys happy with qmake”

  1. Don’t worry, it isn’t more “messy” with CMake, you just need to write 2 lines of code, one to generate (“configure”) the .pc file, and one to make the install rule. Here goes:

    configure_file( eigen2.pc)
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen2.pc
    DESTINATION lib/pkgconfig

    Another advantage is that you don’t have to do anything elsewhere, like in a Debian package ;)

    I seriously with that nobody uses qmake for something else than building Qt itself, because CMake is a much, much better build system in general!

  2. Ah yes and the contents of is just:

    Name: Eigen2
    Description: A C++ template library for linear algebra: vectors, matrices, and related algorithms


  3. (Sorry for spamming your blog with 4 comments in a row)

    Don’t know why I read “messy”, i guess that I have a bad karma with qmake.

    Anyway, you wrote “easy” not “messy” — yes I hope that my CMake example confirms it :)

  4. And while we are at it, Gtk/glib libraries lack proper CMake support.

    So to all folks who make autotools based libraries: Remember to create a proper .cmake file that can be installed along with the headers.

    As you said:
    You’ll be doing everybody who wants to use your software a tremendous favor.

  5. @huas: can you give an example how that would work? And given that cmake and qmake have support for pkgconfig build-in, ain’t it more easy for the qt apps that want to use a library that already ships with a .pc file to use this? I don’t really see the point in redundancy here.

  6. @huas:
    Nah, doesn’t work like that. It’s not the job of library developers to install a FindFoo.cmake along with their Foo library, because then we’d hint exactly the same problem as with pkgconfig, namely that for that to work cross-platform, one would need all devs on all platforms to agree on standard locations where to put these .cmake files, that’s not realistic.

    So yes, if one were to do that, better just use pkgconfig. But instead, if you want to please CMake-using developers, what you can do is to write a FindFoo.cmake module and put it at some easy-to-find location in your source directory, or on the website of your project. If Google can easily find it, that’s all we need. Otherwise, it’s no biggie, because anyone can write such a .cmake file, that’s the big difference from pkgconfig where nothing can be done without the dev’s support.

  7. huas, If cmake has proper non-awkward pkg-config support (I’m trying it now, and so far it remains to been seen), then surely it’s enough to just use that pkg-config support. I see no need for a special script just for cmake. autotools don’t require any autotools-specific support from libraries – they just use pkg-config, which is not at all autotools-specific.

    More source code would just mean more errors. pkg-config fies are not code so therefore I prefer them.

  8. but has create_pc been added only recently in Qt?
    With Qt 4.5 I added

    CONFIG += create_pc
    pkgconfig.files = myownpc.pc
    pkgconfig.path = /lib/pkgconfig
    INSTALLS += pkgconfig

    but nothing happens… should myownpc.pc be already present?

    thanks in advance

  9. Update: this seems to be the most simple way:

    CONFIG += create_pc create_prl
    INSTALLS += target headers

Comments are closed.