

def run_gen(cfg, fips_dir, project_dir, build_dir, toolchain_path, defines):
    'run cmake tool to generate build files\n    \n    :param cfg:             a fips config object\n    :param project_dir:     absolute path to project (must have root CMakeLists.txt file)\n    :param build_dir:       absolute path to build directory (where cmake files are generated)\n    :param toolchain:       toolchain path or None\n    :returns:               True if cmake returned successful\n    '
    cmdLine = 'cmake'
    if (cfg['generator'] != 'Default'):
        cmdLine += ' -G "{}"'.format(cfg['generator'])
    if cfg['generator-platform']:
        cmdLine += ' -A "{}"'.format(cfg['generator-platform'])
    if cfg['generator-toolset']:
        cmdLine += ' -T "{}"'.format(cfg['generator-toolset'])
    cmdLine += ' -DCMAKE_BUILD_TYPE={}'.format(cfg['build_type'])
    if ((cfg['build_tool'] == 'ninja') and (platform.system() == 'Windows')):
        cmdLine += ' -DCMAKE_MAKE_PROGRAM={}'.format(ninja.get_ninja_tool(fips_dir))
    if (toolchain_path is not None):
        cmdLine += ' -DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_path)
    cmdLine += ' -DFIPS_CONFIG={}'.format(cfg['name'])
    if (cfg['defines'] is not None):
        for key in cfg['defines']:
            val = cfg['defines'][key]
            if (type(val) is bool):
                cmdLine += ' -D{}={}'.format(key, ('ON' if val else 'OFF'))
            else:
                cmdLine += ' -D{}={}'.format(key, val)
    for key in defines:
        cmdLine += ' -D{}={}'.format(key, defines[cfg])
    cmdLine += (' -B' + build_dir)
    cmdLine += (' -H' + project_dir)
    print(cmdLine)
    res = subprocess.call(cmdLine, cwd=build_dir, shell=True)
    return (res == 0)

dataset/ETHPy150Open floooh/fips/mod/tools/cmake.py run_gen/VarMisuse@274/573 `key`->`cfg`