Sources from subdirectories in Makefile

后端 未结 7 1318
无人共我
无人共我 2020-11-29 19:06

I have a C++ library built using a Makefile. Until recently, all the sources were in a single directory, and the Makefile did something like this

SOURCES = $(w

7条回答
  •  迷失自我
    2020-11-29 19:49

    If you don't want to use recursive makefiles, this might give you some ideas:

    subdirs := $(wildcard */)
    sources := $(wildcard $(addsuffix *.cpp,$(subdirs)))
    objects := $(patsubst %.cpp,%.o,$(sources))
    
    $(objects) : %.o : %.cpp
    

提交回复
热议问题