-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (54 loc) · 1.57 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
cmake_minimum_required(VERSION 3.15)
project(baremetal_cxx_coro CXX)
include(CTest)
enable_testing()
set(MY_CMAKE_FLAGS "" CACHE STRING "Additional CMake command line flags")
option(ENABLE_FUZZING "Enable Fuzzing Builds" OFF)
option(ENABLE_ASAN "Enable Address Sanitize Builds" OFF)
if(ENABLE_ASAN)
add_compile_options(-fsanitize=address -fsanitize=leak )
add_link_options(-fsanitize=address)
endif()
# -fno-exceptions
# -fno-use-cxa-atexit
add_compile_options(
-std=c++20
-Os
-g
-Wall
-ffunction-sections
-fno-rtti
-fno-nonansi-builtins
-fno-threadsafe-statics
-nostartfiles
-fcoroutines
-Wextra
-Wpedantic
-fno-diagnostics-color
-Wno-unused-function
-Werror
)
include_directories(${PROJECT_SOURCE_DIR}/include)
set ( STACK_SIZE 0xf00 )
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}")
add_compile_options(-DHOST_EMULATION -D__riscv_xlen=32)
else()
add_compile_options(-march=${CMAKE_SYSTEM_PROCESSOR} -DTARGET_MTIME_FREQ_HZ=10000000)
SET(LINKER_SCRIPT "${PROJECT_SOURCE_DIR}/src/linker.lds")
SET(MY_CMAKE_FLAGS "-DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/cmake/riscv.cmake")
# Linker control
add_link_options(
-nostartfiles
-Xlinker
--defsym=__stack_size=${STACK_SIZE}
-T ${LINKER_SCRIPT}
-Wl,-Map=${TARGET}.map)
endif()
set(CMAKE_CXX_STANDARD 20)
SET(DCMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(src)
add_subdirectory(test)
if(ENABLE_FUZZING)
message("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html")
add_subdirectory(test/fuzz)
endif()