-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
48 lines (39 loc) · 1.7 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
cmake_minimum_required(VERSION 3.0)
project (d2itemreader C)
# Quoted variables like "MSVC" will no longer be dereferenced when the policy is set to NEW
cmake_policy(SET CMP0054 NEW)
file(GLOB HEADERS "src/*.h")
file(GLOB LIBSRC "src/*.c")
add_library( d2itemreader ${LIBSRC} ${HEADERS} )
target_include_directories(d2itemreader PUBLIC src/)
set_target_properties(d2itemreader PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED true)
if (MSVC)
target_compile_definitions( d2itemreader PUBLIC _CRT_SECURE_NO_WARNINGS )
target_compile_definitions( d2itemreader PUBLIC _CRT_NONSTDC_NO_WARNINGS )
endif()
if (("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /sdl")
endif()
option(ENABLE_FUZZING "Create executables and targets for fuzzing." Off)
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(tests/fuzz)
else()
add_subdirectory(examples)
add_subdirectory(tools)
enable_testing()
add_subdirectory(tests)
endif()