Skip to content

Commit 84c0bd1

Browse files
committed
cmake: Adjust diagnostic flags for clang-cl
1 parent f79f46c commit 84c0bd1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,21 @@ endif()
242242

243243
include(TryAppendCFlags)
244244
if(MSVC)
245-
# Keep the following commands ordered lexicographically.
245+
# For both cl and clang-cl compilers.
246246
try_append_c_flags(/W3) # Production quality warning level.
247+
# Eliminate deprecation warnings for the older, less secure functions.
248+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
249+
else()
250+
try_append_c_flags(-Wall) # GCC >= 2.95 and probably many other compilers.
251+
endif()
252+
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
253+
# Keep the following commands ordered lexicographically.
247254
try_append_c_flags(/wd4146) # Disable warning C4146 "unary minus operator applied to unsigned type, result still unsigned".
248255
try_append_c_flags(/wd4244) # Disable warning C4244 "'conversion' conversion from 'type1' to 'type2', possible loss of data".
249256
try_append_c_flags(/wd4267) # Disable warning C4267 "'var' : conversion from 'size_t' to 'type', possible loss of data".
250-
# Eliminate deprecation warnings for the older, less secure functions.
251-
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
252257
else()
253258
# Keep the following commands ordered lexicographically.
254259
try_append_c_flags(-pedantic)
255-
try_append_c_flags(-Wall) # GCC >= 2.95 and probably many other compilers.
256260
try_append_c_flags(-Wcast-align) # GCC >= 2.95.
257261
try_append_c_flags(-Wcast-align=strict) # GCC >= 8.0.
258262
try_append_c_flags(-Wconditional-uninitialized) # Clang >= 3.0 only.

0 commit comments

Comments
 (0)