-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (33 loc) · 936 Bytes
/
Makefile
File metadata and controls
45 lines (33 loc) · 936 Bytes
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
# CUDA compiler and standard C++ compiler
NVCC = nvcc
CXX = g++
# CUDA-specific flags for .cu files
CUFLAGS = -std=c++17 -arch=sm_80 -rdc=true -Iinclude -G -g
# Host C++ flags for .cpp files
CXXFLAGS = -std=c++17 -Iinclude
# Directories
SRC_DIR = src
# Source files
CU_SRCS = $(wildcard $(SRC_DIR)/*.cu) main.cu
CPP_SRCS = $(wildcard $(SRC_DIR)/*.cpp)
# Object files
CU_OBJS = $(CU_SRCS:.cu=.cu.o)
CPP_OBJS = $(CPP_SRCS:.cpp=.cpp.o)
OBJS = $(CU_OBJS) $(CPP_OBJS)
# Final executable
TARGET = raytracer
# Default build
all: $(TARGET)
# Linking final executable (with nvcc so device relocatable code is linked properly)
$(TARGET): $(OBJS)
$(NVCC) $(CUFLAGS) -o $@ $^ -lpng
# CUDA compile rule for .cu -> .cu.o
%.cu.o: %.cu
$(NVCC) $(CUFLAGS) -c $< -o $@
# Host compile rule for .cpp -> .cpp.o
%.cpp.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean
clean:
rm -f $(TARGET) *.o $(SRC_DIR)/*.o
.PHONY: all clean