-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
93 lines (80 loc) · 1.9 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.13)
project(zalloc_meta C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN true)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
add_compile_options(
# Portability
-fpie
-pie
-fPIC
-shared
# Various hardening options
-fasynchronous-unwind-tables
-fstack-protector-all
-fstack-protector-strong
# Compile-time optimizations
-pipe
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(
-Wall
-Werror
-Wextra
-Wpedantic
-Wlogical-op
-Wdouble-promotion
-Wformat=2
-Wshadow
-Wcast-qual
-Wdisabled-optimization
-Winit-self
-Wmissing-include-dirs
-Wredundant-decls
-Wstrict-overflow=5
-Wundef
-Wconversion
-Wswitch
-Winvalid-pch
-Wformat-nonliteral
-Wmissing-format-attribute
-Wno-nonnull-compare
-fno-delete-null-pointer-checks
)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.8.5)
add_compile_options(
-Wrestrict
-Wnull-dereference
-Wduplicated-cond
-Wduplicated-branches
-Wodr
)
endif()
link_libraries(
gcov
)
add_compile_options(
--coverage
-fprofile-arcs
-ftest-coverage
)
add_link_options(
--coverage
-fprofile-arcs
-ftest-coverage
)
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_compile_definitions(
_FORTIFY_SOURCE=2
)
add_compile_options(
-O2
-flto
)
add_link_options(
-flto
)
endif()
add_subdirectory(src)
add_subdirectory(tests)