This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
80 lines (63 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
project(CS323-project1 LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
include_directories(src)
include(CTest)
set(CMAKE_CXX_STANDARD 17)
set($ENV{CTEST_OUTPUT_ON_FAILURE} TRUE)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
find_package(FLEX REQUIRED)
SET(FlexOutput ${CMAKE_SOURCE_DIR}/src/lexer.cpp)
IF(FLEX_FOUND)
ADD_CUSTOM_TARGET(lexer
BYPRODUCTS ${FlexOutput}
COMMAND ${FLEX_EXECUTABLE}
--outfile=${FlexOutput}
${CMAKE_SOURCE_DIR}/src/lexer.l
COMMENT "Building lexer.cpp"
)
ENDIF()
find_package(BISON REQUIRED)
SET(BisonOutput ${CMAKE_SOURCE_DIR}/src/parser.cpp)
IF(BISON_FOUND)
ADD_CUSTOM_TARGET(parser
BYPRODUCTS ${BisonOutput} ${CMAKE_SOURCE_DIR}/src/parser.h ${CMAKE_SOURCE_DIR}/src/parser.output
COMMAND ${BISON_EXECUTABLE}
-t -v
--defines=${CMAKE_SOURCE_DIR}/src/parser.h
--output=${BisonOutput}
${CMAKE_SOURCE_DIR}/src/parser.y
COMMENT "Building parser.cpp"
)
ENDIF()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(main
src/parserMain.cpp
src/SyntaxTreeNode.cpp
${BisonOutput}
src/SymbolTable.cpp
src/SemanticAnalyzer.cpp
src/IntermediateCode.cpp
src/IntermediateCodeTranlator.cpp
src/ir_optimizer.cpp
)
add_dependencies(main lexer parser)
target_link_libraries(main
PUBLIC fl)
add_executable(test_syntaxTree
test_executable/test_syntaxTree.cpp
src/SyntaxTreeNode.cpp
src/SymbolTable.cpp)
target_include_directories(test_syntaxTree
PUBLIC src)
add_test(test_tree test_syntaxTree)
add_executable(test_symbolTable
test_executable/test_symbolTable.cpp
src/SymbolTable.cpp)
target_include_directories(test_syntaxTree
PUBLIC src)
add_test(test_symbol test_symbolTable)
add_executable(testInitList src/testInitializeList.cpp)
add_executable(project4_cmake project4/main.c project4/mips32.c project4/tac.c project4/tac.h project4/mips32.h project4/variableLInkedLIst.h project4/variableLinkedList.c)