-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (37 loc) · 1.17 KB
/
Copy pathMakefile
File metadata and controls
46 lines (37 loc) · 1.17 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
PROGRAM_NAME := test
BUILD_PATH := build
BIN_PATH := bin
COMPILER := nvcc
STANDART := --std=c++11
NVCC_FLAGS := --cudart static --relocatable-device-code=false
LIBS := -lcudart -lpthread -lgtest
CUDA_INCLUDES := -I"/usr/local/cuda/include"
WARNINGS_ERRORS := -pedantic -Wall -Wextra -Wno-deprecated -Wno-unused-parameter -Wno-enum-compare -Weffc++
SRC_FILES := $(shell find . -name '*.cpp' | sort -k 1nr | cut -f2-)
OBJS := $(SRC_FILES:%.cpp=$(BUILD_PATH)/%.o)
DEP := $(OBJS:.o=.d)
# Test build for gtests
.PHONY: test
test: dirs $(BIN_PATH)/$(PROGRAM_NAME)
@$(RM) $(PROGRAM_NAME)
@ln -s $(BIN_PATH)/$(PROGRAM_NAME) $(PROGRAM_NAME)
.PHONY: dirs
dirs:
@echo "Creating directories"
@mkdir -p $(dir $(OBJS))
@mkdir -p $(BIN_PATH)
@echo "Directories created"
.PHONY: clean
clean:
@echo "Deleting $(PROGRAM_NAME) symlink"
@$(RM) $(PROGRAM_NAME)
@echo "Deleting directories"
@$(RM) -r build
@$(RM) -r bin
$(BIN_PATH)/$(PROGRAM_NAME): $(OBJS)
@echo "Linking"
$(COMPILER) $(STANDART) $(NVCC_FLAGS) $(LIBS) -link -o $(BIN_PATH)/$(PROGRAM_NAME) $(OBJS)
chmod +x $(BIN_PATH)/$(PROGRAM_NAME)
$(BUILD_PATH)/%.o: %.cpp
@echo "Building"
$(COMPILER) $(STANDART) --compile -o "$@" "$<"