-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
76 lines (63 loc) · 2.74 KB
/
CMakeLists.txt
File metadata and controls
76 lines (63 loc) · 2.74 KB
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
cmake_minimum_required(VERSION 3.13.4)
project(Velva)
# get all file names
file(GLOB_RECURSE lib_srcs ${CMAKE_SOURCE_DIR}/src/*.cpp ${CMAKE_SOURCE_DIR}/src/TreeSitter/*.c)
# set names
set(COMPILER_NAME veld)
set(LIB_NAME velva)
########################## MAKE THE LLVM LIBRARY ##########################
# Find package
find_package(LLVM REQUIRED CONFIG) #Make sure that LLVM is in your CMAKE_PREFIX_PATH
message(STATUS "Found LLVM Package")
# Assert that the version of LLVM is good
if (NOT ${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "15.0.0")
message(FATAL_ERROR "LLVM Package Requires version > 15.0.0!")
endif()
# For generating targets that will be used to link the libraries
foreach(target ${LLVM_TARGETS_TO_BUILD})
list(APPEND targets "LLVM${target}CodeGen")
endforeach()
# find lib names
set(LLVM_LINK_COMPONENTS aarch64asmparser armasmparser avrasmparser bpfasmparser mipsasmparser msp430asmparser powerpcasmparser riscvasmparser sparcasmparser systemzasmparser veasmparser webassemblyasmparser x86asmparser amdgpuasmparser asmparser analysis support core object irreader executionengine scalaropts instcombine orcjit runtimedyld interpreter mc nativecodegen)
# get lib name
llvm_map_components_to_libnames(llvm_libraries ${LLVM_LINK_COMPONENTS})
########################## RUN COMPILER CPP WITH LIBRARY ##########################
set(CMAKE_CXX_FLAGS "-g -fstandalone-debug")
add_executable(${COMPILER_NAME} ${lib_srcs})
target_compile_options(${COMPILER_NAME} PUBLIC)
target_include_directories(${COMPILER_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${LLVM_INCLUDE_DIRS} $ENV{TREE_SITTER_LIB_INCLUDE})
target_link_libraries(${COMPILER_NAME} PUBLIC ${llvm_libraries} ${targets} $ENV{TREE_SITTER_LIB_FILE})
set_property(TARGET ${COMPILER_NAME} PROPERTY CXX_STANDARD 17) # we are using C++17
################################### SET TESTS #####################################
# first word before space is the name of test in path
# everything after is the expected result of the test
set(TestList
"FunctionTest 9"
"ForLoop ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz"
"WhileLoop ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz"
"Auto 363"
"IfStatements 2"
"Assign 1"
"Ternary 4"
"MultipleConditions 315"
"Boolean 1110"
"Scoping 76<"
"Class 30642253"
"ClassExtra 303520"
"Class&Function 35"
"Arrays 123"
"PointerDouble 2"
"ClassInClass 33"
"Printf int 3 and char: c and two f: 5.000000 3.000000"
)
include(CTest)
foreach (X IN LISTS TestList)
separate_arguments(X)
list(POP_FRONT X NameTest)
string(REPLACE ";" " " ExpectedResult "${X}")
add_test(
NAME ${NameTest}
COMMAND ./veld ../tests/${NameTest}.vld
)
set_property(TEST ${NameTest} PROPERTY PASS_REGULAR_EXPRESSION "^${ExpectedResult}")
endforeach()