cmake: always use the same function to test for compiler flags

Fix all cmake tests (including plugin) to use
MY_CHECK_AND_SET_COMPILER_FLAG. And fix that function
to be compatible with cmake 3.0. This way flag checks
are correctly cached (even in cmake 3.0) and properly reused.
This commit is contained in:
Sergei Golubchik 2015-09-01 21:58:10 +02:00
parent efbd4bb039
commit e74f91dfd7
9 changed files with 73 additions and 190 deletions

View file

@ -9,11 +9,13 @@ SET(fail_patterns
FAIL_REGEX "unrecognized .*option" FAIL_REGEX "unrecognized .*option"
FAIL_REGEX "ignoring unknown option" FAIL_REGEX "ignoring unknown option"
FAIL_REGEX "warning:.*ignored" FAIL_REGEX "warning:.*ignored"
FAIL_REGEX "warning:.*is valid for.*but not for"
FAIL_REGEX "warning:.*redefined" FAIL_REGEX "warning:.*redefined"
FAIL_REGEX "[Ww]arning: [Oo]ption" FAIL_REGEX "[Ww]arning: [Oo]ption"
) )
MACRO (MY_CHECK_C_COMPILER_FLAG flag result) MACRO (MY_CHECK_C_COMPILER_FLAG flag)
STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_C_${flag}")
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result} CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result}
@ -21,7 +23,8 @@ MACRO (MY_CHECK_C_COMPILER_FLAG flag result)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO() ENDMACRO()
MACRO (MY_CHECK_CXX_COMPILER_FLAG flag result) MACRO (MY_CHECK_CXX_COMPILER_FLAG flag)
STRING(REGEX REPLACE "[-,= ]" "_" result "HAVE_CXX_${flag}")
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result} CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result}
@ -35,10 +38,11 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag)
IF(WIN32) IF(WIN32)
RETURN() RETURN()
ENDIF() ENDIF()
MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag}) MY_CHECK_C_COMPILER_FLAG(${flag})
MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag}) MY_CHECK_CXX_COMPILER_FLAG(${flag})
STRING(REGEX REPLACE "[-,= ]" "_" result "${flag}")
FOREACH(lang C CXX) FOREACH(lang C CXX)
IF (HAVE_${lang}_${flag}) IF (HAVE_${lang}_${result})
IF(ARGN) IF(ARGN)
FOREACH(type ${ARGN}) FOREACH(type ${ARGN})
SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE) SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE)

View file

@ -15,8 +15,8 @@
# Common warning flags for GCC, G++, Clang and Clang++ # Common warning flags for GCC, G++, Clang and Clang++
SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self") SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security -Wno-init-self")
MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang MY_CHECK_C_COMPILER_FLAG("-Wvla") # Requires GCC 4.3+ or Clang
IF(HAVE_WVLA) IF(HAVE_C__Wvla)
SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla")
ENDIF() ENDIF()

View file

@ -274,8 +274,8 @@ ENDIF()
FIND_PACKAGE (Threads) FIND_PACKAGE (Threads)
FUNCTION(MY_CHECK_PTHREAD_ONCE_INIT) FUNCTION(MY_CHECK_PTHREAD_ONCE_INIT)
CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) MY_CHECK_C_COMPILER_FLAG("-Werror")
IF(NOT HAVE_WERROR_FLAG) IF(NOT HAVE_C__Werror)
RETURN() RETURN()
ENDIF() ENDIF()
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")

View file

@ -132,31 +132,6 @@ include(${MRN_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake)
set(MRN_C_COMPILE_FLAGS "") set(MRN_C_COMPILE_FLAGS "")
set(MRN_CXX_COMPILE_FLAGS "") set(MRN_CXX_COMPILE_FLAGS "")
macro(mrn_check_cflag flag)
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CFLAG${temporary_variable_name}")
check_c_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} ${flag}")
endif()
endmacro()
macro(mrn_check_cxxflag flag)
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CXXFLAG${temporary_variable_name}")
check_cxx_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} ${flag}")
endif()
endmacro()
macro(mrn_build_flag flag)
mrn_check_cflag(${flag})
mrn_check_cxxflag(${flag})
endmacro()
if(MRN_BUNDLED) if(MRN_BUNDLED)
set(MRN_RELATIVE_DIR_PREFIX "${MRN_SOURCE_DIR}/") set(MRN_RELATIVE_DIR_PREFIX "${MRN_SOURCE_DIR}/")
else() else()
@ -360,19 +335,15 @@ else()
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
mrn_build_flag("-Wall") MY_CHECK_AND_SET_COMPILER_FLAG("-Wall")
mrn_build_flag("-Wextra") MY_CHECK_AND_SET_COMPILER_FLAG("-Wextra")
mrn_build_flag("-Wno-unused-parameter") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-parameter")
mrn_build_flag("-Wno-strict-aliasing") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-strict-aliasing")
mrn_build_flag("-Wno-deprecated") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-deprecated")
mrn_check_cxxflag("-fno-implicit-templates") MY_CHECK_AND_SET_COMPILER_FLAG("-fno-implicit-templates")
if(("${MYSQL_VARIANT}" STREQUAL "MariaDB") OR MY_CHECK_AND_SET_COMPILER_FLAG("-fno-exceptions")
("${MYSQL_VARIANT}" STREQUAL "MySQL" AND MY_CHECK_AND_SET_COMPILER_FLAG("-fno-rtti")
${MYSQL_VERSION} VERSION_LESS "5.7.0")) MY_CHECK_AND_SET_COMPILER_FLAG("-felide-constructors")
mrn_check_cxxflag("-fno-exceptions")
mrn_check_cxxflag("-fno-rtti")
endif()
mrn_check_cxxflag("-felide-constructors")
endif() endif()
set_source_files_properties(${MRN_SOURCES} PROPERTIES set_source_files_properties(${MRN_SOURCES} PROPERTIES
COMPILE_FLAGS "${MYSQL_CFLAGS} ${MRN_CXX_COMPILE_FLAGS}") COMPILE_FLAGS "${MYSQL_CFLAGS} ${MRN_CXX_COMPILE_FLAGS}")

View file

@ -143,59 +143,34 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif() endif()
macro(check_cflag flag)
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CFLAG${temporary_variable_name}")
check_c_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} ${flag}")
endif()
endmacro()
macro(check_cxxflag flag)
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CXXFLAG${temporary_variable_name}")
check_cxx_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} ${flag}")
endif()
endmacro()
macro(check_build_flag flag)
check_cflag(${flag})
check_cxxflag(${flag})
endmacro()
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
check_build_flag("-Wall") MY_CHECK_AND_SET_COMPILER_FLAG("-Wall")
check_build_flag("-Wextra") MY_CHECK_AND_SET_COMPILER_FLAG("-Wextra")
check_build_flag("-Wno-unused-but-set-variable") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-but-set-variable")
check_build_flag("-Wno-unused-parameter") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-parameter")
check_build_flag("-Wno-sign-compare") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-sign-compare")
check_cflag("-Wno-pointer-sign") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-pointer-sign")
check_build_flag("-Wno-missing-field-initializers") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-missing-field-initializers")
check_build_flag("-Wformat=2") MY_CHECK_AND_SET_COMPILER_FLAG("-Wformat=2")
check_build_flag("-Wstrict-aliasing=2") MY_CHECK_AND_SET_COMPILER_FLAG("-Wstrict-aliasing=2")
check_build_flag("-fno-strict-aliasing") MY_CHECK_AND_SET_COMPILER_FLAG("-fno-strict-aliasing")
check_build_flag("-Wdisabled-optimization") MY_CHECK_AND_SET_COMPILER_FLAG("-Wdisabled-optimization")
check_build_flag("-Wfloat-equal") MY_CHECK_AND_SET_COMPILER_FLAG("-Wfloat-equal")
check_build_flag("-Wpointer-arith") MY_CHECK_AND_SET_COMPILER_FLAG("-Wpointer-arith")
check_cflag("-Wdeclaration-after-statement") MY_CHECK_AND_SET_COMPILER_FLAG("-Wdeclaration-after-statement")
check_cflag("-Wbad-function-cast") MY_CHECK_AND_SET_COMPILER_FLAG("-Wbad-function-cast")
check_build_flag("-Wcast-align") MY_CHECK_AND_SET_COMPILER_FLAG("-Wcast-align")
# check_build_flag("-Wredundant-decls") #MY_CHECK_AND_SET_COMPILER_FLAG("-Wredundant-decls")
check_build_flag("-Wwrite-strings") MY_CHECK_AND_SET_COMPILER_FLAG("-Wwrite-strings")
check_cxxflag("-fexceptions") MY_CHECK_AND_SET_COMPILER_FLAG("-fexceptions")
check_cxxflag("-fimplicit-templates") MY_CHECK_AND_SET_COMPILER_FLAG("-fimplicit-templates")
check_build_flag("-Wno-clobbered") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-clobbered")
endif() endif()
if(NOT DEFINED CMAKE_C_COMPILE_OPTIONS_PIC) if(NOT DEFINED CMAKE_C_COMPILE_OPTIONS_PIC)
# For old CMake # For old CMake
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX)
check_build_flag("-fPIC") MY_CHECK_AND_SET_COMPILER_FLAG("-fPIC")
endif() endif()
endif() endif()

View file

@ -1,10 +1,7 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET")
IF(HAVE_WVLA) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
ENDIF()
SET(SPIDER_SOURCES SET(SPIDER_SOURCES
spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc

View file

@ -17,12 +17,8 @@ IF(NOT LIBJEMALLOC)
MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported") MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported")
ENDIF() ENDIF()
IF (HAVE_WVLA) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-vla") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
ENDIF()
############################################ ############################################
SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-10.1/README-TOKUDB\nusr/share/doc/mariadb-server-10.1/README.md" PARENT_SCOPE) SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-10.1/README-TOKUDB\nusr/share/doc/mariadb-server-10.1/README.md" PARENT_SCOPE)
@ -70,36 +66,7 @@ ENDIF()
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
macro(set_cflags_if_supported) MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-missing-field-initializers)
foreach(flag ${ARGN})
string(REGEX REPLACE "-" "_" temp_flag ${flag})
check_c_compiler_flag(${flag} HAVE_C_${temp_flag})
if (HAVE_C_${temp_flag})
set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
endif ()
check_cxx_compiler_flag(${flag} HAVE_CXX_${temp_flag})
if (HAVE_CXX_${temp_flag})
set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}")
endif ()
endforeach(flag)
endmacro(set_cflags_if_supported)
macro(append_cflags_if_supported)
foreach(flag ${ARGN})
string(REGEX REPLACE "-" "_" temp_flag ${flag})
check_c_compiler_flag(${flag} HAVE_C_${temp_flag})
if (HAVE_C_${temp_flag})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
endif ()
check_cxx_compiler_flag(${flag} HAVE_CXX_${temp_flag})
if (HAVE_CXX_${temp_flag})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
endif ()
endforeach(flag)
endmacro(append_cflags_if_supported)
set_cflags_if_supported(-Wno-missing-field-initializers)
append_cflags_if_supported(-Wno-vla)
ADD_SUBDIRECTORY(ft-index) ADD_SUBDIRECTORY(ft-index)

View file

@ -46,18 +46,6 @@ endif (USE_GCOV)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
## adds a compiler flag if the compiler supports it
macro(set_cflags_if_supported_named flag flagname)
check_c_compiler_flag("${flag}" HAVE_C_${flagname})
if (HAVE_C_${flagname})
set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
endif ()
check_cxx_compiler_flag("${flag}" HAVE_CXX_${flagname})
if (HAVE_CXX_${flagname})
set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}")
endif ()
endmacro(set_cflags_if_supported_named)
## adds a compiler flag if the compiler supports it ## adds a compiler flag if the compiler supports it
macro(set_cflags_if_supported) macro(set_cflags_if_supported)
foreach(flag ${ARGN}) foreach(flag ${ARGN})
@ -84,21 +72,19 @@ macro(set_ldflags_if_supported)
endmacro(set_ldflags_if_supported) endmacro(set_ldflags_if_supported)
## disable some warnings ## disable some warnings
set_cflags_if_supported( MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-missing-field-initializers)
-Wno-missing-field-initializers MY_CHECK_AND_SET_COMPILER_FLAG(-Wstrict-null-sentinel)
-Wstrict-null-sentinel MY_CHECK_AND_SET_COMPILER_FLAG(-Winit-self)
-Winit-self MY_CHECK_AND_SET_COMPILER_FLAG(-Wswitch)
-Wswitch MY_CHECK_AND_SET_COMPILER_FLAG(-Wtrampolines)
-Wtrampolines MY_CHECK_AND_SET_COMPILER_FLAG(-Wlogical-op)
-Wlogical-op MY_CHECK_AND_SET_COMPILER_FLAG(-Wmissing-format-attribute)
-Wmissing-format-attribute MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-error=missing-format-attribute)
-Wno-error=missing-format-attribute MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-error=address-of-array-temporary)
-Wno-error=address-of-array-temporary MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-error=tautological-constant-out-of-range-compare)
-Wno-error=tautological-constant-out-of-range-compare MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-ignored-attributes)
-Wno-ignored-attributes MY_CHECK_AND_SET_COMPILER_FLAG(-fno-rtti)
-fno-rtti MY_CHECK_AND_SET_COMPILER_FLAG(-fno-exceptions)
-fno-exceptions
)
## set_cflags_if_supported_named("-Weffc++" -Weffcpp) ## set_cflags_if_supported_named("-Weffc++" -Weffcpp)
if (CMAKE_CXX_FLAGS MATCHES -fno-implicit-templates) if (CMAKE_CXX_FLAGS MATCHES -fno-implicit-templates)
@ -111,19 +97,12 @@ endif()
## Clang has stricter POD checks. So, only enable this warning on our other builds (Linux + GCC) ## Clang has stricter POD checks. So, only enable this warning on our other builds (Linux + GCC)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang) if (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_cflags_if_supported( MY_CHECK_AND_SET_COMPILER_FLAG(-Wpacked)
-Wpacked
)
endif () endif ()
## this hits with optimized builds somewhere in ftleaf_split, we don't ## this hits with optimized builds somewhere in ftleaf_split, we don't
## know why but we don't think it's a big deal ## know why but we don't think it's a big deal
set_cflags_if_supported( MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-error=strict-overflow)
-Wno-error=strict-overflow
)
set_ldflags_if_supported(
-Wno-error=strict-overflow
)
## set extra debugging flags and preprocessor definitions ## set extra debugging flags and preprocessor definitions
set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 ${CMAKE_C_FLAGS_DEBUG}")
@ -154,16 +133,15 @@ else ()
endif () endif ()
## set warnings ## set warnings
set_cflags_if_supported( MY_CHECK_AND_SET_COMPILER_FLAG(-Wextra)
-Wextra MY_CHECK_AND_SET_COMPILER_FLAG(-Wbad-function-cast)
-Wbad-function-cast MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-missing-noreturn)
-Wno-missing-noreturn MY_CHECK_AND_SET_COMPILER_FLAG(-Wstrict-prototypes)
-Wstrict-prototypes MY_CHECK_AND_SET_COMPILER_FLAG(-Wmissing-prototypes)
-Wmissing-prototypes MY_CHECK_AND_SET_COMPILER_FLAG(-Wmissing-declarations)
-Wmissing-declarations MY_CHECK_AND_SET_COMPILER_FLAG(-Wpointer-arith)
-Wpointer-arith MY_CHECK_AND_SET_COMPILER_FLAG(-Wmissing-format-attribute)
-Wmissing-format-attribute MY_CHECK_AND_SET_COMPILER_FLAG(-Wshadow)
-Wshadow
## other flags to try: ## other flags to try:
#-Wunsafe-loop-optimizations #-Wunsafe-loop-optimizations
#-Wpointer-arith #-Wpointer-arith
@ -173,11 +151,10 @@ set_cflags_if_supported(
#-Wzero-as-null-pointer-constant #-Wzero-as-null-pointer-constant
#-Wlogical-op #-Wlogical-op
#-Wvector-optimization-performance #-Wvector-optimization-performance
)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang) if (NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# Disabling -Wcast-align with clang. TODO: fix casting and re-enable it, someday. # Disabling -Wcast-align with clang. TODO: fix casting and re-enable it, someday.
set_cflags_if_supported(-Wcast-align) MY_CHECK_AND_SET_COMPILER_FLAG(-Wcast-align)
endif () endif ()
## always want these ## always want these

View file

@ -462,14 +462,6 @@ SET(INNOBASE_SOURCES
ut/ut0wqueue.cc ut/ut0wqueue.cc
ut/ut0timer.cc) ut/ut0timer.cc)
# 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(XTRADB_OK) IF(XTRADB_OK)
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
DEFAULT RECOMPILE_FOR_EMBEDDED DEFAULT RECOMPILE_FOR_EMBEDDED