conan.tools.intel
IntelCC
Available since: 1.41.0
This tool helps you to manage the new Intel oneAPI DPC++/C++ and Classic ecosystem in Conan.
Warning
This generator is experimental and subject to breaking changes.
Warning
macOS is not supported for the Intel oneAPI DPC++/C++ (icx/icpx or dpcpp) compilers. For macOS or Xcode support, you’ll have to use the Intel C++ Classic Compiler.
Note
Remember, you need to have installed previously the Intel oneAPI software.
Note
If you are using CMakeToolchain
or MSBuildToolchain
, you don’t need to use this generator. See intel-cc compiler section for more information.
This generator creates a conanintelsetvars.sh|bat
wrapping the Intel script setvars.sh|bat
that set the Intel oneAPI environment variables needed.
That script is the first step to start using the Intel compilers because it’s setting some important variables in your local environment.
In summary, the IntelCC
generator:
Reads your profile
[settings]
and[conf]
.Uses that information to generate a
conanintelsetvars.sh|bat
script with the command to load the Intelsetvars.sh|bat
script.Then, you or the chosen generator will be able to run that script and use any Intel compiler to compile the project.
Note
You can launch the conanintelsetvars.sh|bat
before calling your intel compiler to build a project.
Also, Conan will automatically call it in the conanfile build(self)
method when running any command with self.run
.
At first, ensure you are using a profile like this one:
[settings]
...
compiler=intel-cc
compiler.mode=dpcpp
compiler.version=2021.3
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CC=dpcpp
CXX=dpcpp
[conf]
tools.intel:installation_path=/opt/intel/oneapi
The IntelCC
generator can be used by name in conanfiles:
class Pkg(ConanFile):
generators = "IntelCC"
[generators]
IntelCC
And it can also be fully instantiated in the conanfile generate()
method:
from conans import ConanFile
from conan.tools.intel import IntelCC
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
def generate(self):
intelcc = IntelCC(self)
intelcc.generate()
Now, running the command conan install . -pr intelprofile will generate the conanintelsetvars.sh|bat
script which will run the
Intel setvars script and load all the variables into your local environment.
Custom configurations
You can apply different installation paths and command arguments simply by changing the [conf]
entries. For instance:
[settings]
...
compiler=intel-cc
compiler.mode=dpcpp
compiler.version=2021.3
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CC=dpcpp
CXX=dpcpp
[conf]
tools.intel:installation_path=/opt/intel/oneapi
tools.intel:setvars_args=--config="full/path/to/your/config.txt" --force
If we run again a conan install . -pr intelprofile then the conanintelsetvars.sh
script (if we are using Linux OS) will contain something like:
. "/opt/intel/oneapi/setvars.sh" --config="full/path/to/your/config.txt" --force
conf
These are the two different entries for IntelCC
:
tools.intel:installation_path
: (required) argument to tells Conan the installation path, if it’s not defined, Conan will try to find it out automatically.tools.intel:setvars_args
: (optional) it is used to pass whatever we want as arguments to our setvars.sh|bat file. You can check out all the possible ones from the Intel official documentation.