macro(enable_gcc_warning which)
  if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W${which}")
  endif()
  if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${which}")
  endif()
endmacro()

macro(disable_gcc_warning which)
  if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${which}")
  endif()
  if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${which}")
  endif()
endmacro()

macro(enable_colors)
  if(CMAKE_GENERATOR STREQUAL Ninja)
    if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
    endif()
    if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
    endif()
  endif()
endmacro()

macro(enable_assertions type)
  string(TOUPPER "${type}" _type)
  if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
    string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_${_type} "${CMAKE_C_FLAGS_${_type}}")
  endif()
  if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
    string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_${_type} "${CMAKE_CXX_FLAGS_${_type}}")
  endif()
  if (CMAKE_C_COMPILER_ID MATCHES MSVC)
    string(REPLACE "/DNDEBUG" "" CMAKE_C_FLAGS_${_type} "${CMAKE_C_FLAGS_${_type}}")
  endif()
  if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
    string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_${_type} "${CMAKE_CXX_FLAGS_${_type}}")
  endif()
  unset(_type)
endmacro()
