-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
68 lines (56 loc) · 1.81 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
cmake_minimum_required(VERSION 3.21)
project(atcc C CXX)
set(CMAKE_C_STANDARD 99)
if (APPLE)
set(LLVM_DIR /opt/homebrew/opt/llvm/lib/cmake/llvm)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(WITH_UTESTS)
set(TEST_SOURCES source/tests/tests-ati.c source/tests/tests-bc.c)
endif ()
add_executable(atcc
source/ati/basic.h
source/ati/config.c
source/ati/config.h
source/ati/string.c
source/ati/string.h
source/ati/table.c
source/ati/table.h
source/ati/utest.c
source/ati/utest.h
source/ati/utils.c
source/ati/utils.h
source/emit/amd64.c
source/emit/arm64.c
source/emit/bcdump.c
source/emit/bytecode.c
source/emit/bytecode.h
source/emit/llvm.c
source/emit/source.c
source/debug.c
source/eval.c
source/lexer.c
source/lower.c
source/main.c
source/parser.c
source/sema.c
source/type.c
${TEST_SOURCES} source/emit/output-mac.c)
find_package(LLVM CONFIG)
if (LLVM_FOUND)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
target_include_directories(atcc PRIVATE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(atcc PRIVATE ${LLVM_DEFINITIONS})
target_link_directories(atcc PRIVATE ${LLVM_LIBRARY_DIRS})
target_compile_definitions(atcc PRIVATE -DUSE_LLVM)
target_link_libraries(atcc LLVM)
else ()
message(STATUS "LLVM not found")
endif ()
target_include_directories(atcc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source)
# Enable address sanitizer
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(atcc PRIVATE -fsanitize=address)
target_link_options(atcc PRIVATE -fsanitize=address)
endif ()