Automatic header dependencies with gmake

前端 未结 3 1907
一个人的身影
一个人的身影 2020-12-04 00:53

EDITED

I\'m trying to have source files recompiled without having to specify header files for each CPP in the makefile.

I\'m down to :

3条回答
  •  感情败类
    2020-12-04 01:10

    You don't have dependency file as a prerequisite for compilation rule. Should be something like this:

    #This is the rule for creating the dependency files
    src/%.d: src/%.cpp
        $(CXX) $(CXX_CFLAGS) -MM -MF $(patsubst obj/%.o,obj/%.d,$@) -o $@ $<
    
    obj/%.o: %.cpp %.d
        $(CXX) $(CXXFLAGS) -o $@ -c $<
    
    -include $(SRC:%.cpp=%.d)
    

    The last string adds dependency on headers.

    EDIT

    I see you have

    -include $(DEPS)
    

    but check with $(warning DEPS = $(DEPS)) whether you really include existing files, otherwise make just silently ignore these.

提交回复
热议问题