blob: f67f8a544af186e13d817502a6d9788958a8d421 (
plain)
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
|
# SetupBuildFlags.cmake
#
# Setups compiler/linker flags, skipping those which are not supported.
include(CheckCCompilerFlag)
if(CMAKE_CXX_COMPILER_ID)
include(CheckCXXCompilerFlag)
endif(CMAKE_CXX_COMPILER_ID)
macro(setup_build_flags _maintainer_mode)
list(APPEND proposed_flags
-Wformat
-Wformat-security
-Winit-self
-Wmissing-declarations
-Wmissing-noreturn
-Wpointer-arith
-Wredundant-decls
-Wundef
-Wwrite-strings
-Wno-cast-function-type
-Wl,--no-undefined
-fno-strict-aliasing
)
if(${_maintainer_mode})
list(APPEND proposed_flags
-Wall
-Wextra
-Wdeprecated-declarations
-Wmissing-include-dirs
)
else(${_maintainer_mode})
list(APPEND proposed_flags
-Wno-deprecated-declarations
-Wno-missing-include-dirs)
endif(${_maintainer_mode})
list(APPEND proposed_c_flags
${proposed_flags}
-Werror-implicit-function-declaration
-Wdeclaration-after-statement
-Wno-missing-field-initializers
-Wno-sign-compare
-Wno-unused-parameter
-Wnested-externs
)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
list(APPEND proposed_c_flags
-Wno-parentheses-equality
-Wno-format-nonliteral
)
endif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
list(APPEND proposed_cxx_flags
${proposed_flags}
-Wnoexcept
)
foreach(flag IN LISTS proposed_c_flags)
check_c_compiler_flag(${flag} c_flag_${flag}_supported)
if(c_flag_${flag}_supported)
set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
endif(c_flag_${flag}_supported)
unset(c_flag_${flag}_supported)
endforeach()
if(CMAKE_CXX_COMPILER_ID)
foreach(flag IN LISTS proposed_cxx_flags)
check_cxx_compiler_flag(${flag} cxx_flag_${flag}_supported)
if(cxx_flag_${flag}_supported)
set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}")
endif(cxx_flag_${flag}_supported)
unset(cxx_flag_${flag}_supported)
endforeach()
endif(CMAKE_CXX_COMPILER_ID)
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD"))
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
endif(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD"))
endmacro()
|