-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
57 lines (50 loc) · 2.13 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
# Bluebird compiler - ahead-of-time compiler for the Bluebird language using LLVM.
# Copyright (C) 2020-2021 Cole Blakley
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.19.1)
project(Bluebird)
# For some reason CMake can't find LLVM on macOS,
# so we need to give it some help
find_package(LLVM 13.0 REQUIRED CONFIG
HINTS /usr/local/opt/llvm/lib/cmake/llvm)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
link_directories(${LLVM_LIBRARY_DIR})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wdeprecated)
endif()
add_executable(bluebird)
include_directories(src third_party third_party/mini-gmp)
add_subdirectory(src)
add_subdirectory(third_party/mini-gmp)
llvm_map_components_to_libnames(LLVM_LIBS core native option passes)
target_link_libraries(bluebird ${LLVM_LIBS})
#libfuzzer build mode - fuzzes lexer (does not work with AppleClang)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message("Note: fuzzer target enabled")
add_executable(fuzzer src/fuzzer.cpp src/lexer.cpp src/token.cpp src/error.cpp)
target_compile_options(fuzzer PRIVATE -fsanitize=fuzzer)
target_link_libraries(fuzzer PRIVATE -fsanitize=fuzzer)
# Set -DFUZZER_MODE (C++ macro definition)
target_compile_definitions(fuzzer PRIVATE FUZZER_MODE)
else()
message("Note: fuzzer target not enabled (compiler is not Clang)")
endif()