Developer Guide and Reference

  • 2021.2
  • 04/07/2021
  • Public Content
  • Download as PDF
Contents

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 ../
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.
  • Visual Studio Generators: Visual Studio generators are supported, but you need to install plugins for Visual Studio. Example:
    cmake -T "Intel(R) oneAPI DPC++ Compiler" -DCMAKE_CXX_COMPILER=dpcpp ../
  • Make/Ninja Generators: The default behavior with CMake, when you use Ninja or CMake generators, does not automatically link DPC++ applications. CMake attempts to link with
    lld-link.exe
    , which correctly links an application without errors (if you are explicitly linking to SYCL*), but the application does not run SYCL kernels correctly. To link and run without errors, you must use
    dpcpp.exe
    .

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.
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.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.