def detect_cpp_compiler(self, want_cross):
        evar = 'CXX'
        if self.is_cross_build() and want_cross:
            compilers = [self.cross_info.config['binaries']['cpp']]
            ccache = []
            is_cross = True
            exe_wrap = self.cross_info.config['binaries'].get('exe_wrapper', None)
        elif evar in os.environ:
            compilers = os.environ[evar].split()
            ccache = []
            is_cross = False
            exe_wrap = None
        else:
            compilers = self.default_cpp
            ccache = self.detect_ccache()
            is_cross = False
            exe_wrap = None
        popen_exceptions = {}
        for compiler in compilers:
            basename = os.path.basename(compiler).lower()
            if basename == 'cl' or basename == 'cl.exe':
                arg = '/?'
            else:
                arg = '--version'
            try:
                p = subprocess.Popen([compiler, arg],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
            except __HOLE__ as e:
                popen_exceptions[' '.join([compiler, arg])] = e
                continue
            (out, err) = p.communicate()
            out = out.decode(errors='ignore')
            err = err.decode(errors='ignore')
            vmatch = re.search(Environment.version_regex, out)
            if vmatch:
                version = vmatch.group(0)
            else:
                version = 'unknown version'
            if 'apple' in out and 'Free Software Foundation' in out:
                return GnuCPPCompiler(ccache + [compiler], version, GCC_OSX, is_cross, exe_wrap)
            if (out.startswith('c++ ') or 'g++' in out or 'GCC' in out) and \
                'Free Software Foundation' in out:
                lowerout = out.lower()
                if 'mingw' in lowerout or 'msys' in lowerout or 'mingw' in compiler.lower():
                    gtype = GCC_MINGW
                else:
                    gtype = GCC_STANDARD
                return GnuCPPCompiler(ccache + [compiler], version, gtype, is_cross, exe_wrap)
            if 'clang' in out:
                if 'Apple' in out:
                    cltype = CLANG_OSX
                else:
                    cltype = CLANG_STANDARD
                return ClangCPPCompiler(ccache + [compiler], version, cltype, is_cross, exe_wrap)
            if 'Microsoft' in out or 'Microsoft' in err:
                version = re.search(Environment.version_regex, err).group()
                return VisualStudioCPPCompiler([compiler], version, is_cross, exe_wrap)
        errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"'
        if popen_exceptions:
            errmsg += '\nThe follow exceptions were encountered:'
            for (c, e) in popen_exceptions.items():
                errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e)
        raise EnvironmentException(errmsg)
dataset/ETHPy150Open mesonbuild/meson/mesonbuild/environment.py/Environment.detect_cpp_compiler