-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
123 lines (111 loc) · 3.77 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.5)
project(compiler)
option(tests "Build tests" OFF)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wextra")
set(CMAKE_CXX_STANDARD 14)
set(INCLUDE_FILES
include/Arguments.hpp
include/ast/AssignmentNode.hpp
include/ast/IdentifierNode.hpp
include/ast/IfNode.hpp
include/ast/IfElseNode.hpp
include/ast/InitNode.hpp
include/ast/IntegerNode.hpp
include/ast/OpDivideNode.hpp
include/ast/OpEqualityNode.hpp
include/ast/OpGreaterThanEqualNode.hpp
include/ast/OpGreaterThanNode.hpp
include/ast/OpInequalityNode.hpp
include/ast/OpLessThanEqualNode.hpp
include/ast/OpLessThanNode.hpp
include/ast/OpMinusNode.hpp
include/ast/OpMultiplyNode.hpp
include/ast/OpOrNode.hpp
include/ast/OpPlusNode.hpp
include/ast/PrintNode.hpp
include/ast/StatementsNode.hpp
include/ast/SyntaxTree.hpp
include/ast/SyntaxTree.ih
include/ast/SyntaxTreeNode.hpp
include/ast/SyntaxTreeNodes.ih
include/ast/WhileNode.hpp
include/generator/IGenerator.hpp
include/generator/MipsAdd.hpp
include/generator/MipsBranchEqual.hpp
include/generator/MipsCodeGenerator.hpp
include/generator/MipsComment.hpp
include/generator/MipsDefines.hpp
include/generator/MipsDivide.hpp
include/generator/MipsEquality.hpp
include/generator/MipsGenerator.hpp
include/generator/MipsInequality.hpp
include/generator/MipsJump.hpp
include/generator/MipsLabel.hpp
include/generator/MipsLessThan.hpp
include/generator/MipsLoad.hpp
include/generator/MipsLoadAddress.hpp
include/generator/MipsLoadImmediate.hpp
include/generator/MipsMinus.hpp
include/generator/MipsMultiply.hpp
include/generator/MipsOp.hpp
include/generator/MipsOptimizer.hpp
include/generator/MipsOr.hpp
include/generator/MipsPop.hpp
include/generator/MipsPush.hpp
include/generator/MipsStatement.hpp
include/generator/MipsStatements.ih
include/generator/MipsStore.hpp
include/generator/MipsSysCall.hpp
include/generator/MipsUtil.hpp
)
set(LIB_SOURCE_FILES
src/Arguments.cpp
src/ast/AssignmentNode.cpp
src/ast/IdentifierNode.cpp
src/ast/IfNode.cpp
src/ast/IfElseNode.cpp
src/ast/InitNode.cpp
src/ast/IntegerNode.cpp
src/ast/OpDivideNode.cpp
src/ast/OpEqualityNode.cpp
src/ast/OpGreaterThanEqualNode.cpp
src/ast/OpGreaterThanNode.cpp
src/ast/OpInequalityNode.cpp
src/ast/OpLessThanEqualNode.cpp
src/ast/OpLessThanNode.cpp
src/ast/OpMinusNode.cpp
src/ast/OpMultiplyNode.cpp
src/ast/OpOrNode.cpp
src/ast/OpPlusNode.cpp
src/ast/PrintNode.cpp
src/ast/StatementsNode.cpp
src/ast/WhileNode.cpp
src/generator/MipsCodeGenerator.cpp
src/generator/MipsGenerator.cpp
src/generator/MipsOptimizer.cpp
src/generator/MipsUtil.cpp
)
set(SOURCE_FILES src/main.cpp)
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
BISON_TARGET(Parser ${CMAKE_CURRENT_SOURCE_DIR}/lang/grammar.y ${CMAKE_CURRENT_BINARY_DIR}/grammar.tab.c)
FLEX_TARGET(Lexer ${CMAKE_CURRENT_SOURCE_DIR}/lang/lex.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.c)
ADD_FLEX_BISON_DEPENDENCY(Lexer Parser)
set_source_files_properties(${BISON_Parser_OUTPUT_SOURCE} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${FLEX_Lexer_OUTPUTS} PROPERTIES LANGUAGE CXX)
set(GENERATED_FILES ${BISON_Parser_OUTPUTS} ${FLEX_Lexer_OUTPUTS})
add_library(compiler_lib ${INCLUDE_FILES} ${LIB_SOURCE_FILES} ${GENERATED_FILES})
add_executable(compiler ${INCLUDE_FILES} ${SOURCE_FILES})
target_link_libraries(compiler compiler_lib)
if(${tests})
set(TEST_INCLUDE_FILES ${INCLUDE_FILES} include/catch.hpp)
set(TEST_SOURCE_FILES
test/grammar.cpp
test/lexer.cpp
test/main.cpp
)
add_executable(compiler_tests ${TEST_INCLUDE_FILES} ${TEST_SOURCE_FILES})
target_link_libraries(compiler_tests compiler_lib)
endif()