warnings.cmake 885 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. # global additional warnings.
  4. if (MSVC)
  5. # warning level 4
  6. add_compile_options(/W4)
  7. else ()
  8. # refer to https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  9. add_compile_options(
  10. -Wall -Wextra -Wformat -Wformat-security
  11. $<$<COMPILE_LANGUAGE:C>:-Wshadow>
  12. )
  13. # -pedantic causes warnings like "ISO C forbids initialization between function pointer and ‘void *’" which
  14. # is widely used in the codebase.
  15. #
  16. # -fpermissive causes warnings like "-fpermissive is valid for C++/ObjC++ but not for C"
  17. #
  18. add_compile_options (
  19. $<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>
  20. $<$<COMPILE_LANGUAGE:C>:-Wimplicit-function-declaration>
  21. )
  22. # waivers
  23. add_compile_options (
  24. -Wno-unused
  25. -Wno-unused-parameter
  26. )
  27. endif ()