On terça-feira, 31 de maio de 2016 15:29:45 BRT Thiago Macieira wrote:
> The following extra rules solve the problem, at the expense of causing Qt
> Creator to complain that the header you had opened changed every time you
> build:
[cut]
> Proof:
> $ gmake
> moc --combine=%.h=.moc/moc_%.cpp 1.h 2.h
> $ touch indirect2.h
> $ gmake
> moc --combine=%.h=.moc/moc_%.cpp 2.h
> $ touch indirect1-1.h
> $ gmake
> moc --combine=%.h=.moc/moc_%.cpp 1.h
Ok, updated Makefile by using a shadow set of zero-sized files just to
accummulate the timestamp.
I've used some extra GNU make goodies here to make my life easier:
===
$(HEADERS:%=.timestamp-%): .timestamp-%: %
@touch -r $< $@
.timestamp-1.h: .timestamp-indirect1.h
.timestamp-2.h: .timestamp-indirect2.h
.timestamp-indirect1.h: .timestamp-indirect1-1.h
===
But qmake could easily just write everything expanded ($< is the first
prerequisite).
However, this *does* require make to do at least one pattern substitution and
I have no clue how to tell nmake to do it:
.moc-run: .timestamp-1.h .timestamp-2.h
moc --combine=%.h=$(MOC_DIR)moc_%.cpp ${?:.timestamp-%=%}
Also note that this will fail for headers outside the current dir. Resolving
that is an exercise left to the reader.
Once someone resolves those two problems, I can change moc --combine to accept
a pattern like the example above and generate multiple files.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
MOC_DIR = .moc/
HEADERS = \
1.h \
2.h \
indirect1.h \
indirect2.h \
indirect1-1.h
mocables: \
$(MOC_DIR)moc_1.cpp \
$(MOC_DIR)moc_2.cpp
$(HEADERS:%=.timestamp-%): .timestamp-%: %
@touch -r $< $@
.timestamp-1.h: .timestamp-indirect1.h
.timestamp-2.h: .timestamp-indirect2.h
.timestamp-indirect1.h: .timestamp-indirect1-1.h
$(MOC_DIR):
mkdir -p $(MOC_DIR)
$(MOC_DIR)moc_1.cpp: .timestamp-1.h .moc-run
$(MOC_DIR)moc_2.cpp: .timestamp-2.h .moc-run
.moc-run: .timestamp-1.h .timestamp-2.h | $(MOC_DIR)
@echo moc --combine=%.h=$(MOC_DIR)moc_%.cpp ${?:.timestamp-%=%}
@touch $@ ${?:timestamp-%.h=$(MOC_DIR)moc_%.cpp}
clean:
-rm -f $(MOC_DIR)moc_1.cpp $(MOC_DIR)moc_2.cpp .moc-run
-rm -f $(HEADERS:%=.timestamp-%)
create:
touch 1.h 2.h indirect1.h indirect2.h indirect1-1.h
.PHONY: clean mocables create
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development