Also fix one issue reported by the build.
Change-Id: I28af9eac2e9fb615903a82c8f4087602b72c134d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250509090936.18818-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31604.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -66,6 +66,13 @@ set(CMAKE_CXX_FLAGS_ASAN |
| 66 | 66 |
CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds." |
| 67 | 67 |
FORCE) |
| 68 | 68 |
|
| 69 |
+function(check_and_add_compiler_flag flag variable) |
|
| 70 |
+ check_c_compiler_flag(${flag} ${variable})
|
|
| 71 |
+ if (${variable})
|
|
| 72 |
+ add_compile_options(${flag})
|
|
| 73 |
+ endif() |
|
| 74 |
+endfunction() |
|
| 75 |
+ |
|
| 69 | 76 |
if (MSVC) |
| 70 | 77 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS) |
| 71 | 78 |
if (USE_WERROR) |
| ... | ... |
@@ -96,11 +103,9 @@ if (MSVC) |
| 96 | 96 |
endif() |
| 97 | 97 |
else () |
| 98 | 98 |
add_compile_options(-Wall -Wuninitialized) |
| 99 |
- check_c_compiler_flag(-Wno-stringop-truncation NoStringOpTruncation) |
|
| 100 |
- |
|
| 101 |
- if (${NoStringOpTruncation})
|
|
| 102 |
- add_compile_options(-Wno-stringop-truncation) |
|
| 103 |
- endif() |
|
| 99 |
+ check_and_add_compiler_flag(-Wno-stringop-truncation NoStringOpTruncation) |
|
| 100 |
+ check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes) |
|
| 101 |
+ check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition) |
|
| 104 | 102 |
# We are not ready for this |
| 105 | 103 |
#add_compile_options(-Wconversion -Wno-sign-conversion -Wsign-compare) |
| 106 | 104 |
if (USE_WERROR) |