1+ # -------------------------------------------------------------------------------------------------------------- #
2+ # GCC compiler utilities
3+ # -------------------------------------------------------------------------------------------------------------- #
4+
5+ include_guard (GLOBAL )
6+
7+ # Debug
8+ message (VERBOSE "rsp/compilers/gcc module included" )
9+
10+ # GCC strict compile options
11+ #
12+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Option-Index.html
13+ # @see https://gcc.gnu.org/onlinedocs/
14+ #
15+ if (NOT DEFINED RSP_GCC_STRICT_COMPILE_OPTIONS)
16+ set (RSP_GCC_STRICT_COMPILE_OPTIONS
17+
18+ # Issue all the warnings demanded by strict ISO C and ISO C++.
19+ #
20+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-pedantic-1
21+ #
22+ -pedantic
23+
24+ # Enables all the warnings about constructions...
25+ #
26+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wall
27+ #
28+ -Wall
29+
30+ # Enables some extra warning flags that are not enabled by -Wall.
31+ #
32+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wextra
33+ #
34+ -Wextra
35+
36+ # Warn if an old-style (C-style) cast to a non-void type is used within a C++ program.
37+ #
38+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wold-style-cast
39+ #
40+ -Wold-style-cast
41+
42+ # Warn whenever a pointer is cast such that the required alignment of the target is increased.
43+ #
44+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wcast-align
45+ #
46+ -Wcast-align
47+
48+ # Warn whenever a pointer is cast so as to remove a type qualifier from the target type.
49+ #
50+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wcast-qual
51+ #
52+ -Wcast-qual
53+
54+ # Warn when a class seems unusable because all the constructors or destructors in that class
55+ # are private, and it has neither friends nor public static member functions.
56+ #
57+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wctor-dtor-privacy
58+ #
59+ -Wctor-dtor-privacy
60+
61+ # Warn if a requested optimization pass is disabled.
62+ #
63+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wdisabled-optimization
64+ #
65+ -Wdisabled-optimization
66+
67+ # Check calls to printf and scanf, etc., to make sure that the arguments supplied have types
68+ # appropriate to the format string specified.
69+ #
70+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wformat
71+ #
72+ -Wformat=2
73+
74+ # Warn about uninitialized variables that are initialized with themselves.
75+ #
76+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Winit-self
77+ #
78+ -Winit-self
79+
80+ # Warn about suspicious uses of logical operators in expressions.
81+ #
82+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wlogical-op
83+ #
84+ -Wlogical-op
85+
86+ # Warn if a global function is defined without a previous declaration.
87+ #
88+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wmissing-declarations
89+ #
90+ -Wmissing-declarations
91+
92+ # Warn if a user-supplied include directory does not exist.
93+ #
94+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wmissing-include-dirs
95+ #
96+ -Wmissing-include -dirs
97+
98+ # Warn when a noexcept-expression evaluates to false because of a call to a function that
99+ # does not have a non-throwing exception specification.
100+ #
101+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wnoexcept
102+ #
103+ -Wnoexcept
104+
105+ # Warn when a function declaration hides virtual functions from a base class.
106+ #
107+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Woverloaded-virtual
108+ #
109+ -Woverloaded-virtual
110+
111+ # Warn if anything is declared more than once in the same scope.
112+ #
113+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wredundant-decls
114+ #
115+ -Wredundant-decls
116+
117+ # Warn for implicit conversions that may change the sign of an integer value, like assigning
118+ # a signed integer expression to an unsigned integer variable.
119+ #
120+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wsign-conversion
121+ #
122+ -Wsign-conversion
123+
124+ # Warn when a comparison between signed and unsigned values could produce an incorrect result
125+ # when the signed value is converted to unsigned.
126+ #
127+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wsign-compare
128+ #
129+ #-Wsign-compare # (Enabled by -Wall)
130+
131+ # Warn when overload resolution chooses a promotion from unsigned or enumerated type to a
132+ # signed type, over a conversion to an unsigned type of the same size.
133+ #
134+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wsign-promo
135+ #
136+ -Wsign-promo
137+
138+ # Warn about the use of an uncasted NULL as sentinel.
139+ #
140+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wstrict-null-sentinel
141+ #
142+ -Wstrict-null-sentinel
143+
144+ # Warns about cases where the compiler optimizes based on the assumption that signed overflow does not occur.
145+ #
146+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wstrict-overflow
147+ #
148+ -Wstrict-overflow=3 # (-Wall only includes Wstrict-overflow=1)
149+
150+ # Warn whenever a switch statement does not have a default case.
151+ #
152+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wswitch-default
153+ #
154+ -Wswitch-default
155+
156+ # Warn if an undefined identifier is evaluated in an #if directive.
157+ #
158+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wundef
159+ #
160+ -Wundef
161+
162+ # All the -Wunused options combined.
163+ #
164+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wno-unused
165+ #
166+ -Wno-unused
167+
168+ # Warn about violations of the style guidelines from Scott Meyers’ Effective C++ series
169+ # of books.
170+ #
171+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Weffc_002b_002b
172+ #
173+ -Weffc++
174+
175+ # Make all warnings into errors.
176+ #
177+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Werror
178+ #
179+ -Werror
180+
181+ # Print (on standard error output) the commands executed to run the stages of compilation.
182+ #
183+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Overall-Options.html#index-v
184+ #
185+ #-v
186+
187+ # Dump all macro definitions, at the end of preprocessing, in addition to normal output.
188+ #
189+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Preprocessor-Options.html#index-dD
190+ # @see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Developer-Options.html#index-dD-1
191+ #
192+ #-dD
193+ )
194+ endif ()
0 commit comments