Before starting the CMake build process, configure CMake to find oneAPI configuration files. The two methods are described below.
Enable CMake with setvars.sh, oneapi-vars.sh, or vars.sh
If you are already using setvars.sh, oneapi-vars.sh, or vars.sh to initialize the build environment, then all the necessary environment variables are being set and you should be able to use CMake. For more information on these scripts, see Use the setvars and oneapi-vars Scripts with Linux*.
Enable Cmake by Explicitly Setting CMAKE_PREFIX_PATH
As an alternative to using one of the above initialization scripts, you can manually add the oneAPI CMake configuration files to the CMAKE_PREFIX_PATH. The paths to add depend on the oneAPI installation. If your installation includes the Unified Directory Layout, you can add a single directory to the CMAKE_PREFIX_PATH to enable CMake for all oneAPI libraries. The Unified Directory Layout can be found in 2024 and later releases of oneAPI toolkits. To check if you have it, look for this directory /opt/intel/oneapi/2024.0/lib, adjusting the version number for your install.
If the directory exists, add the following to your startup script:
export CMAKE_PREFIX_PATH=/opt/intel/oneapi/2024.0/lib:${CMAKE_PREFIX_PATH}
When new versions of oneAPI toolkits or components are installed, ensure you update the version reference at the end of that path.
To learn more about the Unified Directory Layout, see oneAPI Development Environment Setup.
If your oneAPI installation does not include the Unified Directory Layout, then add individual CMake directories to the CMAKE_PREFIX_PATH. For example, to add the latest install of the Intel® Math Kernel Library (Intel® MKL):
export CMAKE_PREFIX_PATH=/opt/intel/oneapi/mkl/latest/lib:${CMAKE_PREFIX_PATH}
If you want to use a specific version of Intel® MKL, change “latest” to the version number in the path.
For specific information on how to use a oneAPI library with CMake, consult the developer guide for your component or library.