-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
221 lines (197 loc) · 4.79 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
cmake_minimum_required(VERSION 3.18)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(
cxbqn
LANGUAGES CXX C
VERSION 0.11.0
)
set(CXBQN_INIT_STACK_SIZE
10000
CACHE STRING "The size the VM stack is initialized with"
)
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "NVHPC")
set(CMAKE_CXX_FLAGS
"-Wall -Wextra ${CMAKE_CXX_FLAGS}"
CACHE STRING ""
)
endif()
set(CXBQN_EXT_STD_FILESYSTEM
OFF
CACHE BOOL "Build std::filesystem using git submodule"
)
set(CXBQN_BUILD_TOOLS
OFF
CACHE BOOL "Build extra tools, eg the compiler examiner"
)
set(CXBQN_BUILD_TESTS
OFF
CACHE BOOL "Build tests, add CTest support"
)
set(CXBQN_REGEN_TESTS
OFF
CACHE BOOL "Regenerate bytecode, simple, and primitive tests"
)
set(CXBQN_MEM_STRATEGY
"leak"
CACHE STRING
"Select memory management strategy from 'shared_ptr', 'gc', 'leak'"
)
set(CXBQN_STACKTRACE
OFF
CACHE
BOOL
"Runs every VM invocation in a try-catch block to provide stack trace information"
)
set(CXBQN_STACKTRACE_DEEP
OFF
CACHE
BOOL
"Checks many additional calls for failure to provide more detailed stack trace information"
)
set(CXBQN_GEN_CODECOV
OFF
CACHE BOOL "Generate code coverage data. Build type must be debug."
)
set(CXBQN_PROFILE_STARTUP
OFF
CACHE BOOL "Output profiling information from the driver"
)
set(CXBQN_PROFILE_VM
OFF
CACHE BOOL "Output profiling information from the VM"
)
set(CXBQN_DEBUG_VM
OFF
CACHE BOOL "Verbose output in the VM for debugging"
)
set(CXBQN_DEBUG_VM_FILE
""
CACHE STRING "Redirect debugging output from VM to a file."
)
set(CXBQN_DEBUG_VMSTACK
OFF
CACHE BOOL "Display the entire stack in the VM for debugging"
)
set(CXBQN_DEEPCHECKS
ON
CACHE BOOL "Deep null checking and debugging information"
)
set(CXBQN_READLINE
OFF
CACHE BOOL "Use libreadline for BQN REPL"
)
set(CXBQN_COLOR
OFF
CACHE BOOL "Output VM information in color"
)
set(CXBQN_LOG
OFF
CACHE BOOL "Enable logging in CXBQN"
)
set(CXBQN_LOGLEVEL
"level::off"
CACHE STRING "Log level spdlog will be set to"
)
set(CHECK_SUBMODULES
ON
CACHE BOOL "Check git submodules on every build"
)
set(CXBQN_CUDA
OFF
CACHE BOOL "Enable CUDA acceleration and non-standard builtins"
)
set(CXBQN_FFI
OFF
CACHE BOOL "Enable foreign function interface"
)
set(CXBQN_NATIVE_R0
ON
CACHE BOOL "Enable native C++ functions for lower-level runtime"
)
set(CXBQN_NATIVE_R1
OFF
CACHE BOOL "Enable native C++ functions for higher-level runtime"
)
set(CXBQN_PLOT
OFF
CACHE BOOL "Enable plotting library (requires python)"
)
add_definitions("-DCXBQN_MEM_${CXBQN_MEM_STRATEGY}=1")
if("${CXBQN_DEBUG_VM_FILE}" STREQUAL "stdout")
set(CXBQN_DEBUG_VM_USE_FILE
ON
CACHE BOOL ""
)
else()
set(CXBQN_DEBUG_VM_USE_FILE
OFF
CACHE BOOL ""
)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING ""
)
endif()
set(HAS_BQN_EXE OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CXBQN_EXT_DIR ${PROJECT_SOURCE_DIR}/ext/)
include(CMakePrintHelpers)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
add_library(tpl INTERFACE)
add_library(cxbqn::tpl ALIAS tpl)
if(CXBQN_READLINE)
find_package(Readline)
target_link_libraries(tpl INTERFACE ${Readline_LIBRARY})
target_include_directories(tpl INTERFACE ${Readline_INCLUDE_DIR})
endif()
if(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
message(
STATUS
"Found default install prefix, setting to ${PROJECT_BINARY_DIR}/install"
)
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)
endif()
find_package(UnixCommands REQUIRED)
include(cmake/Linters.cmake)
include(cmake/CheckGitSubmodules.cmake)
include(cmake/FindBQN.cmake)
include(cmake/CodeCoverage.cmake)
if(CXBQN_CUDA)
if("${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "")
set(CMAKE_CUDA_ARCHITECTURES 60)
endif()
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} --extended-lambda --expt-relaxed-constexpr"
)
include(CheckLanguage)
check_language(CUDA)
enable_language(CUDA)
endif()
if(CXBQN_FFI)
message(STATUS "Enabling foreign function interface")
target_link_libraries(tpl INTERFACE ${CMAKE_DL_LIBS})
endif()
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(${PROJECT_BINARY_DIR})
add_subdirectory(ext)
configure_file(
include/cxbqn/config.hpp.in ${PROJECT_BINARY_DIR}/include/cxbqn/config.hpp
)
add_subdirectory(src)
if(CXBQN_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
file(GLOB_RECURSE CXBQN_HEADERS include/cxbqn/*.hpp)
install(FILES ${CXBQN_HEADERS} DESTINATION include/cxbqn)
install(
DIRECTORY lib
DESTINATION share/bqn
FILES_MATCHING
PATTERN "*.bqn"
)