@@ -23,7 +23,9 @@ if(NOT EMSCRIPTEN)
23
23
endif ()
24
24
endif ()
25
25
26
- eth_add_cxx_compiler_flag_if_supported (-Wimplicit-fallthrough )
26
+ if (PEDANTIC )
27
+ eth_add_cxx_compiler_flag_if_supported (-Wimplicit-fallthrough )
28
+ endif ()
27
29
28
30
# Prevent the path of the source directory from ending up in the binary via __FILE__ macros.
29
31
eth_add_cxx_compiler_flag_if_supported ("-fmacro-prefix-map=${CMAKE_SOURCE_DIR} =/solidity" )
@@ -32,39 +34,45 @@ eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/
32
34
# if the argument was not wrapped in a call. This happens when moving a local
33
35
# variable in a return statement when the variable is the same type as the
34
36
# return type or using a move to create a new object from a temporary object.
35
- eth_add_cxx_compiler_flag_if_supported (-Wpessimizing-move )
37
+ if (PEDANTIC )
38
+ eth_add_cxx_compiler_flag_if_supported (-Wpessimizing-move )
39
+ endif ()
36
40
37
41
# -Wredundant-move warns when an implicit move would already be made, so the
38
42
# std::move call is not needed, such as when moving a local variable in a return
39
43
# that is different from the return type.
40
- eth_add_cxx_compiler_flag_if_supported (-Wredundant-move )
44
+ if (PEDANTIC )
45
+ eth_add_cxx_compiler_flag_if_supported (-Wredundant-move )
46
+ endif ()
41
47
42
48
if (("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU" ) OR ("${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang" ))
43
49
# Enables all the warnings about constructions that some users consider questionable,
44
50
# and that are easy to avoid. Also enable some extra warning flags that are not
45
51
# enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers
46
52
# to fix warnings as they arise, so they don't accumulate "to be fixed later".
47
- add_compile_options (-Wall )
48
- add_compile_options (-Wextra )
49
- add_compile_options (-Werror )
50
- add_compile_options (-pedantic )
51
- add_compile_options (-Wmissing-declarations )
52
- add_compile_options (-Wno-unknown-pragmas )
53
- add_compile_options (-Wimplicit-fallthrough )
54
- add_compile_options (-Wsign-conversion )
55
- add_compile_options (-Wconversion )
53
+ if (PEDANTIC )
54
+ add_compile_options (-Wall )
55
+ add_compile_options (-Wextra )
56
+ add_compile_options (-Werror )
57
+ add_compile_options (-pedantic )
58
+ add_compile_options (-Wmissing-declarations )
59
+ add_compile_options (-Wno-unknown-pragmas )
60
+ add_compile_options (-Wimplicit-fallthrough )
61
+ add_compile_options (-Wsign-conversion )
62
+ add_compile_options (-Wconversion )
56
63
57
- check_cxx_compiler_flag (-Wextra-semi WEXTRA_SEMI )
58
- if (WEXTRA_SEMI )
59
- add_compile_options ($< $< COMPILE_LANGUAGE:CXX> :-Wextra-semi> )
64
+ check_cxx_compiler_flag (-Wextra-semi WEXTRA_SEMI )
65
+ if (WEXTRA_SEMI )
66
+ add_compile_options ($< $< COMPILE_LANGUAGE:CXX> :-Wextra-semi> )
67
+ endif ()
68
+ eth_add_cxx_compiler_flag_if_supported (-Wfinal-dtor-non-final-class )
69
+ eth_add_cxx_compiler_flag_if_supported (-Wnewline-eof )
70
+ eth_add_cxx_compiler_flag_if_supported (-Wsuggest-destructor-override )
71
+ eth_add_cxx_compiler_flag_if_supported (-Wduplicated-cond )
72
+ eth_add_cxx_compiler_flag_if_supported (-Wduplicate-enum )
73
+ eth_add_cxx_compiler_flag_if_supported (-Wlogical-op )
74
+ eth_add_cxx_compiler_flag_if_supported (-Wno-unknown-attributes )
60
75
endif ()
61
- eth_add_cxx_compiler_flag_if_supported (-Wfinal-dtor-non-final-class )
62
- eth_add_cxx_compiler_flag_if_supported (-Wnewline-eof )
63
- eth_add_cxx_compiler_flag_if_supported (-Wsuggest-destructor-override )
64
- eth_add_cxx_compiler_flag_if_supported (-Wduplicated-cond )
65
- eth_add_cxx_compiler_flag_if_supported (-Wduplicate-enum )
66
- eth_add_cxx_compiler_flag_if_supported (-Wlogical-op )
67
- eth_add_cxx_compiler_flag_if_supported (-Wno-unknown-attributes )
68
76
69
77
# Configuration-specific compiler settings.
70
78
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG" )
@@ -158,7 +166,9 @@ elseif (DEFINED MSVC)
158
166
159
167
add_compile_options (/MP ) # enable parallel compilation
160
168
add_compile_options (/EHsc ) # specify Exception Handling Model in msvc
161
- add_compile_options (/WX ) # enable warnings-as-errors
169
+ if (PEDANTIC )
170
+ add_compile_options (/WX ) # enable warnings-as-errors
171
+ endif ()
162
172
add_compile_options (/wd4068 ) # disable unknown pragma warning (4068)
163
173
add_compile_options (/wd4996 ) # disable unsafe function warning (4996)
164
174
add_compile_options (/wd4503 ) # disable decorated name length exceeded, name was truncated (4503)
0 commit comments