Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Fix checking compiler flags like -Wno-some-warning #1332

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented May 30, 2023

Some compilers (GCC) produce no diagnostic for -Wno-unknown-warning unless other diagnostics are being produced:

$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 240557f..f976824 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,6 +220,7 @@ if(MSVC)
   add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
 else()
   # Keep the following commands ordered lexicographically.
+  try_append_c_flags(-Wno-unknown-warning)
   try_append_c_flags(-pedantic)
   try_append_c_flags(-Wall) # GCC >= 2.95 and probably many other compilers.
   try_append_c_flags(-Wcast-align) # GCC >= 2.95.
$ cmake -B build -DCMAKE_C_COMPILER=gcc 2>&1 | grep -i unknown
-- Performing Test C_SUPPORTS__WNO_UNKNOWN_WARNING
-- Performing Test C_SUPPORTS__WNO_UNKNOWN_WARNING - Success
Compile options ....................... -Wno-unknown-warning -pedantic -Wall -Wcast-align -Wcast-align=strict -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wundef

This PR fixes compiler flag check in CMake-based build system.

Let me know, if the same fix is desirable in Autotools-based build system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants