ci: add automatic header file deps to Makefile
This commit is contained in:
parent
f5197bfc85
commit
cf19cc7183
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.clangd
|
||||
*.o
|
||||
bin/swarm
|
||||
obj/
|
||||
|
15
Makefile
15
Makefile
@ -6,19 +6,16 @@ OBJ_DIR = ./obj
|
||||
|
||||
HEADERS = $(wildcard $(INC_DIR)/*.hpp)
|
||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
DEP_FILES = $(OBJ_FILES:.o=.d)
|
||||
OBJ_FILES = $(addprefix $(OBJ_DIR)/,$(notdir $(SRC_FILES:.cpp=.o)))
|
||||
|
||||
CXXFLAGS += -Wall -std=c++20 -O2
|
||||
CXXFLAGS += -Wall -std=c++20 -O2 -I $(INC_DIR)
|
||||
|
||||
all: bin/swarm
|
||||
|
||||
$(OBJ_DIR)/%.o: src/%.cpp
|
||||
$(CXX) -I $(INC_DIR) $(CXXFLAGS) -c -o $@ $^
|
||||
|
||||
bin/swarm: $(OBJ_FILES)
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
@mkdir -p bin
|
||||
$(CXX) -I $(INC_DIR) $(CXXFLAGS) -o $@ $^
|
||||
$(CXX) $(CXXFLAGS) -o $@ $^
|
||||
|
||||
.PHONY: debug
|
||||
debug: CXXFLAGS += -O0 -g
|
||||
@ -28,3 +25,9 @@ debug: clean bin/swarm
|
||||
clean:
|
||||
$(RM) obj/*.o
|
||||
$(RM) bin/swarm
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
$(OBJ_DIR)/%.o : src/%.cpp
|
||||
mkdir -p $(@D)
|
||||
$(CXX) $(CXXFLAGS) -MMD -c $< -o $@
|
||||
|
Loading…
Reference in New Issue
Block a user