include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
macro(add_c_compiler_flag_if_supported FLAG)
  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
  CHECK_C_COMPILER_FLAG(${FLAG} FLAG_SUPPORTED)
  if(FLAG_SUPPORTED)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
  endif()
  CHECK_CXX_COMPILER_FLAG(${FLAG} FLAG_SUPPORTED)
  if(FLAG_SUPPORTED)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
  endif()
endmacro(add_c_compiler_flag_if_supported)

