I'm trying to moc all header files with Q_OBJECT macro using make. Here is what I have right now.
HEADERS = *.h
MOCS := $(shell grep -l Q_OBJECT $(HEADERS))
MOC_SOURCES := $(MOCS:%.h=moc_%.cpp)
$(MOC_SOURCES) : moc_%.cpp: %.h
@echo "Building Moc: $@ from $<"
/opt/Qt5.1.1/5.1.1/gcc/bin/moc $< -o $@
But I have a problem in this solution. Only first file is moc'ing.
Thanks.
If the first rule in the makefile has several targets, only the first target in the rule becomes the default goal, not the whole list.
Therefore, I believe you need to define an "all" target above dependent on the $(MOC_SOURCES).