Improve Makefile rules for running moc

The previous rules were conflicting, and the naming of the moc-generated
file to be included in .cpp files was deviating from what's most used in
Qt: the usual way is to
  #include "file.moc"
and not
  #include "file.moc.cpp"

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
This commit is contained in:
Alberto Mardegan 2013-04-01 23:08:13 +03:00
parent b5b14f1d95
commit 40e3671bd2
2 changed files with 11 additions and 6 deletions

View file

@ -306,18 +306,23 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $
@mkdir -p .dep @mkdir -p .dep
@$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $<
# This rule is for running the moc on QObject subclasses defined in the .h
# files.
# To activate this rule, add <file>.moc.o to the OBJS variable.
%.moc.cpp: %.h %.moc.cpp: %.h
@echo ' MOC' $< @echo ' MOC' $<
@$(MOC) $(MOCFLAGS) $< -o $@ @$(MOC) $(MOCFLAGS) $< -o $@
# This rule is for running the moc on QObject subclasses defined in the .cpp files; # This rule is for running the moc on QObject subclasses defined in the .cpp
# remember to #include "<file>.moc.cpp" at the end of the .cpp file, or you'll # files; remember to #include "<file>.moc" at the end of the .cpp file, or
# get linker errors ("undefined vtable for...") # you'll get linker errors ("undefined vtable for...")
%.moc.cpp: %.cpp # To activate this rule, you need another rule on the .o file, like:
# file.o: file.moc
%.moc: %.cpp
@echo ' MOC' $< @echo ' MOC' $<
@$(MOC) -i $(MOCFLAGS) $< -o $@ @$(MOC) -i $(MOCFLAGS) $< -o $@
qt-gui.o: qt-gui.moc.cpp qt-gui.o: qt-gui.moc
%.ui.h: ui/%.ui %.ui.h: ui/%.ui
@echo ' UIC' $< @echo ' UIC' $<

View file

@ -2394,4 +2394,4 @@ gdouble get_screen_dpi(void)
return dpi_h; return dpi_h;
} }
#include "qt-gui.moc.cpp" #include "qt-gui.moc"