summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-02-06 02:38:01 +0100
committerSergei Golubchik <serg@mariadb.org>2018-02-06 12:53:01 +0100
commit0c25e58db6b045df92c209d396031cac5b528bbf (patch)
tree74e61993ee9b9616179df5dad8bac1c3fe8e7399
parent4418abb267583f34d24fab23835cb121a6ce14a2 (diff)
downloadmariadb-git-0c25e58db6b045df92c209d396031cac5b528bbf.tar.gz
correctly detect unsupported compiler flags
in gcc `-Wno-unsupported-something` will not be an error or even a warning, so cmake will think the flag is supported. But if there's any other warning during compilation, for any reason, unknown option will be a warning too. Or an error when -Werror, even if that "other warning" would not be an error on itself. So we need to detect whether `-Wno-unsupported-something` is *really* supported. Luckily, `-Wunsupported-something` will always fail with an error. So, whenever there's a need to detect if -Wno-something is supported, test -Wsomething instead.
-rw-r--r--cmake/check_compiler_flag.cmake14
1 files changed, 7 insertions, 7 deletions
diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake
index ef675959059..673361ab8fe 100644
--- a/cmake/check_compiler_flag.cmake
+++ b/cmake/check_compiler_flag.cmake
@@ -32,25 +32,25 @@ MACRO (MY_CHECK_CXX_COMPILER_FLAG flag)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO()
-FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag)
+FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag_to_set)
# At the moment this is gcc-only.
# Let's avoid expensive compiler tests on Windows:
IF(WIN32)
RETURN()
ENDIF()
- MY_CHECK_C_COMPILER_FLAG(${flag})
- MY_CHECK_CXX_COMPILER_FLAG(${flag})
- STRING(REGEX REPLACE "[-,= +]" "_" result "${flag}")
+ STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set})
+ MY_CHECK_C_COMPILER_FLAG(${flag_to_check})
+ MY_CHECK_CXX_COMPILER_FLAG(${flag_to_check})
+ STRING(REGEX REPLACE "[-,= +]" "_" result "${flag_to_check}")
FOREACH(lang C CXX)
IF (HAVE_${lang}_${result})
IF(ARGN)
FOREACH(type ${ARGN})
- SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE)
+ SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE)
ENDFOREACH()
ELSE()
- SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag}" PARENT_SCOPE)
+ SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag_to_set}" PARENT_SCOPE)
ENDIF()
ENDIF()
ENDFOREACH()
ENDFUNCTION()
-