| 1 |
# |
| 2 |
# add_c_compiler_flag("-Werror" SUPPORTED_CFLAGS) |
| 3 |
# |
| 4 |
# Copyright (c) 2018 Andreas Schneider <[email protected]> |
| 5 |
# |
| 6 |
# Redistribution and use is allowed according to the terms of the BSD license. |
| 7 |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
| 8 |
|
| 9 |
include(CheckCCompilerFlag) |
| 10 |
|
| 11 |
macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE) |
| 12 |
string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME) |
| 13 |
string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") |
| 14 |
string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") |
| 15 |
|
| 16 |
check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG) |
| 17 |
if (WITH_${_COMPILER_FLAG_NAME}_FLAG) |
| 18 |
#string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ") |
| 19 |
list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG}) |
| 20 |
endif() |
| 21 |
endmacro() |