-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
63 lines (47 loc) · 1.38 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
cmake_minimum_required(VERSION 3.20)
project(
tinyclang
VERSION 0.0.1
LANGUAGES C CXX
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_BUILD_TYPE "Debug")
set(project_version "${${PROJECT_NAME}_VERSION}")
message(STATUS "Project '${PROJECT_NAME}', version: '${project_version}'")
option(TINYCLANG_OPT_BUILD_UNITTESTS "Build all tinyclang unittests" ON)
# temp define: https://discourse.llvm.org/t/python-api-problem/945
add_compile_options(-fno-rtti)
# CMake helpers:
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CTest)
include_directories(include)
# Create the tinyclang C++ library
set(tinyclang_SRCS)
set(STATIC_LIB_NAME ${PROJECT_NAME})
# apt install llvm-15-dev
set(LLVM_DIR /usr/lib/llvm-15/lib/cmake/llvm)
# manually install
# set(LLVM_DIR /usr/local/lib/cmake/llvm)
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
file(GLOB_RECURSE LIB_PATH
./lib/Basic/*.cc
./lib/Lexer/*.cc
./lib/Source/*.cc
./lib/Diagnostic/*.cc
)
list(APPEND tinyclang_SRCS ${LIB_PATH})
add_library(${STATIC_LIB_NAME} STATIC ${tinyclang_SRCS})
target_link_libraries(${STATIC_LIB_NAME}
LLVMSupport
LLVMOption
LLVMCore
)
add_subdirectory(Driver)
if (TINYCLANG_OPT_BUILD_UNITTESTS)
add_subdirectory(unittests #[[EXCLUDE_FROM_ALL]])
endif()