def METHOD_NAME():
    parser = argparse.ArgumentParser()
    parser.add_argument('-D', dest='defines', action='append', default=[])
    parser.add_argument('-i', '--input',
                        help='cmake-style template to generate from')
    parser.add_argument('-o', '--output',
                        help='name of output file to write')
    parser.add_argument('-c', '--check-unchanged', action='store_true',
                        help='avoid touching file if contents would not change')
    parser.add_argument('-v', '--verbose', action='store_true')
    args = parser.parse_args()
    if args.input:
        defines = {}
        for define in args.defines:
            if '=' in define:
                name, val = define.split('=', 1)
                defines[name] = val
            else:
                defines[define] = '1'
        contents = ''
        used = set()
        with open(args.input, 'r') as f:
            for l in f:
                if l.startswith('#cmakedefine '):
                    defvar = l[13:].rstrip()
                    if ' ' in defvar:
                        defvar, rest = defvar.split(' ', 1)
                        # strip matching quotes
                        if rest.startswith('"') and rest.endswith('"'):
                            rest = rest[1:-1]
                    else:
                        rest = ''
                    used.add(defvar)
                    if defvar in defines:
                        if rest != '':
                            rest = rest.replace('@' + defvar + '@',
                                                defines[defvar])
                            contents += '#define {} {}\n'.format(defvar,
                                                                 rest)
                        else:
                            contents += '#define {}\n'.format(defvar)
                    else:
                        contents += '/* #undef {} */\n'.format(defvar)
                else:
                    contents += l
        unused = set(defines) - used
        if len(unused) > 0:
            for defvar in sorted(unused):
                sys.stderr.write('{}: ERROR: \'{}\' does not appear in \'{}\'\n'.format(sys.argv[0],
                                                                                        defvar,
                                                                                        args.input))
            exit(1)
    else:
        contents = '/* Generated by: {} */\n'.format(' '.join(map(quote, sys.argv)))
        for define in args.defines:
            contents += make_define(define)
    if args.output:
        if args.check_unchanged:
            try:
                oldcontents = open(args.output, 'r').read()
                if contents == oldcontents:
                    if args.verbose:
                        print('Contents of \'{}\' have not changed.'.format(args.output))
                    exit(0)
                else:
                    if args.verbose:
                        print('Contents of \'{}\' have changed - rewriting file.'.format(args.output))
            except IOError:
                # file does not exist or not readable - either way, we want to
                #  fall through and try to write it ourselves
                pass
        with open(args.output, 'w') as f:
            f.write(contents)
    else:
        sys.stdout.write(contents)