Skip to content

Commit a8d059f

Browse files
committed
cmake, doc: Document compiler flags
1 parent 6ece150 commit a8d059f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

CMakeLists.txt

+13-11
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,22 @@ endif()
193193

194194
include(TryAppendCFlags)
195195
if(MSVC)
196-
try_append_c_flags(/W2)
197-
try_append_c_flags(/wd4146)
196+
# Keep the following commands ordered lexicographically.
197+
try_append_c_flags(/W2) # Moderate warning level.
198+
try_append_c_flags(/wd4146) # Disable warning C4146 "unary minus operator applied to unsigned type, result still unsigned".
198199
else()
200+
# Keep the following commands ordered lexicographically.
199201
try_append_c_flags(-pedantic)
200-
try_append_c_flags(-Wall)
201-
try_append_c_flags(-Wcast-align)
202-
try_append_c_flags(-Wcast-align=strict)
203-
try_append_c_flags(-Wconditional-uninitialized)
204-
try_append_c_flags(-Wextra)
202+
try_append_c_flags(-Wall) # GCC >= 2.95 and probably many other compilers.
203+
try_append_c_flags(-Wcast-align) # GCC >= 2.95.
204+
try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0.
205+
try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only.
206+
try_append_c_flags(-Wextra) # GCC >= 3.4, this is the newer name of -W, which we don't use because older GCCs will warn about unused functions.
205207
try_append_c_flags(-Wnested-externs)
206-
try_append_c_flags(-Wno-long-long)
207-
try_append_c_flags(-Wno-overlength-strings)
208-
try_append_c_flags(-Wno-unused-function)
209-
try_append_c_flags(-Wreserved-identifier)
208+
try_append_c_flags(-Wno-long-long) # GCC >= 3.0, -Wlong-long is implied by -pedantic.
209+
try_append_c_flags(-Wno-overlength-strings) # GCC >= 4.2, -Woverlength-strings is implied by -pedantic.
210+
try_append_c_flags(-Wno-unused-function) # GCC >= 3.0, -Wunused-function is implied by -Wall.
211+
try_append_c_flags(-Wreserved-identifier) # Clang >= 13.0 only.
210212
try_append_c_flags(-Wshadow)
211213
try_append_c_flags(-Wstrict-prototypes)
212214
try_append_c_flags(-Wundef)

0 commit comments

Comments
 (0)