-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (53 loc) · 1.98 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
# Create target for the parser
cmake_minimum_required(VERSION 3.8)
set(ROOT ${CMAKE_CURRENT_SOURCE_DIR})
find_package(LLVM REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
llvm_map_components_to_libnames(llvm_libs support core irreader)
add_custom_command(
OUTPUT lexer.l parser.yxx
COMMAND ${ROOT}/gen.py --root_dir ${ROOT} --output_dir .
DEPENDS ${ROOT}/parser/* ${ROOT}/lexer/* ${ROOT}/gen.py
COMMENT "generate from template"
)
add_custom_command(
OUTPUT parser.cpp parser.hxx
COMMAND bison parser.yxx --defines=parser.hxx --output=parser.cpp -v
DEPENDS parser.yxx
COMMENT "bison gen"
)
add_custom_command(
OUTPUT lexer.cpp
COMMAND flex++ -o lexer.cpp lexer.l
DEPENDS lexer.l
COMMENT "flex gen"
)
SET_SOURCE_FILES_PROPERTIES(parser.hxx GENERATED)
SET_SOURCE_FILES_PROPERTIES(lexer.cpp GENERATED)
SET_SOURCE_FILES_PROPERTIES(parser.cpp GENERATED)
set(CMAKE_CXX_STANDARD 17)
include_directories(kernel)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(parser_hxx DEPENDS parser.hxx)
file(GLOB VISITOR_CPPS kernel/PrintVisitor.cpp kernel/LoadSymbolTableVisitor.cpp kernel/StaticAnalyseVisitor.cpp)
add_library(visitors ${VISITOR_CPPS})
add_dependencies(visitors parser_hxx)
file(GLOB STATIC_ANALYSE kernel/static_analyse_driver/*.cpp)
add_library(static_analyse ${STATIC_ANALYSE})
target_link_libraries(static_analyse visitors)
add_library(parser parser.cpp)
add_library(lexer lexer.cpp)
add_dependencies(lexer parser_hxx)
file(GLOB LLVM_DRIVER kernel/llvm_driver/*.cpp kernel/CodegenVisitor.cpp)
add_library(llvm_driver ${LLVM_DRIVER})
target_link_libraries(llvm_driver ${llvm_libs})
add_dependencies(llvm_driver parser_hxx)
add_executable(main kernel/main.cpp)
# target_link_libraries(main visitors)
target_link_libraries(main parser)
target_link_libraries(main lexer)
target_link_libraries(main static_analyse)
target_link_libraries(main llvm_driver)