1# Copyright (c) 2010, 2018, 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, version 2.0, 5# as published by the Free Software Foundation. 6# 7# This program is also distributed with certain software (including 8# but not limited to OpenSSL) that is licensed under separate terms, 9# as designated in a particular file or component or in included license 10# documentation. The authors of MySQL hereby grant you an additional 11# permission to link the program and your derivative works with the 12# separately licensed software that they have included with MySQL. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License, version 2.0, for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program; if not, write to the Free Software 21# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 23# Common warning flags for GCC, G++, Clang and Clang++ 24SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security") 25MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang 26IF(HAVE_WVLA) 27 SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") 28ENDIF() 29 30# Common warning flags for GCC and Clang 31SET(MY_C_WARNING_FLAGS 32 "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") 33 34# Common warning flags for G++ and Clang++ 35SET(MY_CXX_WARNING_FLAGS 36 "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter") 37 38# Extra warning flags for Clang++ 39IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 40 SET(MY_CXX_WARNING_FLAGS 41 "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field") 42ENDIF() 43 44# Turn on Werror (warning => error) when using maintainer mode. 45IF(MYSQL_MAINTAINER_MODE) 46 SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -Werror") 47 SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -Werror") 48 SET(COMPILE_FLAG_WERROR 1) 49ENDIF() 50 51# Set warning flags for GCC/Clang 52IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") 53 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_WARNING_FLAGS}") 54ENDIF() 55# Set warning flags for G++/Clang++ 56IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 57 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_WARNING_FLAGS}") 58ENDIF() 59