-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (99 loc) · 3.62 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
124
125
126
127
cmake_minimum_required(VERSION 3.14)
project(paracl)
option(INSOURCEBUILD OFF)
if((${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) AND NOT
${INSOURCEBUILD})
message(
FATAL_ERROR
"In-source building disabled. Provide -DINSOURCEBUILD option if you are sure about it."
)
endif()
set(CONSTEXPR_DEPTH_LIMIT 4096)
# Possibly support windows and MSVC compiler
if(MSVC)
add_compile_options(/W2)
else()
add_compile_options(-Wall -Wextra -fconstexpr-depth=${CONSTEXPR_DEPTH_LIMIT})
endif()
option(LINT OFF)
if(${LINT})
find_program(CLANG_TIDY_EXECUTABLE "clang-tidy")
set(CLANG_TIDY_COMMAND
"${CLANG_TIDY_EXECUTABLE}"
"-checks=-*,modernize-*,-modernize-use-trailing-return-type*,readability-*,-readability-implicit-bool-conversion*,\
-readability-identifier-length*,portability-*,bugprone-*")
function(target_enable_linter TARGET_NAME)
set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY
"${CLANG_TIDY_COMMAND}")
endfunction()
else()
function(target_enable_linter TARGET_NAME)
# Do nothing
endfunction()
endif()
option(PROFILE OFF)
if(PROFILE)
add_compile_options(-pg)
add_link_options(-pg)
endif()
option(SANITIZE OFF)
if(SANITIZE)
add_compile_options(-fsanitize=undefined,address -fno-omit-frame-pointer)
add_link_options(-fsanitize=undefined,address -fno-omit-frame-pointer)
endif()
include(FetchContent)
FetchContent_Declare(
graphs
GIT_REPOSITORY "https://github.com/ajlekcahdp4/graphs.git"
GIT_TAG origin/main)
FetchContent_Declare(
ezvis
GIT_REPOSITORY "https://github.com/serjzimmerman/ezvis.git"
GIT_TAG origin/main)
FetchContent_Declare(
fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG origin/master)
FetchContent_MakeAvailable(graphs ezvis fmt)
# Tools
find_package(FLEX REQUIRED)
find_package(BISON 3.5 REQUIRED)
# External libraries
add_subdirectory(3rd-party/popl EXCLUDE_FROM_ALL)
# Compiler source
set(BYTECODE_VM_SOURCES src/bytecode_vm/decl_vm.cc)
add_library(bytecode_vm STATIC ${BYTECODE_VM_SOURCES})
target_include_directories(bytecode_vm PUBLIC include)
target_compile_features(bytecode_vm PUBLIC cxx_std_20)
target_link_libraries(bytecode_vm PUBLIC fmt::fmt)
add_executable(pcldis src/pcldis.cc)
target_link_libraries(pcldis popl bytecode_vm)
target_enable_linter(pcldis)
add_executable(pclvm src/pclvm.cc)
target_link_libraries(pclvm popl bytecode_vm)
target_enable_linter(pclvm)
bison_target(
parser src/frontend/parser/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.y.cc
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/bison_paracl_parser.hpp)
flex_target(scanner src/frontend/parser/scanner.l
${CMAKE_CURRENT_BINARY_DIR}/scanner.l.cc)
add_flex_bison_dependency(scanner parser)
set(PARACL_COMPILER_SOURCES
src/frontend/dumper.cc src/frontend/analysis/function_explorer.cc
src/frontend/analysis/semantic_analyzer.cc src/frontend/ast_copier.cc)
add_library(
paracl_compiler STATIC ${PARACL_COMPILER_SOURCES} ${BISON_parser_OUTPUTS}
${FLEX_scanner_OUTPUTS})
target_include_directories(paracl_compiler PUBLIC include
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(paracl_compiler PUBLIC ezvis graphs fmt::fmt)
target_enable_linter(paracl_compiler)
add_executable(pclc src/pclc.cc)
target_link_libraries(pclc PRIVATE ezvis popl paracl_compiler bytecode_vm)
target_enable_linter(pclc)
set(SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
find_program(BASH_PROGRAM bash)
if(BASH_PROGRAM)
enable_testing()
add_subdirectory(test)
endif()