Skip to content

Commit 6eb1932

Browse files
authored
cmake: allow providing SYCL_DIR (#699)
allow providing SYCL_DIR
1 parent 57f9c68 commit 6eb1932

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

cmake/modules/FindSyclRuntime.cmake

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,33 @@
2727

2828
include(FindPackageHandleStandardArgs)
2929

30-
if(NOT DEFINED ENV{CMPLR_ROOT})
30+
if(NOT DEFINED ENV{CMPLR_ROOT} AND NOT DEFINED ENV{SYCL_DIR})
3131
message(WARNING "Please make sure to install Intel DPC++ Compiler and run setvars.(sh/bat)")
3232
message(WARNING "You can download standalone Intel DPC++ Compiler from https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#compilers")
33+
message(Warning "Alternatively, you can set environment SYCL_DIR to the install dir of SYCL")
3334
else()
34-
get_filename_component(ONEAPI_VER "$ENV{CMPLR_ROOT}" NAME)
35-
# Adding more precise detection for SYCL runtime folder name
36-
if (ONEAPI_VER)
37-
string(REGEX MATCH "[0-9]+.[0-9]+[.0-9]*" VER_NUMBER ${ONEAPI_VER})
35+
if(DEFINED ENV{SYCL_DIR})
36+
set(SyclRuntime_ROOT "$ENV{SYCL_DIR}")
3837
else()
39-
set(VER_NUMBER FALSE)
40-
endif()
38+
get_filename_component(ONEAPI_VER "$ENV{CMPLR_ROOT}" NAME)
39+
# Adding more precise detection for SYCL runtime folder name
40+
if (ONEAPI_VER)
41+
string(REGEX MATCH "[0-9]+.[0-9]+[.0-9]*" VER_NUMBER ${ONEAPI_VER})
42+
else()
43+
set(VER_NUMBER FALSE)
44+
endif()
4145

42-
if(VER_NUMBER AND ONEAPI_VER VERSION_LESS 2024.0)
43-
if(LINUX OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
44-
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/linux")
45-
elseif(WIN32)
46-
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/windows")
46+
if(VER_NUMBER AND ONEAPI_VER VERSION_LESS 2024.0)
47+
if(LINUX OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
48+
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/linux")
49+
elseif(WIN32)
50+
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/windows")
51+
endif()
52+
else()
53+
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}")
4754
endif()
48-
else()
49-
set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}")
5055
endif()
56+
5157
list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include")
5258
list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include/sycl")
5359

0 commit comments

Comments
 (0)