[Qt-interest] configure.ac with Qt project

Reece Dunn msclrhd at googlemail.com
Tue Jun 1 19:12:32 CEST 2010


On 1 June 2010 17:40, Frank Lutz <frank422542 at googlemail.com> wrote:
> Hi,
>
> i do try to make my project autotool compatible. But i do not have much
> experience on autotool, so my question. "How i do have to put the
> qt-library check into configure.ac?

configure.ac:
----- 8< -----
PKG_PROG_PKG_CONFIG(0.20)

PKG_CHECK_MODULES(QT, [QtCore >= 4.6, QtGui >= 4.6, QtMultimedia >= 4.6])
AC_SUBST(QT_CFLAGS)
AC_SUBST(QT_LIBS)
----- >8 -----

Replace the list of modules and versions with the ones you require.
You can also split this out into several checks (if, for example, you
don't require one of the Qt components to build).

Then put them in your Makefile.am:
----- 8< -----
AM_CXXFLAGS = ${QT_CFLAGS}
AM_LDFLAGS = ${QT_LIBS}
----- >8 -----

NOTE: For moc compiler support, in Makefile.am I do:
----- 8< -----
bin_PROGRAMS = appname

appname_SOURCES = \
   File.hpp File.cpp \
   OtherFile.hpp OtherFile.cpp \
   main.cpp

nodist_appname_SOURCES = \
   moc_File.cpp \
   moc_OtherFile.cpp

moc_%.cpp: %.hpp
   moc $< -o $@

CLEANFILES = $(nodist_appname_SOURCES)
----- >8 -----

One thing to note is that the above does not always get the build
dependencies correct when doing an incremental build (e.g. if you
change the class layout), so you may experience strange crashes in
this case -- use `make clean && make` to work around this (to fix it
properly, you'll need to maintain header dependencies on the source
files).

If you want TS (translation file) support, you can do:
----- 8< -----
appname.ts: $(appname_SOURCES)
   lupdate-qt4 $(appname_SOURCES) -ts appname.ts
----- >8 -----
so that `make appname.ts` will generate the TS file for you. I haven't
figured out how to properly hook it up, as I have switched to using PO
files.

HTH,
- Reece



More information about the Qt-interest-old mailing list