You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.4 KiB

11 years ago
  1. # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; version 2 of the License.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. # Common warning flags for GCC, G++, Clang and Clang++
  16. SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self")
  17. MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang
  18. IF(HAVE_WVLA)
  19. SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla")
  20. ENDIF()
  21. # Common warning flags for GCC and Clang
  22. SET(MY_C_WARNING_FLAGS
  23. "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement")
  24. # Common warning flags for G++ and Clang++
  25. SET(MY_CXX_WARNING_FLAGS
  26. "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter")
  27. # Extra warning flags for Clang++
  28. IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  29. SET(MY_CXX_WARNING_FLAGS
  30. "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field")
  31. ENDIF()
  32. # Turn on Werror (warning => error) when using maintainer mode.
  33. IF(FALSE AND MYSQL_MAINTAINER_MODE MATCHES "ON")
  34. SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror")
  35. SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror")
  36. ENDIF()
  37. # Set warning flags for GCC/Clang
  38. IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
  39. SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}")
  40. ENDIF()
  41. # Set warning flags for G++/Clang++
  42. IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  43. SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}")
  44. ENDIF()
  45. IF(MYSQL_MAINTAINER_MODE MATCHES "ON")
  46. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}")
  47. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}")
  48. ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
  49. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}")
  50. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}")
  51. ENDIF()