Merge pull request #4924 from lhchavez/werror Make ENABLE_WERROR actually work
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/cmake/Modules/AddCFlagIfSupported.cmake b/cmake/Modules/AddCFlagIfSupported.cmake
index 1d6181c..b7aaa79 100644
--- a/cmake/Modules/AddCFlagIfSupported.cmake
+++ b/cmake/Modules/AddCFlagIfSupported.cmake
@@ -7,7 +7,8 @@ INCLUDE(CheckCCompilerFlag)
MACRO(ADD_C_FLAG _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
@@ -19,7 +20,8 @@ ENDMACRO()
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
- STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
+ STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/Modules/EnableWarnings.cmake
index e7d7d39..72e1523 100644
--- a/cmake/Modules/EnableWarnings.cmake
+++ b/cmake/Modules/EnableWarnings.cmake
@@ -1,14 +1,11 @@
MACRO(ENABLE_WARNINGS flag)
- IF(ENABLE_WERROR)
- ADD_C_FLAG_IF_SUPPORTED(-Werror=${flag})
- ELSE()
- ADD_C_FLAG_IF_SUPPORTED(-W${flag})
- ENDIF()
+ ADD_C_FLAG_IF_SUPPORTED(-W${flag})
ENDMACRO()
MACRO(DISABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
- IF(ENABLE_WERROR)
- ADD_C_FLAG_IF_SUPPORTED(-Wno-error=${flag})
- ENDIF()
ENDMACRO()
+
+IF(ENABLE_WERROR)
+ ADD_C_FLAG_IF_SUPPORTED(-Werror)
+ENDIF()