message("-- Option list:")

macro(ADD_OPTION _name _desc _value)
  if (DEFINED ${_name})
    if (${${_name}})
      set(${_name} ${${_name}})
      unset(${_name} CACHE)

      add_definitions("-DGD_${_name}=${${_name}}")
    endif()
  else()
    if (${_value})
      add_definitions("-DGD_${_name}=${_value}")
    endif()
    set(${_name} ${_value})
  endif()
  message("   - ${_name}: ${${_name}}")
endmacro()

macro(ADD_CHOICE _name _desc _choices _default)
  if (DEFINED ${_name})
    string(FIND ${_choices} "${${_name}}" _index)
    if (${_index} LESS 0)
      message(FATAL_ERROR "Incorrect value (${${_name}}) for ${_name}. Must be one of: [${_choices}]\n")
    endif()

    set(${_name} ${${_name}})
    unset(${_name} CACHE)
  else()
    set(${_name} ${_default})
  endif()
  message("   - ${_name}: ${${_name}}")
endmacro()
