Sources from subdirectories in Makefile

后端 未结 7 1283
无人共我
无人共我 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 20:08

    This should do it:

    SOURCES = $(wildcard *.cpp) $(wildcard */*.cpp)
    

    If you change you mind and want a recursive solution (i.e. to any depth), it can be done but it involves some of the more powerful Make functions. You know, the ones that allow you to do things you really shouldn't.

    EDIT:
    Jack Kelly points out that $(wildcard **/*.cpp) works to any depth, at least on some platforms, using GNUMake 3.81. (How he figured that out, I have no idea.)

    0 讨论(0)
提交回复
热议问题