-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile_test
More file actions
58 lines (46 loc) · 1.97 KB
/
Copy pathMakefile_test
File metadata and controls
58 lines (46 loc) · 1.97 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
46
47
48
49
50
51
52
53
54
55
56
57
58
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile_test :+: :+: :+: #
# +:+ +:+ +:+ #
# By: codespace <codespace@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/06/29 19:09:21 by codespace #+# #+# #
# Updated: 2025/07/22 15:00:00 by you ### ########.fr #
# #
# **************************************************************************** #
# Compilador e flags
CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -std=c++14 -DUNIT_TEST
# Diretórios
SRC_DIR = sources
OBJ_DIR = build_tests/tests
INC_DIRS = includes
INCLUDES = -I$(INC_DIRS)
# Bibliotecas de teste
TEST_FLAGS = -lgtest -lgtest_main -pthread
# Arquivos de teste
TEST_DIR = tests
TEST_SRCS = $(shell find $(TEST_DIR) -name "*.cpp")
# Excluímos o main.cpp do projeto principal
SRCS = $(filter-out $(SRC_DIR)/main.cpp, $(shell find $(SRC_DIR) -name "*.cpp"))
# Nome do executável de testes
TEST_EXEC = $(OBJ_DIR)/test_executable
# Alvo padrão
all: $(TEST_EXEC)
$(TEST_EXEC):
@mkdir -p $(OBJ_DIR)
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(TEST_SRCS) $(SRCS) -o $(TEST_EXEC) $(TEST_FLAGS)
@echo "✅ [Compiled] Test Executable"
run: all
@echo "✅ [Running] Tests"
@./$(TEST_EXEC)
how_build:
@echo make -f Makefile_test # Compila os testes
@echo make -f Makefile_test run # Roda os testes
@echo make -f Makefile_test clean # Limpa os objetos de teste
clean:
@rm -rf $(OBJ_DIR)
@echo "🧹 [Cleaned] Test build"
re: clean all
.PHONY: all run clean re