================
@@ -386,6 +386,44 @@ macro(add_flag_if_supported flag name)
append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
endmacro()
+# LLVM's diagnostic policy is collected in LLVM_WARNING_OPTIONS_C/CXX instead
of
+# CMAKE_<LANG>_FLAGS, which every target in the build tree would inherit. The
+# lists are applied to LLVM-owned targets by llvm_apply_warning_options().
+#
+# llvm_add_warning_options(<C|CXX|ALL> <option>...)
+#
+# An option that is already present is moved to the end, because
+# target_compile_options() keeps only the first of duplicates while the last of
+# conflicting options (-Wno-foo ... -Wfoo) wins on the command line.
+macro(llvm_add_warning_options lang)
+ if (NOT "${lang}" MATCHES "^(C|CXX|ALL)$")
+ message(FATAL_ERROR "llvm_add_warning_options: language must be C, CXX or
ALL, not '${lang}'")
+ endif()
----------------
petrhosek wrote:
This doesn't cover Fortran. Rather than hardcoding the languages, CMake's own
modules use:
```
get_property (_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if (NOT _lang IN_LIST _supported_languages)
message (SEND_ERROR "llvm_add_warning_options: ${_lang}: needs to be enabled
before use.")
return()
endif()
```
I'm also not sure about the `ALL` option, that might have unintended
consequences in case we add more supported languages later. I'd rather that the
invoker were explicit, which is again what the CMake's own modules do.
https://github.com/llvm/llvm-project/pull/244464
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits