-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (44 loc) · 1.45 KB
/
Makefile
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
# Compiler and flags
CXX := g++
CXXFLAGS := -std=c++26 -g -Wno-pointer-arith
#CXXFLAGS := -std=c++20 -O2 -flto
LDFLAGS := -lglfw3 -lvulkan -ldl -lyaml-cpp
SHADER_COMPILER := glslc
# Directories
SRC_DIR := src/cpp
BUILD_DIR := build
SHADER_DIR := src/shaders
SUBDIR_SHADER_FILES := $(shell find $(SHADER_DIR) -mindepth 2 -name "*.comp")
SHADER_BUILD_DIR := build/shaders
# Source files
SRC_FILES := $(shell find $(SRC_DIR) -name "*.cpp")
OBJ_FILES := $(SRC_FILES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
# Precompiled header
PCH_HEADER := $(SRC_DIR)/pch.hpp
PCH_NAME := precompiled.hpp
PCH_FILE := $(BUILD_DIR)/$(PCH_NAME).gch
# Shader files
COMPUTE_SHADERS := $(wildcard $(SHADER_DIR)/*.comp)
COMPILED_COMPUTE_SHADERS := $(COMPUTE_SHADERS:$(SHADER_DIR)/%.comp=$(SHADER_BUILD_DIR)/%.comp.spv)
# Executable
TARGET := VulkanTest
# Rules
all: $(TARGET) run
compile: $(TARGET)
$(TARGET): $(OBJ_FILES) $(COMPILED_COMPUTE_SHADERS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_FILES) $(LDFLAGS)
# Compile the precompiled header (pch.h)
$(PCH_FILE): $(PCH_HEADER)
@mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.hpp $(PCH_FILE)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -I$(BUILD_DIR) -include $(PCH_NAME) -c $< -o $@
$(SHADER_BUILD_DIR)/%.comp.spv: $(SHADER_DIR)/%.comp $(SUBDIR_SHADER_FILES)
@mkdir -p $(SHADER_BUILD_DIR)
$(SHADER_COMPILER) $< -o $@
run:
./$(TARGET)
clean:
rm -rf $(BUILD_DIR) $(SHADER_BUILD_DIR) $(TARGET)
.PHONY: all clean