Based on this link, I created a Autotools-based build system that accepts Qt UI and RSC files without the need to call QMAKE.
I however wish to separate the source, headers and ui-files into folders in the the following fashion:
${srcdir}
├── Makefile.am
├── main.cc
├── include
│ └── mainwidget.h
├── src
│ └── mainwidget.cc
└── ui
└── mainwidget.ui
And have the build directory ordered in the following way
${builddir}
├── include
│ └── ui_mainwidget.h
├── Makefile
├── main.o
├── mainwidget.o
└── moc_mainwidget.o
My Makefile.am currently looks like this:
moc_%.cc: %.h
@MOC@ -o$@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(MOC_CPPFLAGS) $<
ui_%.h: %.ui
@UIC@ -o $@ $<
qrc_%.cc: %.qrc
@RCC@ -o $@ $<
bin_PROGRAMS = qthello
BUILT_SOURCES = ui_mainwidget.h
qthello_CXXFLAGS = -I$(srcdir)/include -I$(builddir)/include
qthello_CPPFLAGS = $(QT_CPPFLAGS)
qthello_LDFLAGS = $(QT_LDFLAGS)
qthello_LDADD = $(QT_LIBS)
qthello_SOURCES = \
moc_mainwidget.cc \
mainwidget.cc \
main.cc
Which works fine if the ui-class files are located in $(srcdir), but simply moving them to the desired directories and changing the expected lines in the Makefile.am does not yeld the desired result. That is, doing these changes does not work:
BUILT_SOURCES = include/ui_mainwidget.h
[ ... ]
qthello_SOURCES = \
src/moc_mainwidget.cc \
src/mainwidget.cc \
main.cc
It occurs to me that some changes have to be made to the build rules to ensure that the include, src, ui -directories exist in $(builddir), and that the correct input files are passed. I am however inexperienced in writing such build rules and google does not seem to have the answer.
Are there any easy portable ways of achieving this?