-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (43 loc) · 1.48 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
cmake_minimum_required(VERSION 3.17)
project(Compiler)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-I/usr/local/opt/flex/include")
add_compile_options("-Wall" "-pedantic" "-Ofast" "-march=native" "-fomit-frame-pointer")
# FLEX and BISON
find_package(BISON 3.6 REQUIRED)
find_package(FLEX REQUIRED)
BISON_TARGET(parser utils/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
FLEX_TARGET(scanner utils/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c)
ADD_FLEX_BISON_DEPENDENCY(scanner parser)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# LLVM
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# Common sources
include_directories(include)
file(GLOB HEADERS include/*.hpp)
file(GLOB SOURCES src/*.cpp)
# Interpreter
add_executable(
interpreter
interpreter.cpp
${HEADERS}
${SOURCES}
${BISON_parser_OUTPUTS}
${FLEX_scanner_OUTPUTS})
# Compiler
add_executable(
compiler
compiler.cpp
${HEADERS}
${SOURCES}
${BISON_parser_OUTPUTS}
${FLEX_scanner_OUTPUTS})
llvm_map_components_to_libnames(llvm_libs support core passes x86asmparser x86codegen)
# Link against LLVM libraries
target_link_libraries(compiler ${llvm_libs})
target_link_libraries(interpreter ${llvm_libs}) # too lazy to not GLOB sources