From bad556ae299f9e463be7bc6f5d82292eb61fd0cc Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 30 May 2023 10:39:42 +0100 Subject: [PATCH] cmake: Fix checking compiler flags like `-Wno-some-warning` --- cmake/TryAppendCFlags.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/TryAppendCFlags.cmake b/cmake/TryAppendCFlags.cmake index 1d81a9317a..633d99b62f 100644 --- a/cmake/TryAppendCFlags.cmake +++ b/cmake/TryAppendCFlags.cmake @@ -10,7 +10,14 @@ function(secp256k1_check_c_flags_internal flags output) # This avoids running a linker. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - check_c_compiler_flag("${flags}" ${result}) + + # Some compilers (GCC) produce no diagnostic for -Wno-some-warning, + # if "some-warning" is unknown to the compiler and no other diagnostics + # are being produced. Therefore, test the -Wsome-warning case instead + # of the -Wno-some-warning one. + string(REPLACE "-Wno-" "-W" non_negated_flags "${flags}") + + check_c_compiler_flag("${non_negated_flags}" ${result}) set(${output} ${${result}} PARENT_SCOPE) endfunction()