diff options
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/AddCFlagIfSupported.cmake | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cmake/Modules/AddCFlagIfSupported.cmake b/cmake/Modules/AddCFlagIfSupported.cmake index 67fc89510..1d6181cac 100644 --- a/cmake/Modules/AddCFlagIfSupported.cmake +++ b/cmake/Modules/AddCFlagIfSupported.cmake @@ -5,9 +5,21 @@ INCLUDE(CheckCCompilerFlag) +MACRO(ADD_C_FLAG _FLAG) + STRING(TOUPPER ${_FLAG} UPCASE) + STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) + CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) + + IF(IS_${UPCASE_PRETTY}_SUPPORTED) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}") + ELSE() + MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported") + ENDIF() +ENDMACRO() + MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG) STRING(TOUPPER ${_FLAG} UPCASE) - STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) + STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) IF(IS_${UPCASE_PRETTY}_SUPPORTED) |