-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (57 loc) · 1.77 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Adapted from https://github.com/TravisWThompson1/Makefile_Example_CUDA_CPP_To_Executable
# Windows-only, using Visual Studio toolchain
## USER SPECIFIC DIRECTORIES ##
# CUDA directory:
CUDA_ROOT_DIR=D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6
## CC COMPILER OPTIONS ##
# CC compiler options:
CC=cl.exe
CC_FLAGS=-g -O0
CC_LIBS=
## NVCC COMPILER OPTIONS ##
# NVCC compiler options:
NVCC=nvcc
NVCC_FLAGS=-dc -G -g -O0
NVCC_LIBS=
# CUDA include directory:
CUDA_INC_DIR=/I"$(CUDA_ROOT_DIR)/include"
# CUDA linking libraries:
CUDA_LINK_LIBS="$(CUDA_ROOT_DIR)/lib/x64/cudart.lib"
## Project file structure ##
# Source file directory:
SRC_DIR = src
# Object file directory:
OBJ_DIR = bin
# Include header file diretory:
INC_DIR = include
## Make variables ##
# Target executable name:
EXE = parallellines
# Object files:
OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.obj,$(wildcard $(SRC_DIR)/*.cpp)) \
$(patsubst $(SRC_DIR)/%.cu,$(OBJ_DIR)/%.obj,$(wildcard $(SRC_DIR)/*.cu))
## Compile ##
# Link c++ and CUDA compiled object files to target executable:
$(EXE) : $(OBJS)
$(NVCC) $(OBJS) $(CUDA_LINK_LIBS) -o $@
# Force recompilation of header files by deleting main's object before make
remake : clean-main $(EXE)
# Compile main.cu file to object files:
$(OBJ_DIR)/%.obj : $(SRC_DIR)/%.cu
$(NVCC) $(NVCC_FLAGS) -c $< -o $@
# Compile C++ source files to object files:
$(OBJ_DIR)/%.obj : $(SRC_DIR)/%.cpp $(INC_DIR)/%.hpp
$(CC) $(CC_FLAGS) -c $< /Fo$@
# Compile CUDA source files to object files:
$(OBJ_DIR)/%.obj : $(SRC_DIR)/%.cu $(INC_DIR)/%.cuh
$(NVCC) $(NVCC_FLAGS) -c $< -o $@
# Clean object from main only
clean-main:
del /q $(OBJ_DIR)\\main.obj
# Clean objects in object directory.
clean:
del /s /q $(OBJ_DIR)
run : $(EXE)
$(EXE)
remake-run : remake
$(EXE)