2023-09-27 18:37:09 +00:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
|
2023-12-06 23:21:38 +00:00
|
|
|
function(rustsecp256k1_v0_9_1_check_c_flags_internal flags output)
|
2023-09-27 18:37:09 +00:00
|
|
|
string(MAKE_C_IDENTIFIER "${flags}" result)
|
|
|
|
string(TOUPPER "${result}" result)
|
|
|
|
set(result "C_SUPPORTS_${result}")
|
|
|
|
if(NOT MSVC)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-Werror")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# This avoids running a linker.
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
check_c_compiler_flag("${flags}" ${result})
|
|
|
|
|
|
|
|
set(${output} ${${result}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Append flags to the COMPILE_OPTIONS directory property if CC accepts them.
|
|
|
|
macro(try_append_c_flags)
|
2023-12-06 23:21:38 +00:00
|
|
|
rustsecp256k1_v0_9_1_check_c_flags_internal("${ARGV}" result)
|
2023-09-27 18:37:09 +00:00
|
|
|
if(result)
|
|
|
|
add_compile_options(${ARGV})
|
|
|
|
endif()
|
|
|
|
endmacro()
|