Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intel oneapi detection #15358

Merged
merged 9 commits into from
Dec 28, 2023
26 changes: 26 additions & 0 deletions conan/internal/api/detect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def _detect_gcc_libcxx(version_, executable):
return "libCstd"
elif compiler == "mcst-lcc":
return "libstdc++"
elif compiler == "intel-cc":
return "libstdc++11"


def default_msvc_runtime(compiler):
Expand Down Expand Up @@ -225,9 +227,16 @@ def _visual_cppstd_default(version):
def _mcst_lcc_cppstd_default(version):
return "gnu14" if version >= "1.24" else "gnu98"

def _intel_cppstd_default(version):
tokens = version.main
major = tokens[0]
# https://www.intel.com/content/www/us/en/developer/articles/troubleshooting/icx-changes-default-cpp-std-to-cpp17-with-2023.html
return "17" if major >= "2023" else "14"
jakeheke75 marked this conversation as resolved.
Show resolved Hide resolved

default = {"gcc": _gcc_cppstd_default(compiler_version),
"clang": _clang_cppstd_default(compiler_version),
"apple-clang": "gnu98",
"intel-cc": _intel_cppstd_default(compiler_version),
"msvc": _visual_cppstd_default(compiler_version),
"mcst-lcc": _mcst_lcc_cppstd_default(compiler_version)}.get(str(compiler), None)
return default
Expand Down Expand Up @@ -268,6 +277,9 @@ def detect_compiler():
output.error("%s detected as a frontend using apple-clang. "
"Compiler not supported" % command)
return gcc, gcc_version
if "icpx" in command or "icx" in command:
intel, intel_version = _intel_compiler(command)
return intel, intel_version
if platform.system() == "SunOS" and command.lower() == "cc":
return _sun_cc_compiler(command)
if (platform.system() == "Windows" and command.rstrip('"').endswith(("cl", "cl.exe"))
Expand Down Expand Up @@ -342,6 +354,18 @@ def _gcc_compiler(compiler_exe="gcc"):
except (Exception,): # to disable broad-except
return None, None

def _intel_compiler(compiler_exe="icx"):
try:
ret, out = detect_runner("%s --version" % compiler_exe)
if ret != 0:
return None, None
compiler = "intel-cc"
installed_version = re.search(r"(202[0-9]+(\.[0-9])?)", out).group()
if installed_version:
ConanOutput(scope="detect_api").info("Found %s %s" % (compiler, installed_version))
return compiler, Version(installed_version)
except (Exception,): # to disable broad-except
return None, None

def _sun_cc_compiler(compiler_exe="cc"):
try:
Expand Down Expand Up @@ -423,4 +447,6 @@ def default_compiler_version(compiler, version):
return major
elif compiler == "msvc":
return major
elif compiler == "intel-cc":
return major
return version
3 changes: 2 additions & 1 deletion conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
libcxx: [libstdc++, libc++]
cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
intel-cc:
version: ["2021.1", "2021.2", "2021.3"]
version: ["2021.1", "2021.2", "2021.3", "2021.4", "2022.1", "2022.2",
jakeheke75 marked this conversation as resolved.
Show resolved Hide resolved
"2022.3", "2023.0", "2023.1", "2023.2", "2024.0",]
update: [null, ANY]
mode: ["icx", "classic", "dpcpp"]
libcxx: [null, libstdc++, libstdc++11, libc++]
Expand Down