# OneAPI support with Custom Toolchain

**URL:** <https://discourse.cmake.org/t/oneapi-support-with-custom-toolchain/1593>\
**Category:** Code\
**Created:** [July 20, 2020, 8:55pm UTC](https://discourse.cmake.org/t/oneapi-support-with-custom-toolchain/1593 "2020-07-20T20:55:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jyoung](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jyoung](https://discourse.cmake.org/u/jyoung)\
**Post date:** [July 20, 2020, 8:55pm UTC](https://discourse.cmake.org/t/oneapi-support-with-custom-toolchain/1593/1 "2020-07-20T20:55:02Z")

</div>

I’m trying to write a custom toolchain file to support compiling a simple OneAPI project with the DPCPP compiler. It was suggested in a recent workshop that I write a custom toolchain file, which I have done (see attached). However, I’m failing on the configure step currently. Am I missing something simple about how to include and test dpcpp as the default CXX\_COMPILER?

```auto
cmake -B oneapi_build -S . -DCMAKE_TOOLCHAIN_FILE=cmake/oneapi-toolchain.cmake
-- Using DPCPP toolchain in /net/tools/intel/oneapi/beta07/inteloneapi
-- Using DPCPP toolchain in /net/tools/intel/oneapi/beta07/inteloneapi
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is Clang 11.0.0
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /net/tools/intel/oneapi/beta07/inteloneapi/compiler/latest/linux/bin/dpcpp - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /localscratch/jyoung9/sycl-testing/oneapi_build ./run_cmake_build.sh
-- Using DPCPP toolchain in /net/tools/intel/oneapi/beta07/inteloneapi
-- Using DPCPP toolchain in /net/tools/intel/oneapi/beta07/inteloneapi
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is Clang 11.0.0
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
System is unknown to cmake, create:
Platform/OneAPI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /net/tools/intel/oneapi/beta07/inteloneapi/compiler/latest/linux/bin/dpcpp - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /localscratch/sycl-testing/oneapi_build

```

```auto
# cmake/oneapi-toolchain.cmake
set(CMAKE_SYSTEM_NAME OneAPI)

#Usually ONEAPI_ROOT will be set by a call to setvars.sh
if(DEFINED ENV{ONEAPI_ROOT})
	set(ONEAPI_BASE $ENV{ONEAPI_ROOT})
else()
	set(ONEAPI_BASE "/opt/intel/inteloneapi")
endif()

message(STATUS "Using DPCPP toolchain in ${ONEAPI_BASE}")
set(CMAKE_CXX_COMPILER "${ONEAPI_BASE}/compiler/latest/linux/bin/dpcpp")

```

---

<div class="post-metadata">

**Author:** ![jyoung](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jyoung](https://discourse.cmake.org/u/jyoung)\
**Post date:** [July 20, 2020, 9:26pm UTC](https://discourse.cmake.org/t/oneapi-support-with-custom-toolchain/1593/2 "2020-07-20T21:26:23Z")

</div>

I realized that I had learned the wrong lesson from a different toolchain example cross-compiling for a different platform. Changing the system name to Linux fixes this problem, although it still skips checking that dpcpp compiles a test program.

```auto
# cmake/oneapi-toolchain.cmake (updated)
set(CMAKE_SYSTEM_NAME Linux)

```
