-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 1.85 KB
/
Copy pathMakefile
File metadata and controls
77 lines (60 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Compiler and flags
CXX := g++
# Base flags
PROJ_FLAGS := -std=c++17 -Iinclude -Isrc
# Flags for the application (uses PCH)
PCH_SRC := src/pch.h
PCH_OUT := src/pch.h.gch
CXXFLAGS_APP := $(PROJ_FLAGS) -include src/pch.h -g
# Flags for libraries (no PCH)
CXXFLAGS_LIBS := $(PROJ_FLAGS) -g
LDFLAGS := -Llib -lglfw3dll
# Executable name
TARGET := voidprotocol.exe
# Source files
SRC_APP := $(shell find src -type f -name "*.cpp")
SRC_LIBS := src/glad.c \
include/ufbx/ufbx.c \
include/imgui/imgui.cpp \
include/imgui/imgui_draw.cpp \
include/imgui/imgui_tables.cpp \
include/imgui/imgui_widgets.cpp \
include/imgui/imgui_impl_glfw.cpp \
include/imgui/imgui_impl_opengl3.cpp \
# Object files
OBJ_APP := $(SRC_APP:.cpp=.o)
OBJ_LIBS := $(SRC_LIBS:.cpp=.o)
OBJ_LIBS := $(OBJ_LIBS:.c=.o)
OBJ := $(OBJ_APP) $(OBJ_LIBS)
# Default rule
# Default rule
all: compile_core
@echo "Running $(TARGET)..."
@./$(TARGET)
compile_core: $(PCH_OUT) $(TARGET)
# Compile PCH
# We map the PCH output to the header compilation
$(PCH_OUT): $(PCH_SRC)
$(CXX) $(PROJ_FLAGS) -x c++-header -c $< -o $@
# Link the final executable
$(TARGET): $(OBJ)
$(CXX) $(OBJ) $(LDFLAGS) -o $@
# Compile App C++ source files (Depends on PCH)
# Note: This pattern match must be specific enough or we need to filter
$(OBJ_APP): %.o: %.cpp $(PCH_OUT)
$(CXX) $(CXXFLAGS_APP) -c $< -o $@
# Compile Library C++ source files (No PCH)
# We need to manually match these or filter them out of the generic rule.
# Since SRC_LIBS are in include/, and SRC_APP in src/, we can use path patterns.
include/%.o: include/%.cpp
$(CXX) $(CXXFLAGS_LIBS) -c $< -o $@
# Compile Library C source files
%.o: %.c
$(CXX) $(CXXFLAGS_LIBS) -c $< -o $@
# Clean build artifacts
clean:
rm -f $(OBJ_APP) $(TARGET)
clean-all:
rm -f $(OBJ) $(TARGET) $(PCH_OUT)
# Phony targets
.PHONY: all clean clean-allL