-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (53 loc) · 1.5 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.22)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -g")
set(This MyProgrammingLanguage)
project(${This} C CXX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
enable_testing()
# Find and include Google Test
add_subdirectory(third_party/googletest)
include_directories(src)
set (Headers
src/bytecodeSeq.h
src/common.h
src/constantPoolArray.h
src/virtualMachine.h
src/value.h
src/object.h
src/hashTable.h
src/scanner.h
src/debug.h
src/table.h
src/memory.h
src/compiler.h
)
set (Sources
src/bytecodeSeq.c
src/constantPoolArray.c
src/debug.c
src/memory.c
src/value.c
src/table.c
src/object.c
src/scanner.c
src/compiler.c
src/hashTable.c
src/virtualMachine.c
src/main.c)
add_library(${This} STATIC ${Sources} ${Headers})
add_subdirectory(test)
add_executable(${This}_App src/main.c)
target_link_libraries(${This}_App PRIVATE ${This})
set(VALGRIND_CMD valgrind --leak-check=yes --log-file=valgrind.rpt)
add_custom_target(memLeak
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/valgrind_script.sh $<TARGET_FILE:${This}_App>
COMMAND ${CMAKE_COMMAND} -E echo "Running with valgrind..."
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E echo "valgrind report generated."
DEPENDS ${This}_App # Ensure that the executable is built before running the target
)
# Add custom target for debug
add_custom_target(debug
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${This}_App --config Debug
)