Files
geant4/config/moc.gmk
T
2016-06-09 15:58:43 +02:00

63 lines
2.3 KiB
Plaintext

# $Id: moc.gmk,v 1.3 2008/12/03 13:35:36 gcosmo Exp $
# ----------------------------------------------------------------
# Common part of GNUmakefile for libraries. John Allison, 5/7/95.
# ----------------------------------------------------------------
# Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96.
# Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98.
# Introduced Qt moc rule, L.Garnier 16/2/08.
ifndef G4LIBDIR
G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
endif
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
ifneq ($(G4INTY_BUILD_QT),)
moc_inc := $(shell ($(GREP) -l "Q_OBJECT" include/*.hh))
moc_sources := $(patsubst include/%.hh, moc/%_moc.cc, $(moc_inc))
moc_objects := $(patsubst moc/%_moc.cc,$(G4TMPDIR)/%_moc.o,$(moc_sources))
moc_dependencies := $(patsubst moc/%_moc.cc,$(G4TMPDIR)/%_moc.d,$(moc_sources))
endif
###############################################################################
#
# Actual moc files for Qt files
#
# moc sources and headers: used for Qt signal/slot
# - all headers which use signals/slots have the macro "Q_OBJECT" present
# in the class definitions; these all need to be processed by the
# "meta object compiler (moc)" which generates extra source code to
# implement the signal/slots, i.e., if "foo.h" contains the token "Q_OBJECT"
# it will be used by moc to generate the file "foo_moc.cpp" (the _moc. is
# just an arbitrary extension to make it easier to identify sources
# generated by moc).
ifneq ($(G4INTY_BUILD_QT),)
$(G4TMPDIR)/%_moc.d: moc/%_moc.cc
@echo Making dependency for moc file $< ...
@if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR) ;fi
@set -e;\
g++ $(GPPFLAGS) $(CPPFLAGS) -w -xc++ $< |\
sed 's!$*\.o!$(G4TMPDIR)/& $@!' >$@;\
[ -s $@ ] || rm -f $@
moc/%_moc.cc: include/%.hh
@echo Making moc file for $< ...
@if [ ! -d moc ] ; then mkdir -p moc ;fi
@if [ `$(QTMOC) -v 2>&1 | $(GREP) "Qt 3" | wc -l ` -gt 0 ]; then \
$(QTMOC) -o $@ $<;\
else $(QTMOC) $(MOC_MACRO) -o $@ $<; \
fi;
# could be better if we not duplicate this rule from common.gmk...
$(G4TMPDIR)/%_moc.o: moc/%_moc.cc
@echo Compiling $*.cc ...
ifdef CPPVERBOSE
@echo Compiling moc file $*.cc ...
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc
else
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc
endif
endif