1# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 2# Copyright (c) 2011, 2021, MariaDB 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; version 2 of the License. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software 15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA 16 17IF(MSVC OR MYSQL_MAINTAINER_MODE STREQUAL "NO") 18 # Windows support is in cmake/os/Windows.cmake, not here 19 RETURN() 20ENDIF() 21 22# Common warning flags for GCC, G++, Clang and Clang++ 23SET(MY_WARNING_FLAGS 24 -Wall 25 -Wdeclaration-after-statement 26 -Wextra 27 -Wformat-security 28 -Wno-format-truncation 29 -Wno-init-self 30 -Wno-nonnull-compare 31 -Wno-null-conversion 32 -Wno-unused-parameter 33 -Wno-unused-private-field 34 -Woverloaded-virtual 35 -Wnon-virtual-dtor 36 -Wvla 37 -Wwrite-strings 38 ) 39 40FOREACH(F ${MY_WARNING_FLAGS}) 41 MY_CHECK_AND_SET_COMPILER_FLAG(${F} DEBUG RELWITHDEBINFO) 42ENDFOREACH() 43 44SET(MY_ERROR_FLAGS -Werror) 45 46IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") 47 SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=maybe-uninitialized) 48ENDIF() 49 50IF(MYSQL_MAINTAINER_MODE MATCHES "OFF|WARN") 51 RETURN() 52ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") 53 SET(WHERE DEBUG) 54ENDIF() 55 56FOREACH(F ${MY_ERROR_FLAGS}) 57 MY_CHECK_AND_SET_COMPILER_FLAG(${F} ${WHERE}) 58ENDFOREACH() 59 60IF(CMAKE_C_COMPILER_ID MATCHES "GNU") 61 STRING(REPLACE " -E " " -E -dDI " CMAKE_C_CREATE_PREPROCESSED_SOURCE ${CMAKE_C_CREATE_PREPROCESSED_SOURCE}) 62ENDIF() 63IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 64 STRING(REPLACE " -E " " -E -dDI " CMAKE_CXX_CREATE_PREPROCESSED_SOURCE ${CMAKE_CXX_CREATE_PREPROCESSED_SOURCE}) 65ENDIF() 66