diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-09-01 21:58:10 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-09-04 10:32:02 +0200 |
commit | e74f91dfd7986a63e73e72b8a1fbeaa2822d8f1e (patch) | |
tree | a23f27c30e40dd58c1a7c6eb2c1ce89ab6826a8b /cmake | |
parent | efbd4bb039060e9cc7a82467c36307367f4013ec (diff) | |
download | mariadb-git-e74f91dfd7986a63e73e72b8a1fbeaa2822d8f1e.tar.gz |
cmake: always use the same function to test for compiler flags
Fix all cmake tests (including plugin) to use
MY_CHECK_AND_SET_COMPILER_FLAG. And fix that function
to be compatible with cmake 3.0. This way flag checks
are correctly cached (even in cmake 3.0) and properly reused.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/check_compiler_flag.cmake | 14 | ||||
-rw-r--r-- | cmake/maintainer.cmake | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake index 4a029659f43..303d5d8d3c8 100644 --- a/cmake/check_compiler_flag.cmake +++ b/cmake/check_compiler_flag.cmake @@ -9,11 +9,13 @@ SET(fail_patterns FAIL_REGEX "unrecognized .*option" FAIL_REGEX "ignoring unknown option" FAIL_REGEX "warning:.*ignored" + FAIL_REGEX "warning:.*is valid for.*but not for" FAIL_REGEX "warning:.*redefined" FAIL_REGEX "[Ww]arning: [Oo]ption" ) -MACRO (MY_CHECK_C_COMPILER_FLAG flag result) +MACRO (MY_CHECK_C_COMPILER_FLAG flag) + STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_C_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result} @@ -21,7 +23,8 @@ MACRO (MY_CHECK_C_COMPILER_FLAG flag result) SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") ENDMACRO() -MACRO (MY_CHECK_CXX_COMPILER_FLAG flag result) +MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) + STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_CXX_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result} @@ -35,10 +38,11 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag) IF(WIN32) RETURN() ENDIF() - MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag}) - MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag}) + MY_CHECK_C_COMPILER_FLAG(${flag}) + MY_CHECK_CXX_COMPILER_FLAG(${flag}) + STRING(REGEX REPLACE "[-,= ]" "_" result "${flag}") FOREACH(lang C CXX) - IF (HAVE_${lang}_${flag}) + IF (HAVE_${lang}_${result}) IF(ARGN) FOREACH(type ${ARGN}) SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE) diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 5e9d0d3ad99..24547103b63 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -15,8 +15,8 @@ # Common warning flags for GCC, G++, Clang and Clang++ SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self") -MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang -IF(HAVE_WVLA) +MY_CHECK_C_COMPILER_FLAG("-Wvla") # Requires GCC 4.3+ or Clang +IF(HAVE_C__Wvla) SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") ENDIF() |