Check whether -Wno-unused-but-set-variable is supported before using
authorDmitry Marakasov <amdmi3@amdmi3.ru>
Mon, 1 Aug 2011 18:17:32 +0000 (22:17 +0400)
committerDmitry Marakasov <amdmi3@amdmi3.ru>
Mon, 1 Aug 2011 18:17:32 +0000 (22:17 +0400)
it. It seems to only be available on recent (>=4.6) versions of gcc.

src/CMakeLists.txt

index ce53651b0dee22555de44788808c80595ec46c77..5bdfc7eeeb17ff4277326cd648296c61409aad67 100644 (file)
@@ -209,6 +209,8 @@ endif(BUILD_SERVER)
 # Set some optimizations and tweaks
 #
 
+include(CheckCCompilerFlag)
+
 if(MSVC)
        # Visual Studio
 
@@ -236,7 +238,10 @@ else()
        endif()
        
        if(NOT APPLE)
-               set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
+               check_c_compiler_flag("-Wno-unused-but-set-variable" HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
+               if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
+                       set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
+               endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
        endif()
        
        if(APPLE)