<commit_before>"""wrapper for cmake tool"""
import subprocess

from mod import log

name = 'cmake'
platforms = ['linux', 'osx', 'win']
optional = False
not_found = 'please install cmake 2.8.11 or newer'

# required version
major = 2
minor = 8

#------------------------------------------------------------------------------
def check_exists(fips_dir) :
    """test if cmake is in the path and has the required version
    
    :returns:   True if cmake found and is the required version
    """
    try:
        out = subprocess.check_output(['cmake', '--version'], universal_newlines=True)
        ver = out.split()[2].split('.')
        if int(ver[0]) > major or int(ver[0]) == major and int(ver[2]) >= minor:
            return True
        else :
            log.info('{}NOTE{}: cmake must be at least version {}.{} (found: {}.{}.{})'.format(
                    log.RED, log.DEF, major, minor, ver[0],ver[1],ver[2]))
            return False
    except OSError:
        return False

#------------------------------------------------------------------------------
def run_gen(cfg, project_dir, build_dir, toolchain_path, defines) :
    """run cmake tool to generate build files
    
    :param cfg:             a fips config object
    :param project_dir:     absolute path to project (must have root CMakeLists.txt file)
    :param build_dir:       absolute path to build directory (where cmake files are generated)
    :param toolchain:       toolchain path or None
    :returns:               True if cmake returned successful
    """
    cmdLine = ['cmake', '-G', cfg['generator'], '-DCMAKE_BUILD_TYPE={}'.format(cfg['build_type'])]
    if toolchain_path is not None :
        cmdLine.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_path))
    cmdLine.append('-DFIPS_CONFIG={}'.format(cfg['name']))
    if cfg['defines'] is not None :
        for key in cfg['defines'] :<commit_msg>Fixed cmake version check<commit_after>"""wrapper for cmake tool"""
import subprocess

from mod import log

name = 'cmake'
platforms = ['linux', 'osx', 'win']
optional = False
not_found = 'please install cmake 2.8 or newer'

# required version
major = 2
minor = 8

#------------------------------------------------------------------------------
def check_exists(fips_dir) :
    """test if cmake is in the path and has the required version
    
    :returns:   True if cmake found and is the required version
    """
    try:
        out = subprocess.check_output(['cmake', '--version'], universal_newlines=True)
        ver = out.split()[2].split('.')
        if int(ver[0]) > major or (int(ver[0]) == major and int(ver[1]) >= minor):
            return True
        else :
            log.info('{}NOTE{}: cmake must be at least version {}.{} (found: {}.{}.{})'.format(
                    log.RED, log.DEF, major, minor, ver[0],ver[1],ver[2]))
            return False
    except OSError:
        return False

#------------------------------------------------------------------------------
def run_gen(cfg, project_dir, build_dir, toolchain_path, defines) :
    """run cmake tool to generate build files
    
    :param cfg:             a fips config object
    :param project_dir:     absolute path to project (must have root CMakeLists.txt file)
    :param build_dir:       absolute path to build directory (where cmake files are generated)
    :param toolchain:       toolchain path or None
    :returns:               True if cmake returned successful
    """
    cmdLine = ['cmake', '-G', cfg['generator'], '-DCMAKE_BUILD_TYPE={}'.format(cfg['build_type'])]
    if toolchain_path is not None :
        cmdLine.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain_path))
    cmdLine.append('-DFIPS_CONFIG={}'.format(cfg['name']))
    if cfg['defines'] is not None :
        for key in cfg['defines'] :
{'fraction_non_alphanumeric': 0.203893712181005, 'fraction_numerical': 0.006314127861089187, 'mean_word_length': 2.118949958982773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3903738', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1065, 'n_words': 341}