generated from SwarnenduRC/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
59 lines (43 loc) · 1.42 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
##Directories
SRC_DIR := src
INC_DIR := include
OBJ_DIR := obj
BIN_DIR := bin
##Compiler flags
CXX := clang++
CXXFLAGS := -std=c++20 -g -Wall -Wextra -Werror -Wno-unused-function -I$(INC_DIR) $(addprefix -I, $(wildcard $(INC_DIR)/*))
##Files
SRCS := $(wildcard *.cpp $(SRC_DIR)/*.cpp)
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
DBG_OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%_d.o, $(SRCS))
##Binaries
TARGET := $(BIN_DIR)/DS-Algos
DBG_TARGET := $(BIN_DIR)/DS-AlgosD
all : debug release
release : $(TARGET)
debug : $(DBG_TARGET)
$(TARGET) : $(OBJS) | $(BIN_DIR)
@echo "Linking release build...."
$(CXX) $(CXXFLAGS) -lgtest -lgmock -lpthread -o $@ $^
@echo "Linking release build completed"
$(DBG_TARGET) : $(DBG_OBJS) | $(BIN_DIR)
@echo "Linking debug build...."
$(CXX) $(CXXFLAGS) -lgtest -lgmock -lpthread -o $@ $^
@echo "Linking debug build completed"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
@echo "Compiling release build...."
$(CXX) $(CXXFLAGS) -c $< -o $@
@echo "Compiling release build completed"
$(OBJ_DIR)/%_d.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
@echo "Compiling debug build...."
$(CXX) $(CXXFLAGS) -c $< -o $@ -DDEBUG
@echo "Compiling debug build completed"
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(BIN_DIR):
mkdir -p $(BIN_DIR)
clean:
@echo "Cleaning solution..."
rm -rf $(OBJ_DIR) $(BIN_DIR) $(TARGET) $(DBG_TARGET)
@echo "Cleaning solution completed"
.PHONY: all release debug clean