diff options
| author | Ingo Müller <ingomueller@google.com> | 2024-03-06 14:15:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-06 14:15:17 +0100 |
| commit | 8406f8023dc08a1697acd2375e120670c0233a8a (patch) | |
| tree | 25cbd0591e287609d6c9158e30ae8f7e93e7526e /mlir/CMakeLists.txt | |
| parent | 099045a0456a77c38aed504d0b50d44c4d3df6ff (diff) | |
[mlir][cmake] Enable -Wundef. (#84011)
This is another follow-up of #83004, which fixed a bug due to some
macros not being defined in some situations. By raising warnings on
undefined macros, this kind of bug is less likely to be introduced.
Similar to #83004, the fix is probably adding an include to
`mlir-config.h` (and potentially defining the macro there).
Diffstat (limited to 'mlir/CMakeLists.txt')
| -rw-r--r-- | mlir/CMakeLists.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index e37cb465b919..5c4301af040b 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -70,6 +70,12 @@ endif() check_c_compiler_flag("-Werror=implicit-function-declaration" C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION) append_if(C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION "-Werror=implicit-function-declaration" CMAKE_C_FLAGS) +# Warn on undefined macros. This is often an indication that an include to +# `mlir-config.h` or similar is missing. +check_c_compiler_flag("-Wundef" C_SUPPORTS_WUNDEF) +append_if(C_SUPPORTS_WUNDEF "-Wundef" CMAKE_C_FLAGS) +append_if(C_SUPPORTS_WUNDEF "-Wundef" CMAKE_CXX_FLAGS) + # Forbid mismatch between declaration and definition for class vs struct. This is # harmless on Unix systems, but it'll be a ticking bomb for MSVC/Windows systems # where it creeps into the ABI. |
