Skip to content

Commit bad556a

Browse files
committed
cmake: Fix checking compiler flags like -Wno-some-warning
1 parent a526937 commit bad556a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmake/TryAppendCFlags.cmake

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ function(secp256k1_check_c_flags_internal flags output)
1010

1111
# This avoids running a linker.
1212
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
13-
check_c_compiler_flag("${flags}" ${result})
13+
14+
# Some compilers (GCC) produce no diagnostic for -Wno-some-warning,
15+
# if "some-warning" is unknown to the compiler and no other diagnostics
16+
# are being produced. Therefore, test the -Wsome-warning case instead
17+
# of the -Wno-some-warning one.
18+
string(REPLACE "-Wno-" "-W" non_negated_flags "${flags}")
19+
20+
check_c_compiler_flag("${non_negated_flags}" ${result})
1421

1522
set(${output} ${${result}} PARENT_SCOPE)
1623
endfunction()

0 commit comments

Comments
 (0)