Commit 1fde7853 authored by Dmitry Shulga's avatar Dmitry Shulga

MDEV-31890: Compilation failing on MacOS (unknown warning option -Wno-unused-but-set-variable)

For clang compiler the compiler's flag -Wno-unused-but-set-variable
was set based on compiler version. This approach could result in
false positive detection for presence of compiler option since
only first three groups of digits in compiler version taken into account
and it could lead to inaccuracy in determining of supported compiler's
features.

Correct way to detect options supported by a compiler is to use
the macros  MY_CHECK_CXX_COMPILER_FLAG and to check the result of
variable with prefix have_CXX__
So, to check whether compiler does support the option
 -Wno-unused-but-set-variable
the macros
 MY_CHECK_CXX_COMPILER_FLAG(-Wno-unused-but-set-variable)
should be called and the result variable
 have_CXX__Wno_unused_but_set_variable
be tested for assigned value.
parent 02878f12
......@@ -153,8 +153,8 @@ SET (SQL_SOURCE
${MYSYS_LIBWRAP_SOURCE}
)
IF(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0")
MY_CHECK_CXX_COMPILER_FLAG(-Wno-unused-but-set-variable)
IF(have_CXX__Wno_unused_but_set_variable)
ADD_COMPILE_FLAGS(${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
COMPILE_FLAGS "-Wno-unused-but-set-variable")
......
......@@ -358,8 +358,9 @@ IF(MSVC)
# on generated file.
TARGET_COMPILE_OPTIONS(innobase PRIVATE "/wd4065")
ENDIF()
IF(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0")
MY_CHECK_CXX_COMPILER_FLAG(-Wno-unused-but-set-variable)
IF(have_CXX__Wno_unused_but_set_variable)
ADD_COMPILE_FLAGS(pars/pars0grm.cc fts/fts0pars.cc
COMPILE_FLAGS "-Wno-unused-but-set-variable")
ENDIF()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment