-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
31 lines (26 loc) · 1.11 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
project ( fuzzing-lua C )
cmake_minimum_required ( VERSION 2.8 )
cmake_policy(SET CMP0022 NEW)
include(${CMAKE_CURRENT_LIST_DIR}/deps/lua-5.1.cmake)
add_library( luafuzzhelper src/llex_helper.c )
target_link_libraries( luafuzzhelper PRIVATE liblua )
target_include_directories( luafuzzhelper PUBLIC src )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
option(ENABLE_FUZZING "Create executables and targets for fuzzing." On)
option(COVERAGE "Enable code coverage tracking" Off)
if (COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
set(COVERAGE_LINKER_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
endif()
if (ENABLE_FUZZING)
if(NOT FUZZ_ENGINE AND NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
message(FATAL_ERROR "Fuzzing requires a FUZZ_ENGINE or the Clang compiler")
endif()
set(CMAKE_BUILD_TYPE Debug)
if (NOT COVERAGE AND NOT FUZZ_ENGINE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address,undefined,fuzzer -fno-sanitize=alignment -fno-omit-frame-pointer")
endif()
add_subdirectory(fuzz)
else()
add_subdirectory(tools)
endif()