Skip to content

Commit 318a730

Browse files
committed
Check whether -Wno-unused-but-set-variable is supported before using
it. It seems to only be available on recent (>=4.6) versions of gcc.
1 parent 9017c51 commit 318a730

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ endif(BUILD_SERVER)
209209
# Set some optimizations and tweaks
210210
#
211211

212+
include(CheckCCompilerFlag)
213+
212214
if(MSVC)
213215
# Visual Studio
214216

@@ -236,7 +238,10 @@ else()
236238
endif()
237239

238240
if(NOT APPLE)
239-
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
241+
check_c_compiler_flag("-Wno-unused-but-set-variable" HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
242+
if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
243+
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
244+
endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
240245
endif()
241246

242247
if(APPLE)

0 commit comments

Comments
 (0)