diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2014-10-13 09:52:28 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2014-10-13 09:52:28 +0200 |
commit | 8b64f825058a2439903e9420552641ca6105d9d6 (patch) | |
tree | 5e4595b95c1636b3a7f3d889de96da08676d4b19 | |
parent | a3cc647dbdbdeb0f2e9c9ac55ffe062c659d82dc (diff) | |
download | mariadb-git-8b64f825058a2439903e9420552641ca6105d9d6.tar.gz |
Bug#17633291: SET PROPER COMPILE OPTIONS FOR CLANG
Bug#17959689: MAKE GCC AND CLANG GIVE CONSISTENT COMPILATION WARNINGS
Bug#18313717: ENABLE -WERROR IN MAINTANER MODE WHEN COMPILING WITH CLANG
Bug#18510941: REMOVE CMAKE WORKAROUNDS FOR OLDER VERSIONS OF OS X/XCODE
Backport from mysql-5.6 to mysql-5.5
-rw-r--r-- | CMakeLists.txt | 92 | ||||
-rw-r--r-- | client/CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/build_configurations/mysql_release.cmake | 19 | ||||
-rw-r--r-- | cmake/compile_flags.cmake | 44 | ||||
-rw-r--r-- | cmake/maintainer.cmake | 67 | ||||
-rw-r--r-- | cmake/os/Darwin.cmake | 21 | ||||
-rw-r--r-- | configure.cmake | 9 | ||||
-rw-r--r-- | libmysqld/CMakeLists.txt | 8 | ||||
-rw-r--r-- | libmysqld/examples/CMakeLists.txt | 6 | ||||
-rw-r--r-- | plugin/auth/CMakeLists.txt | 4 | ||||
-rw-r--r-- | scripts/CMakeLists.txt | 12 | ||||
-rw-r--r-- | sql/CMakeLists.txt | 8 | ||||
-rw-r--r-- | storage/innobase/CMakeLists.txt | 8 |
13 files changed, 187 insertions, 117 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f43473f76a5..8ce5f4734c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,12 @@ ENDIF() # We use the LOCATION target property (CMP0026) # and get_target_property() for non-existent targets (CMP0045) +# and INSTALL_NAME_DIR (CMP0042) IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR CMAKE_VERSION VERSION_GREATER "3.0.0") CMAKE_POLICY(SET CMP0026 OLD) CMAKE_POLICY(SET CMP0045 OLD) + CMAKE_POLICY(SET CMP0042 OLD) ENDIF() MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") @@ -73,11 +75,9 @@ ENDIF() SET(BUILDTYPE_DOCSTRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") - + IF(WITH_DEBUG) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE) - SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL - "MySQL maintainer-specific development environment") IF(UNIX AND NOT APPLE) # Compiling with PIC speeds up embedded build, on PIC sensitive systems # Predefine it to ON, in case user chooses to build embedded. @@ -107,6 +107,15 @@ ELSE() ENDIF() PROJECT(${MYSQL_PROJECT_NAME}) +# Maintainer mode is default on only for Linux debug builds using GCC/G++ +IF(CMAKE_BUILD_TYPE MATCHES "Debug" OR WITH_DEBUG) + IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND + CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX) + SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL + "MySQL maintainer-specific development environment") + ENDIF() +ENDIF() + IF(BUILD_CONFIG) INCLUDE( ${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake) @@ -130,38 +139,12 @@ FOREACH(_base ENDFOREACH() - # Following autotools tradition, add preprocessor definitions # specified in environment variable CPPFLAGS IF(DEFINED ENV{CPPFLAGS}) ADD_DEFINITIONS($ENV{CPPFLAGS}) ENDIF() -# -# Control aspects of the development environment which are -# specific to MySQL maintainers and developers. -# -INCLUDE(maintainer) - -OPTION(MYSQL_MAINTAINER_MODE - "MySQL maintainer-specific development environment" OFF) - -# Whether the maintainer mode compiler options should be enabled. -IF(MYSQL_MAINTAINER_MODE) - IF(CMAKE_C_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_C_OPTIONS() - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS() - ENDIF() - IF(CMAKE_C_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS() - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS() - ENDIF() -ENDIF() - # Add macros INCLUDE(character_sets) INCLUDE(zlib) @@ -192,7 +175,6 @@ OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) - include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) # We need some extra FAIL_REGEX patterns @@ -373,13 +355,13 @@ MYSQL_CHECK_READLINE() # not run with the warning options as to not perturb fragile checks # (i.e. do not make warnings into errors). # -IF(MYSQL_MAINTAINER_MODE) - # 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}") - MESSAGE(STATUS "C++ warning options: ${MY_MAINTAINER_CXX_WARNINGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") -ENDIF() +# Why doesn't these flags affect the entire build? +# Because things may already have been included with ADD_SUBDIRECTORY +# +OPTION(MYSQL_MAINTAINER_MODE + "MySQL maintainer-specific development environment" OFF) + +INCLUDE(maintainer) IF(NOT WITHOUT_SERVER) SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "") @@ -395,7 +377,6 @@ ADD_SUBDIRECTORY(regex) ADD_SUBDIRECTORY(mysys) ADD_SUBDIRECTORY(libmysql) - IF(WITH_UNIT_TESTS) ENABLE_TESTING() ENDIF() @@ -487,7 +468,6 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM") ) INSTALL(FILES README DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme) INSTALL(FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN DESTINATION ${INSTALL_DOCDIR}) - IF(UNIX) INSTALL(FILES Docs/INSTALL-BINARY DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme) ENDIF() @@ -507,3 +487,37 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM") ENDIF() INCLUDE(CPack) + +# C compiler flags consist of: +# CPPFLAGS Taken from environment, see above. +# ADD_DEFINITIONS In each individual CMakeLists.txt +# CMAKE_C_FLAGS From command line. +# We extend these in maintainer.cmake +# ENV{CFLAGS} From environment, but environment is ignored if +# CMAKE_C_FLAGS is also given on command line +# CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} +# We extend these in compiler_options.cmake +# +# Note that CMakeCache.txt contains cmake builtins for these variables, +# *not* the values that will actually be used: + +IF(CMAKE_GENERATOR MATCHES "Makefiles") + MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +ENDIF() +GET_PROPERTY(cwd_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS) +MESSAGE(STATUS "COMPILE_DEFINITIONS: ${cwd_definitions}") +MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") +MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +IF(CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Makefiles") + STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKEBT) + MESSAGE(STATUS "CMAKE_C_FLAGS_${CMAKEBT}: ${CMAKE_C_FLAGS_${CMAKEBT}}") + MESSAGE(STATUS "CMAKE_CXX_FLAGS_${CMAKEBT}: ${CMAKE_CXX_FLAGS_${CMAKEBT}}") +ENDIF() +IF(NOT CMAKE_GENERATOR MATCHES "Makefiles") + MESSAGE(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}") + MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") + MESSAGE(STATUS + "CMAKE_C_FLAGS_RELWITHDEBINFO: ${CMAKE_C_FLAGS_RELWITHDEBINFO}") + MESSAGE(STATUS + "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") +ENDIF() diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 4d8fab3f4b9..0d67cf2e0d4 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -35,6 +35,12 @@ ENDIF(UNIX) MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test) SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS") +# mysqltest has unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) +IF(HAVE_WERROR_FLAG) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(mysqltest.cc COMPILE_FLAGS "-Wno-error") +ENDIF() TARGET_LINK_LIBRARIES(mysqltest mysqlclient regex) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index e2b815ef830..b0d3de10299 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -189,15 +189,16 @@ IF(UNIX) ENDIF() ENDIF() - # OSX flags - IF(APPLE) - SET(COMMON_C_FLAGS "-g -fno-common -fno-strict-aliasing") - # XXX: why are we using -felide-constructors on OSX? - SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors -fno-strict-aliasing") - SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os ${COMMON_C_FLAGS}") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os ${COMMON_CXX_FLAGS}") + # Default Clang flags + IF(CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing") + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}") + ENDIF() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}") ENDIF() # Solaris flags diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake new file mode 100644 index 00000000000..5e872f981b0 --- /dev/null +++ b/cmake/compile_flags.cmake @@ -0,0 +1,44 @@ +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +## ADD_COMPILE_FLAGS(<source files> COMPILE_FLAGS <flags>) +MACRO(ADD_COMPILE_FLAGS) + SET(FILES "") + SET(FLAGS "") + SET(COMPILE_FLAGS) + FOREACH(ARG ${ARGV}) + IF(ARG STREQUAL "COMPILE_FLAGS") + SET(COMPILE_FLAGS "COMPILE_FLAGS") + ELSEIF(COMPILE_FLAGS) + LIST(APPEND FLAGS ${ARG}) + ELSE() + LIST(APPEND FILES ${ARG}) + ENDIF() + ENDFOREACH() + FOREACH(FILE ${FILES}) + FOREACH(FLAG ${FLAGS}) + GET_SOURCE_FILE_PROPERTY(PROP ${FILE} COMPILE_FLAGS) + IF(NOT PROP) + SET(PROP ${FLAG}) + ELSE() + SET(PROP "${PROP} ${FLAG}") + ENDIF() + SET_SOURCE_FILES_PROPERTIES( + ${FILE} PROPERTIES COMPILE_FLAGS "${PROP}" + ) + ENDFOREACH() + ENDFOREACH() +ENDMACRO() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index a91905a281b..c537d00260f 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,42 +13,39 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -INCLUDE(CheckCCompilerFlag) +# Common warning flags for GCC, G++, Clang and Clang++ +SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security") +MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang +IF(HAVE_WVLA) + SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") +ENDIF() -# Setup GCC (GNU C compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS) - SET(MY_MAINTAINER_WARNINGS - "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror") - 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 - "${MY_MAINTAINER_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}" - CACHE STRING "C warning options used in maintainer builds.") - # Do not make warnings in checks into errors. - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error") -ENDMACRO() +# Common warning flags for GCC and Clang +SET(MY_C_WARNING_FLAGS + "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") -# Setup G++ (GNU C++ compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS) - SET(MY_MAINTAINER_CXX_WARNINGS - "${MY_MAINTAINER_WARNINGS} -Wno-unused-parameter -Woverloaded-virtual" - CACHE STRING "C++ warning options used in maintainer builds.") -ENDMACRO() +# Common warning flags for G++ and Clang++ +SET(MY_CXX_WARNING_FLAGS + "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter") -# Setup ICC (Intel C Compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS) - SET(MY_MAINTAINER_WARNINGS "-Wcheck") - SET(MY_MAINTAINER_C_WARNINGS "${MY_MAINTAINER_WARNINGS}" - CACHE STRING "C warning options used in maintainer builds.") -ENDMACRO() +# Extra warning flags for Clang++ +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(MY_CXX_WARNING_FLAGS + "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field") +ENDIF() -# Setup ICPC (Intel C++ Compiler) warning options. -MACRO(SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS) - SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_WARNINGS}" - CACHE STRING "C++ warning options used in maintainer builds.") -ENDMACRO() +# Turn on Werror (warning => error) when using maintainer mode. +IF(MYSQL_MAINTAINER_MODE) + SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -Werror") + SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -Werror") + SET(COMPILE_FLAG_WERROR 1) +ENDIF() +# Set warning flags for GCC/Clang +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_WARNING_FLAGS}") +ENDIF() +# Set warning flags for G++/Clang++ +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_WARNING_FLAGS}") +ENDIF() diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake index 0d8bac106f0..4ac72070e8b 100644 --- a/cmake/os/Darwin.cmake +++ b/cmake/os/Darwin.cmake @@ -1,5 +1,4 @@ -# Copyright (c) 2010 Sun Microsystems, Inc. -# Use is subject to license terms. +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,21 +14,3 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This file includes OSX specific options and quirks, related to system checks - -# Workaround for CMake bug#9051 -# (CMake does not pass CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET when -# running TRY_COMPILE) - -IF(CMAKE_OSX_SYSROOT) - SET(ENV{CMAKE_OSX_SYSROOT} ${CMAKE_OSX_SYSROOT}) -ENDIF() -IF(CMAKE_OSX_SYSROOT) - SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET}) -ENDIF() - -IF(CMAKE_OSX_DEPLOYMENT_TARGET) - # Workaround linker problems on OSX 10.4 - IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5") - ADD_DEFINITIONS(-fno-common) - ENDIF() -ENDIF() diff --git a/configure.cmake b/configure.cmake index c3ac3a8222f..28974a84c49 100644 --- a/configure.cmake +++ b/configure.cmake @@ -53,15 +53,6 @@ IF(NOT SYSTEM_TYPE) ENDIF() -# Always enable -Wall for gnu C/C++ -IF(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter") -ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -ENDIF() - - IF(CMAKE_COMPILER_IS_GNUCXX) # MySQL "canonical" GCC flags. At least -fno-rtti flag affects # ABI and cannot be simply removed. diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index f31aa819ed5..abbf887e1e6 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -93,6 +93,14 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ) +# These files have unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) +IF(HAVE_WERROR_FLAG) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(../sql/filesort.cc COMPILE_FLAGS "-Wno-error") + ADD_COMPILE_FLAGS(../sql/opt_range.cc COMPILE_FLAGS "-Wno-error") +ENDIF() + ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES}) DTRACE_INSTRUMENT(sql_embedded) ADD_DEPENDENCIES(sql_embedded GenError GenServerSource) diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index c4055a56303..55b2079c320 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -33,6 +33,12 @@ IF(UNIX) ENDIF(UNIX) MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc) +# mysqltest has unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) +IF(HAVE_WERROR_FLAG) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(../../client/mysqltest.cc COMPILE_FLAGS "-Wno-error") +ENDIF() TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver) diff --git a/plugin/auth/CMakeLists.txt b/plugin/auth/CMakeLists.txt index 6a9c31f82ce..9a3682a5e96 100644 --- a/plugin/auth/CMakeLists.txt +++ b/plugin/auth/CMakeLists.txt @@ -28,7 +28,9 @@ MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c MODULE_ONLY) CHECK_CXX_SOURCE_COMPILES( -"#define _GNU_SOURCE +"#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include <sys/socket.h> int main() { struct ucred cred; diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 5e03acb654b..05bf8530a26 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -88,16 +88,20 @@ ENDIF() IF(CMAKE_GENERATOR MATCHES "Makefiles") # Strip maintainer mode options if necessary - STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}") - STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + STRING(REPLACE "${MY_C_WARNING_FLAGS}" "" CFLAGS + "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}") + STRING(REPLACE "${MY_CXX_WARNING_FLAGS}" "" CXXFLAGS + "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") FOREACH(ARCH ${CMAKE_OSX_ARCHITECTURES}) SET(CFLAGS "${CFLAGS} -arch ${ARCH}") SET(CXXFLAGS "${CXXFLAGS} -arch ${ARCH}") ENDFOREACH() ELSE() # Strip maintainer mode options if necessary - STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + STRING(REPLACE "${MY_C_WARNING_FLAGS}" "" CFLAGS + "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + STRING(REPLACE "${MY_CXX_WARNING_FLAGS}" "" CXXFLAGS + "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") ENDIF() IF(UNIX) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index c19ea9b17bd..030f183d5f7 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -80,6 +80,14 @@ SET (SQL_SOURCE ${GEN_SOURCES} ${MYSYS_LIBWRAP_SOURCE}) +# These files have unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) +IF(HAVE_WERROR_FLAG) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(filesort.cc COMPILE_FLAGS "-Wno-error") + ADD_COMPILE_FLAGS(opt_range.cc COMPILE_FLAGS "-Wno-error") +ENDIF() + MYSQL_ADD_PLUGIN(partition ha_partition.cc STORAGE_ENGINE DEFAULT STATIC_ONLY RECOMPILE_FOR_EMBEDDED) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 01034eede69..4f000434eb9 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -247,6 +247,14 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c ut/ut0bh.c) +# These files have unused result errors, so we skip Werror +CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR) +IF(HAVE_WERROR) + INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) + ADD_COMPILE_FLAGS(page/page0zip.c COMPILE_FLAGS "-Wno-error") + ADD_COMPILE_FLAGS(ut/ut0ut.c COMPILE_FLAGS "-Wno-error") +ENDIF() + IF(WITH_INNODB) # Legacy option SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) |