3 # Warning flags ===============================================================
4 function(cxx_add_warning_flags target enable_werror enable_pedantic)
5 target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7 # -W4 is the cl.exe/clang-cl equivalent of -Wall. (In cl.exe and clang-cl,
8 # -Wall is equivalent to -Weverything in GCC style compiler drivers.)
9 target_add_compile_flags_if_supported(${target} PRIVATE -W4)
11 target_add_compile_flags_if_supported(${target} PRIVATE -Wall)
13 # TODO: Should -Wconversion be enabled?
14 target_add_compile_flags_if_supported(${target} PRIVATE
28 if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
29 target_add_compile_flags_if_supported(${target} PRIVATE
30 -Wno-user-defined-literals
31 -Wno-covered-switch-default
34 if (LIBCXX_TARGETING_CLANG_CL)
35 target_add_compile_flags_if_supported(${target} PRIVATE
37 -Wno-c++98-compat-pedantic
40 -Wno-reserved-id-macro
42 -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings
43 -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences.
44 -Wno-deprecated-dynamic-exception-spec # For auto_ptr
47 -Wno-deprecated # FIXME: Remove this and fix all occurrences.
48 -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang?
49 -Wno-double-promotion # FIXME: remove me
53 elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
55 target_add_compile_flags_if_supported(${target} PRIVATE
67 target_add_compile_flags_if_supported(${target} PRIVATE -Werror)
68 target_add_compile_flags_if_supported(${target} PRIVATE -WX)
70 # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
72 target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error)
74 if (${enable_pedantic})
75 target_add_compile_flags_if_supported(${target} PRIVATE -pedantic)