[Development] Announcing moc_combine

Thiago Macieira thiago.macieira at intel.com
Tue May 31 20:54:02 CEST 2016


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: text/x-makefile
Size: 815 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160531/3ff141ba/attachment.bin>


More information about the Development mailing list