-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (37 loc) · 1.12 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
# Compiler and flags
CXX = g++
CXXFLAGS = -std=c++20 -Iinclude -I/usr/local/include
LDFLAGS = -L/usr/local/lib -lgtest -lgtest_main -pthread
# CXXFLAGS = -std=c++20 -Iinclude -I/usr/local/include
# LDFLAGS = -L/usr/local/lib -lgtest -lgtest_main -pthread
# CXXFLAGS += -fsanitize=address -g
# LDFLAGS += -fsanitize=address
# Output binary for main program
TARGET = main
# Source files for the main program
SRCS = easy_df_adam.cpp
# Object files (generated from source files)
OBJS = $(SRCS:.cpp=.o)
# Build the main target
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)
# Test files
TESTS = $(wildcard tests/test*.cpp)
TEST_TARGET = test_output
# Compile and run tests with Google Test
test_only: $(TEST_TARGET)
./$(TEST_TARGET) #--gtest_fail_fast
$(TEST_TARGET): $(TESTS)
$(CXX) $(CXXFLAGS) -o $(TEST_TARGET) $(TESTS) $(LDFLAGS)
# Compile each .cpp file into a .o file
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Run the main program
run: $(TARGET)
./$(TARGET)
# Clean up build artifacts
clean:
rm -f $(OBJS) $(TARGET) $(TEST_TARGET)
test: clean test_only
pytest: clean test_only
.PHONY: clean run test