File: TryAppendCFlags.cmake

package info (click to toggle)
libsecp256k1 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,408 kB
  • sloc: ansic: 45,273; python: 772; asm: 736; makefile: 285; sh: 208
file content (24 lines) | stat: -rw-r--r-- 685 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
include(CheckCCompilerFlag)

function(secp256k1_check_c_flags_internal flags output)
  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)
  secp256k1_check_c_flags_internal("${ARGV}" result)
  if(result)
    add_compile_options(${ARGV})
  endif()
endmacro()