#At file:///home/mysql_src/bzrrepos_new/5.5-bugteam-57933/ based on revid:georgi.kodinov@stripped
3122 Guilhem Bichot 2010-11-03
BUG#57933 "add -Wdeclaration-after-statement to gcc builds"
implementation for autotools and cmake.
@ CMakeLists.txt
Detect compiler flag -Wdeclaration-after-statement and use it if exists.
The detection cannot happen before "INCLUDE(configure.cmake)" because
configure.cmake is what does
"INCLUDE (CheckCSourceCompiles)"
which is needed for CHECK_C_COMPILER_FLAG.
That's a first reason to move the first maintainer-related block down.
A second reason is that I could not understand why we set some
variables (MY_MAINTAINER*) early in a first block; I believe they don't influence
anything until we use them to set CMAKE_C_FLAGS in the second block.
So I move the first block into the second.
I don't know whether adding -Wno-error to CMAKE_REQUIRED_FLAGS
is still needed, for me it compiles even without it, but I
left it.
@ config/ac-macros/maintainer.m4
Add flag to autotools build.
modified:
CMakeLists.txt
config/ac-macros/maintainer.m4
=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt 2010-10-21 12:12:23 +0000
+++ b/CMakeLists.txt 2010-11-03 16:26:00 +0000
@@ -111,28 +111,6 @@ IF(DEFINED ENV{CPPFLAGS})
ADD_DEFINITIONS($ENV{CPPFLAGS})
ENDIF()
-#
-# Control aspects of the development environment which are
-# specific to MySQL maintainers and developers.
-#
-OPTION(MYSQL_MAINTAINER_MODE "MySQL maintainer-specific development environment" OFF)
-# Whether the maintainer mode should be enabled.
-IF(MYSQL_MAINTAINER_MODE)
- IF(CMAKE_COMPILER_IS_GNUCC)
- SET(MY_MAINTAINER_C_WARNINGS
- "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
- CACHE STRING "C warning options used in maintainer builds.")
- ENDIF()
- IF(CMAKE_COMPILER_IS_GNUCXX)
- SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_C_WARNINGS} -Wno-unused-parameter"
- CACHE STRING "C++ warning options used in maintainer builds.")
- ENDIF()
- # Do not make warnings in checks into errors.
- IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
- SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
- ENDIF()
-ENDIF()
-
# Add macros
INCLUDE(character_sets)
INCLUDE(zlib)
@@ -247,11 +225,36 @@ MYSQL_CHECK_SSL()
MYSQL_CHECK_READLINE()
#
-# Setup maintainer mode options by the end. Platform checks are
-# not run with the warning options as to not perturb fragile checks
-# (i.e. do not make warnings into errors).
+# Control aspects of the development environment which are
+# specific to MySQL maintainers and developers.
+# We set compiler flags only here towards the end: earlier
+# platform checks are not run with the warning options to
+# not perturb fragile checks (i.e. do not make warnings into errors).
#
+OPTION(MYSQL_MAINTAINER_MODE "MySQL maintainer-specific development environment" OFF)
+# Whether the maintainer mode should be enabled.
IF(MYSQL_MAINTAINER_MODE)
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" HAVE_DECLARATION_AFTER_STATEMENT)
+ IF(HAVE_DECLARATION_AFTER_STATEMENT)
+ SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT "-Wdeclaration-after-statement")
+ ENDIF()
+ SET(MY_MAINTAINER_C_WARNINGS
+ "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
+ ENDIF()
+ IF(CMAKE_COMPILER_IS_GNUCXX)
+ SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_C_WARNINGS} -Wno-unused-parameter"
+ CACHE STRING "C++ warning options used in maintainer builds.")
+ ENDIF()
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ SET(MY_MAINTAINER_C_WARNINGS
+ "${MY_MAINTAINER_C_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
+ CACHE STRING "C warning options used in maintainer builds.")
+ ENDIF()
+ # Do not make warnings in checks into errors.
+ IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
+ ENDIF()
# Set compiler flags required under maintainer mode.
MESSAGE(STATUS "C warning options: ${MY_MAINTAINER_C_WARNINGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}")
=== modified file 'config/ac-macros/maintainer.m4'
--- a/config/ac-macros/maintainer.m4 2010-10-18 16:27:10 +0000
+++ b/config/ac-macros/maintainer.m4 2010-11-03 16:26:00 +0000
@@ -19,6 +19,7 @@ AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS],
AS_IF([test "$GCC" = "yes"], [
C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter"
+ C_WARNINGS="${C_WARNINGS} -Wdeclaration-after-statement"
])
# Test whether the warning options work.
Attachment: [text/bzr-bundle] bzr/guilhem@mysql.com-20101103162600-cltpq5dmzfc0tqte.bundle