diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-09-14 20:59:11 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-09-14 20:59:11 +0200 |
commit | 51ebb9166df1dee7831d9ab25aaa8e70bd65aa16 (patch) | |
tree | 106b3918e1a0607b7c01ac3abdb2b2d6158fb45a /CMakeLists.txt | |
parent | 95d3f0607556e66666b3974486b061fc4372ede0 (diff) | |
download | libquotient-51ebb9166df1dee7831d9ab25aaa8e70bd65aa16.tar.gz libquotient-51ebb9166df1dee7831d9ab25aaa8e70bd65aa16.zip |
CMakeLists: add flags more carefully for non-Windows
Previous logic wasn't quite accurate with detection of existing flags
in CMAKE_CXX_FLAGS - the new code doesn't add a flag if the negating
flag is already there. This required separate treatment of positive
and negative (-Wno-*) flags.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fbb4ef1..4781ed52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,14 +37,20 @@ if (MSVC) /wd4464 /wd4505 /wd4514 /wd4571 /wd4619 /wd4623 /wd4625 /wd4626 /wd4706 /wd4710 /wd4774 /wd4820 /wd4946 /wd5026 /wd5027) else() - foreach (FLAG Wall Wpedantic Wextra Werror=return-type Wno-unused-parameter - Wno-gnu-zero-variadic-macro-arguments Wno-subobject-linkage) - CHECK_CXX_COMPILER_FLAG("-${FLAG}" COMPILER_${FLAG}_SUPPORTED) - if ( COMPILER_${FLAG}_SUPPORTED AND - NOT CMAKE_CXX_FLAGS MATCHES "(^| )-?${FLAG}($| )") - add_compile_options(-${FLAG}) + foreach (FLAG all pedantic extra error=return-type) # Switch these on + CHECK_CXX_COMPILER_FLAG("-W${FLAG}" W${FLAG}_SUPPORTED) + if (W${FLAG}_SUPPORTED AND + NOT CMAKE_CXX_FLAGS MATCHES "W(no-)?${FLAG}($| )") + add_compile_options(-W${FLAG}) endif () endforeach () + foreach (FLAG unused-parameter gnu-zero-variadic-macro-arguments + subobject-linkage) # Switch these off + CHECK_CXX_COMPILER_FLAG("-Wno-${FLAG}" Wno-${FLAG}_SUPPORTED) + if (Wno-${FLAG}_SUPPORTED AND + NOT CMAKE_CXX_FLAGS MATCHES "W(no-)?${FLAG}($| )") + add_compile_options(-Wno-${FLAG}) + endforeach () endif() if (WIN32) |