Skip to content

Commit

Permalink
Updated code to skip gcc when it's using apple-clang as a frontend in…
Browse files Browse the repository at this point in the history
… Mac OS X
  • Loading branch information
pvicente committed Feb 21, 2018
1 parent 22b941a commit 16b1e85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions conans/client/conf/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _clang_compiler(output, compiler_exe="clang"):
compiler = "apple-clang"
elif "clang version" in out:
compiler = "clang"
installed_version = re.search("version ([0-9]\.[0-9])", out).group(1)
installed_version = re.search("([0-9]\.[0-9])", out).group()
if installed_version:
output.success("Found %s %s" % (compiler, installed_version))
return compiler, installed_version
Expand Down Expand Up @@ -146,13 +146,19 @@ def _get_default_compiler(output):
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 or "clang" in command.lower():
if "gcc" in command:
if platform.system() != "Darwin":
return _gcc_compiler(output, command)

# In Mac OS X check if gcc is a fronted using apple-clang
_, out = _execute("%s --version" % command)
out = out.lower()
if "gcc" in out:
if "clang" not in out:
return _gcc_compiler(output, command)
if "clang" in out:
return _clang_compiler(output, command)
output.warn("%s detected as a frontend using apple-clang, skipping it to use native apple-clang" % command)
command = "clang" # Force use of clang when gcc is detected as a fronted of apple-clang
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
Expand Down
2 changes: 2 additions & 0 deletions conans/test/util/detect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ def _execute(command):
# result is a list of tuples (name, value) so converting it to dict
result = dict(result)
self.assertEquals(result.get("compiler", None), "apple-clang")
self.assertIn("gcc detected as a frontend using apple-clang", output)
self.assertIsNotNone(output.warn)

0 comments on commit 16b1e85

Please sign in to comment.