-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt_c_Project_SafetyFlags_GNU.cmake
72 lines (65 loc) · 1.3 KB
/
CMakeLists.txt_c_Project_SafetyFlags_GNU.cmake
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
# Safety flags for GCC.
# Some of the safety flags may request certain optimization level.
# Based on:
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
# https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
# https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc
list(APPEND SAFETY_FLAGS
-Wall
-Wextra
-Wshadow
-Winit-self
-Wuninitialized
-Wundef
-Wswitch-enum
-Wdouble-promotion
-Wformat=2
-Wformat-security
-Wconversion
-Wsign-conversion
-Wold-style-cast
-Wunreachable-code
-Werror
-Wpedantic
-Wno-unused-value
-Wno-unused-result
-Wno-unused-function
-Wno-unused-parameter
-Winfinite-recursion
-Wnonnull # works with -Og
-Wnull-dereference # works with -O1
)
if(QT_FOUND)
list(APPEND SAFETY_FLAGS
-Wno-padded
)
endif()
list(APPEND SAFETY_FLAGS
-Wformat-overflow
-Wformat-truncation
-Wl,-z,defs
-Wl,-z,now
-Wl,-z,relro
)
if(NOT WIN32)
list(APPEND SAFETY_FLAGS
-fstack-clash-protection
-fstack-protector-all
-fstack-protector-strong
-fno-short-enums
-fno-fast-math
-fno-common
-fno-lto
-fexceptions
-fverbose-asm
-fasynchronous-unwind-tables
)
endif()
list(APPEND SAFETY_FLAGS
-pipe
-march=native
-D_FORTIFY_SOURCE=2
)
list(APPEND SAFETY_FLAGS
-Wno-float-conversion
)