File: AddCCompilerFlag.cmake

package info (click to toggle)
libssh 0.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,420 kB
  • sloc: ansic: 100,132; cpp: 421; sh: 186; makefile: 25; javascript: 20; python: 9
file content (21 lines) | stat: -rw-r--r-- 845 bytes parent folder | download | duplicates (31)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# add_c_compiler_flag("-Werror" SUPPORTED_CFLAGS)
#
# Copyright (c) 2018      Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

include(CheckCCompilerFlag)

macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE)
    string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME)
    string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")
    string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")

    check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG)
    if (WITH_${_COMPILER_FLAG_NAME}_FLAG)
        #string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ")
        list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG})
    endif()
endmacro()