-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
140 lines (113 loc) · 3 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
128
129
130
131
132
133
134
135
136
137
138
139
140
cmake_minimum_required(VERSION 3.2)
find_program(NODE_EXECUTABLE
NAMES node nodejs
)
if(NOT NODE_EXECUTABLE)
message(SEND_ERROR "Could not find Node executable")
endif()
list(APPEND CMAKE_MODULE_PATH
cmake/Modules
${CMAKE_CURRENT_LIST_DIR}/third_party/omr/cmake/modules/
)
project(base9
LANGUAGES C CXX
VERSION 0.1
)
include(OmrPlatform)
# Global Configuration
omr_platform_global_setup()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
enable_testing()
# Optional debug and testing features
set(B9_GCOV OFF CACHE BOOL "Run tests with gcov to gather code coverage data.")
if(B9_GCOV)
add_compile_options(
-fprofile-arcs
-ftest-coverage
-O0
-g
)
link_libraries(
-fprofile-arcs
-ftest-coverage
)
endif(B9_GCOV)
set(B9_ASAN OFF CACHE BOOL "Build b9 with clang address sanitizer enabled.")
if(B9_ASAN)
add_compile_options(
-fsanitize=address -fno-omit-frame-pointer
)
link_libraries(
-fsanitize=address
)
endif(B9_ASAN)
set(B9_UBSAN OFF CACHE BOOL "Build b9 with clang undefined behaviour sanitizer.")
if(B9_UBSAN)
add_compile_options(
-fsanitize=undefined
)
link_libraries(
-fsanitize=undefined
)
endif(B9_UBSAN)
# OMR Configuration
set(OMR_COMPILER ON CACHE INTERNAL "Enable the Compiler.")
set(OMR_JITBUILDER ON CACHE INTERNAL "We use OMR's jitbuilder tool for the b9 JIT")
set(OMR_EXAMPLE OFF CACHE INTERNAL "Disable the GC example")
set(OMR_OM ON CACHE INTERNAL "Enable OMR Om, a GC object model")
set(OMR_GC ON CACHE INTERNAL "Enable the GC")
set(OMR_FVTEST OFF CACHE INTERNAL "Disable OMR's internal test suite, it's incompatible with b9")
set(OMR_WARNINGS_AS_ERRORS OFF CACHE INTERNAL "OMR doesn't compile cleanly on my laptop :p")
# Compile a b9-js *.js to C++
function(add_b9_module src)
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/${src}.b9mod"
COMMAND
${NODE_EXECUTABLE}
"${CMAKE_SOURCE_DIR}/js_compiler/compile.js"
"${CMAKE_CURRENT_SOURCE_DIR}/${src}.js"
"${src}.b9mod"
MAIN_DEPENDENCY
"${CMAKE_CURRENT_SOURCE_DIR}/${src}.js"
DEPENDS
"${CMAKE_SOURCE_DIR}/js_compiler/compile.js"
)
add_custom_target(compile_${src} ALL
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/${src}.b9mod"
)
endfunction(add_b9_module)
# Add a b9 test program written in b9-js
function(add_b9_test test)
add_b9_module("${test}")
add_test(
NAME "run_${test}"
COMMAND b9run ${test}.b9mod
)
# add_dependencies(run_${test} ${test}.b9mod)
add_test(
NAME "run_${test}_jit"
COMMAND b9run -jit ${test}.b9mod
)
add_test(
NAME "run_${test}_jit_directcall"
COMMAND b9run -jit -directcall ${test}.b9mod
)
add_test(
NAME "run_${test}_jit_passparam"
COMMAND b9run -jit -directcall -passparam ${test}.b9mod
)
add_test(
NAME "run_${test}_jit_lazyvmstate"
COMMAND b9run -jit -directcall -passparam -lazyvmstate ${test}.b9mod
)
endfunction(add_b9_test)
# Subdirectories
add_subdirectory(b9)
add_subdirectory(b9run)
add_subdirectory(b9disasm)
add_subdirectory(b9asm)
add_subdirectory(test)
add_subdirectory(third_party)