brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 43ef765 Raw
87 lines · plain
1include(HandleFlags)2 3# Warning flags ===============================================================4function(cxx_add_warning_flags target enable_werror enable_pedantic)5  target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)6  if (MSVC)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)10  else()11    target_add_compile_flags_if_supported(${target} PRIVATE -Wall)12  endif()13  # TODO: Should -Wconversion be enabled?14  target_add_compile_flags_if_supported(${target} PRIVATE15      -Wextra16      -Wnewline-eof17      -Wshadow18      -Wwrite-strings19      -Wno-unused-parameter20      -Wno-long-long21      -Werror=return-type22      -Wextra-semi23      -Wundef24      -Wunused-template25      -Wformat-nonliteral26      -Wzero-length-array27      -Wdeprecated-redundant-constexpr-static-def28      -Wno-nullability-completeness29      )30 31  if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")32    target_add_compile_flags_if_supported(${target} PRIVATE33      -Wno-user-defined-literals34      -Wno-covered-switch-default35      -Wno-suggest-override36    )37    if (LIBCXX_TARGETING_CLANG_CL)38      target_add_compile_flags_if_supported(${target} PRIVATE39        -Wno-c++98-compat40        -Wno-c++98-compat-pedantic41        -Wno-c++11-compat42        -Wno-undef43        -Wno-reserved-id-macro44        -Wno-gnu-include-next45        -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings46        -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences.47        -Wno-deprecated-dynamic-exception-spec # For auto_ptr48        -Wno-sign-conversion49        -Wno-old-style-cast50        -Wno-deprecated # FIXME: Remove this and fix all occurrences.51        -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang?52        -Wno-double-promotion # FIXME: remove me53      )54    endif()55 56  elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")57 58    target_add_compile_flags_if_supported(${target} PRIVATE59      -Wstrict-aliasing=260      -Wstrict-overflow=461      -Wno-attributes62      -Wno-literal-suffix63      -Wno-c++14-compat64      -Wno-noexcept-type65      -Wno-suggest-override66      -Wno-alloc-size-larger-than67      -Wno-deprecated-declarations68      -Wno-dangling-reference69      -Wno-strict-overflow70      -Wno-maybe-uninitialized71      -Wno-strict-aliasing72      )73 74  endif()75  if (${enable_werror})76    target_add_compile_flags_if_supported(${target} PRIVATE -Werror)77    target_add_compile_flags_if_supported(${target} PRIVATE -WX)78  else()79    # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is80    # added elsewhere.81    target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error)82  endif()83  if (${enable_pedantic})84    target_add_compile_flags_if_supported(${target} PRIVATE -pedantic)85  endif()86endfunction()87