I have a very simple makefile, that basically does the following:
# Pre-compiled header
CORE_PCH_FILENAME =Core.h
CORE_PCH:
$(CXX) $(CXX_CFLAGS) -x c++-header $(CORE_PCH_FILENAME)
#Objects
obj/%.o: CORE_PCH %.cpp obj/%.d
@mkdir -p obj
$(CXX) $(CXX_CFLAGS) -c $*.cpp -o $@
#Dependencies
obj/%.d: %.cpp
@mkdir -p obj
$(CXX) $(CXX_CFLAGS) -MM -MT obj/$*.o -MF $@ $<
My problem is, the first time I make, the Core.h.gch gets created and the project gets built. That's fine.
But, even if change nothing, running make again will re-create the Core.h.gch and recompile everything.
If I don't have a pre-compiled header, make behaves fine (will not rebuild anything if nothing has changed, and rebuild only what's necessary if modifications were made)
But I'd really like to have that pre-compiled header, is there something I'm not doing right!?
EDIT:
The following was suggested:
# Pre-compiled header
$(CORE_PCH_FILENAME) =Core.h
CORE_PCH: $(CORE_PCH_FILENAME)
$(CXX) $(CXX_CFLAGS) -x c++-header $(CORE_PCH_FILENAME)
But it still gets created every time :(