def _get_default_compiler(output): """ find the default compiler on the build machine search order and priority: 1. CC and CXX environment variables are always top priority 2. Visual Studio detection (Windows only) via vswhere or registry or environment variables 3. Apple Clang (Mac only) 4. cc executable 5. gcc executable 6. clang executable """ v2_mode = get_env(CONAN_V2_MODE_ENVVAR, False) cc = os.environ.get("CC", "") cxx = os.environ.get("CXX", "") if cc or cxx: # Env defined, use them output.info("CC and CXX: %s, %s " % (cc or "None", cxx or "None")) command = cc or cxx if v2_mode: compiler = _get_compiler_and_version(output, command) if compiler: return compiler else: if "gcc" in command: gcc = _gcc_compiler(output, command) if platform.system() == "Darwin" and gcc is None: output.error( "%s detected as a frontend using apple-clang. " "Compiler not supported" % command) return gcc if "clang" in command.lower(): return _clang_compiler(output, command) if platform.system() == "SunOS" and command.lower() == "cc": return _sun_cc_compiler(output, command) # I am not able to find its version output.error("Not able to automatically detect '%s' version" % command) return None vs = cc = sun_cc = None if detected_os() == "Windows": version = latest_visual_studio_version_installed(output) vs = ('Visual Studio', version) if version else None if v2_mode: cc = _get_compiler_and_version(output, "cc") gcc = _get_compiler_and_version(output, "gcc") clang = _get_compiler_and_version(output, "clang") else: gcc = _gcc_compiler(output) clang = _clang_compiler(output) if platform.system() == "SunOS": sun_cc = _sun_cc_compiler(output) if detected_os() == "Windows": return vs or cc or gcc or clang elif platform.system() == "Darwin": return clang or cc or gcc elif platform.system() == "SunOS": return sun_cc or cc or gcc or clang else: return cc or gcc or clang
def _get_default_compiler(output): cc = os.environ.get("CC", "") cxx = os.environ.get("CXX", "") if cc or cxx: # Env defined, use them output.info("CC and CXX: %s, %s " % (cc or "None", cxx or "None")) command = cc or cxx if "gcc" in command: gcc = _gcc_compiler(output, command) if platform.system() == "Darwin" and gcc is None: output.error( "%s detected as a frontend using apple-clang. Compiler not supported" % command) return gcc if "clang" in command.lower(): return _clang_compiler(output, command) if platform.system() == "SunOS" and command.lower() == "cc": return _sun_cc_compiler(output, command) # I am not able to find its version output.error("Not able to automatically detect '%s' version" % command) return None if detected_os() == "Windows": version = latest_visual_studio_version_installed(output) vs = ('Visual Studio', version) if version else None gcc = _gcc_compiler(output) clang = _clang_compiler(output) if platform.system() == "SunOS": sun_cc = _sun_cc_compiler(output) if detected_os() == "Windows": return vs or gcc or clang elif platform.system() == "Darwin": return clang or gcc elif platform.system() == "SunOS": return sun_cc or gcc or clang else: return gcc or clang