Reputation: 29
My project organization is as follows:
In my makefile, to grab all *.h from the subdirectories I currently use:
#includes (.h / .hpp)
INC_DIRS := \
$(wildcard include/*/)
INCLUDE = $(foreach d, $(INC_DIRS), -I$d)
This does work, and I am able to compile fine. However I was wondering if there was a simpler way to include all subdirectories in a single include statement.
The current method I am using does a '-Iinclude/subdirectory' for each subdirectory and it looks really messy and confusing in the terminal.
Upvotes: 1
Views: 803
Reputation: 385098
Given your include path approach, this is a good way to specify it in your makefile.
However, it would be better to not require all these subdirectories to be in the path, and instead use relative paths inside your code.
#include "somedir/thing.h"
#include "somedir2/otherthing.h"
and so forth.
This will also then be much easier to port to other build systems if needed.
Upvotes: 2