ci: add automatic header file deps to Makefile

This commit is contained in:
dvdrw 2024-11-25 13:52:40 +01:00
parent f5197bfc85
commit cf19cc7183
Signed by: dvdrw
GPG Key ID: 3ED4E5A371C20DD7
2 changed files with 10 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.clangd
*.o
bin/swarm
obj/

View File

@ -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 $@