-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
38 lines (29 loc) · 1.06 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
cmake_minimum_required(VERSION 3.25)
project(kevs)
option(RELEASE "Release build" OFF)
option(NO_SAN "Disable sanitizers" OFF)
option(NO_COV "Disable code coverage" OFF)
message(STATUS "CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (RELEASE)
set(NO_SAN ON)
set(NO_COV ON)
string(APPEND CMAKE_C_FLAGS " -O3")
endif()
string(APPEND CMAKE_C_FLAGS " -std=c99 -g -Wall -Wextra -Werror")
if (NOT NO_SAN)
string(APPEND CMAKE_C_FLAGS " -fsanitize=address,undefined -fno-sanitize-recover=all")
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
if (NOT NO_COV)
string(APPEND CMAKE_C_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
endif()
endif()
add_executable(kevs src/cli.c src/kevs.c src/util.c)
add_executable(unittests src/unittests.c src/kevs.c)
add_executable(example src/example.c src/kevs.c src/util.c)
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_executable(fuzzer src/fuzzer.c src/kevs.c)
target_compile_options(fuzzer PUBLIC -fsanitize=fuzzer)
target_link_options(fuzzer PUBLIC -fsanitize=fuzzer)
endif()