Using CMake with Data Parallel C++ (DPC++)

The following content is OS specific.

Linux*

Using CMake with the Intel® oneAPI DPC++/C++ Compiler (dpcpp) on Linux is supported. You may need to set your CXX or CMAKE_CXX_COMPILER string to dpcpp. For example:

$ CXX=dpcpp cmake ../ 

-or-

$ cmake –DCMAKE_CXX_COMPILER=dpcpp ../ 

Note

Make and Ninja Generators are also supported.

Windows*

There are differences in behavior between build system generation targets when you use CMake to compile with the Intel oneAPI DPC++/C++ Compiler. The two supported generators are Microsoft Visual Studio* and Make/Ninja.

Support

Intel is working to contribute support into CMake for the Intel oneAPI DPC++/C++ Compiler.

There are a few workarounds for directing CMake to use dpcpp.exe as the linker. See the table below for specific built target considerations.

Target Type Status Note

Executable

Workaround available

See the workaround section.

Library (Static)

Workaround available

See the workaround section.

Note

Pay special attention to llvm-ar and llvm-ranlib requirements.

Library (Shared)

Fails (some solutions are available, but are untested)

A mix of MVC and non-MVC flags causes issues due to incompatibles.

Workaround

The following workaround contains the CMake flags/directives that you need to be set before the projects() line.

``` 

set(CMAKE_CXX_COMPILER "dpcpp") 
include (Platform/Windows-Clang) 
set(CMAKE_LINKER "dpcpp") 
set(CMAKE_AR "llvm-ar") 
set(CMAKE_RANLIB "llvm-ranlib") 
set(CMAKE_CXX_STANDARD 17) 
set(CMAKE_CXX_FLAGS "/EHsc") 
 
project(project-name CXX) 

``` 

For static library targets, you need to add llvm-ar and llvm-ranlib to your PATH. llvm-ar is included with the Intel oneAPI DPC++/C++ Compiler, but llvm-ranlib is not. llvm-ranlib can be found in the Intel® Distribution for Python, which is part of the LLVM/Clang installation available through the Visual Studio Package manager.