Fixed conditional compilation to regard headers using dependency files

This commit is contained in:
Jonathan Moallem 2020-12-03 22:26:25 +11:00
parent 193da09dd6
commit 1bd9c7e4ef

View File

@ -8,6 +8,7 @@ executable := app
target := $(buildDir)/$(executable) target := $(buildDir)/$(executable)
sources := $(call rwildcard,src/,*.cpp) sources := $(call rwildcard,src/,*.cpp)
objects := $(patsubst src/%, $(buildDir)/%, $(patsubst %.cpp, %.o, $(sources))) objects := $(patsubst src/%, $(buildDir)/%, $(patsubst %.cpp, %.o, $(sources)))
depends := $(patsubst %.o, %.d, $(objects))
compileFlags := -std=c++17 -I include compileFlags := -std=c++17 -I include
linkFlags = -L lib/$(platform) -l raylib linkFlags = -L lib/$(platform) -l raylib
@ -20,9 +21,9 @@ ifeq ($(OS), Windows_NT)
libGenDir := src libGenDir := src
THEN := && THEN := &&
PATHSEP := \$(BLANK) PATHSEP := \$(BLANK)
MKDIR := -mkdir MKDIR := -mkdir
RM := -del /q RM := -del /q
COPY = -robocopy "$(call platformpth,$1)" "$(call platformpth,$2)" $3 COPY = -robocopy "$(call platformpth,$1)" "$(call platformpth,$2)" $3
else else
# Check for MacOS/Linux # Check for MacOS/Linux
UNAMEOS := $(shell uname) UNAMEOS := $(shell uname)
@ -78,10 +79,13 @@ lib: submodules
$(target): $(objects) $(target): $(objects)
$(CXX) $(objects) -o $(target) $(linkFlags) $(CXX) $(objects) -o $(target) $(linkFlags)
# Add all rules from dependency files
-include $(depends)
# Compile objects to the build directory # Compile objects to the build directory
$(buildDir)/%.o: src/%.cpp $(buildDir)/%.o: src/%.cpp Makefile
$(MKDIR) $(call platformpth, $(@D)) $(MKDIR) $(call platformpth, $(@D))
$(CXX) -c $(compileFlags) $< -o $@ $(CXX) -MMD -MP -c $(compileFlags) $< -o $@
# Run the executable # Run the executable
execute: execute: