[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Portable moc/uic support - works for me

From: Pavel Roskin
Subject: Portable moc/uic support - works for me
Date: Fri, 03 Feb 2006 00:22:46 -0500


I see many people here ask how to integrate Qt designer support, but
nobody reported success.  I could do it for a project called qgit (Qt
frontend to git, the version control system used by the Linux kernel).

I was able to test the project on FreeBSD with the native BSD make, and
there were no errors concerning the makefiles.

Here's the src/ from qgit with the actual sources replaced
with short placeholders and without irrelevant extra targets:

bin_PROGRAMS = foo
FORMS = quux.ui

MOC_CC = $( $(
UIC_CC = $(


nodist_foo_SOURCES = $(MOC_CC) $(UIC_CC)

        $(QT_UIC) -o $@ $<
        $(QT_MOC) -o $@ $<
        $(QT_UIC) -o $@ -impl $< $(srcdir)/$(<:.h=.ui)

SUFFIXES = .h .ui

As you can see, I'm using double extensions so that syntax rules can be
used both for generating and for compiling generated sources.  It's
probably not necessary to use *.cpp for real sources and *.cc for
generated ones, but it's convenient to distinguish them.

While I want to share my positive experience, I'd like to hear from the
Automake gurus if I'm doing something potentially problematic, in

- How portable are double extensions? (I'm more concerned about UNIX
make issues than about MS DOS)

- How portable is $(<:.h=.ui) in the suffix rules?

- How safe are substitution references like $(FORMS:.ui=.h) in Automake
variables?  Does Automake calculate them (I guess it does, but keeps the
original line in

I actually tried another approach without double extensions.  Real
sources end with .cpp, sources generated by uic end with .cc and sources
generated by moc end with .cxx (I chose standard extensions so that I
won't need to force-feed them to the compiler as C++ sources).  *.cc is
compiled to libuic.a with a dummy per-target flag.  *.cxx is compiled to
libmoc.a with another dummy per-target flag.  They are linked with the
objects made from the real sources.  It worked too, but Makefile was
very large because it had rules for every file.

Pavel Roskin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]