1 # CMake find_package() module for SYCL Runtime
5 # find_package(SyclRuntime)
7 # If successful, the following variables will be defined:
9 # SyclRuntime_INCLUDE_DIRS
11 # SyclRuntime_LIBRARIES_DIR
14 include(FindPackageHandleStandardArgs)
16 if(NOT DEFINED ENV{CMPLR_ROOT})
17 message(WARNING "Please make sure to install Intel DPC++ Compiler and run setvars.(sh/bat)")
18 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")
20 get_filename_component(ONEAPI_VER "$ENV{CMPLR_ROOT}" NAME)
21 if(ONEAPI_VER VERSION_LESS 2024.0)
22 if(LINUX OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
23 set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/linux")
25 set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/windows")
28 set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}")
30 list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include")
31 list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include/sycl")
33 set(SyclRuntime_LIBRARY_DIR "${SyclRuntime_ROOT}/lib")
35 message(STATUS "SyclRuntime_LIBRARY_DIR: ${SyclRuntime_LIBRARY_DIR}")
36 find_library(SyclRuntime_LIBRARY
38 PATHS ${SyclRuntime_LIBRARY_DIR}
43 if(SyclRuntime_LIBRARY)
44 set(SyclRuntime_FOUND TRUE)
45 if(NOT TARGET SyclRuntime::SyclRuntime)
46 add_library(SyclRuntime::SyclRuntime INTERFACE IMPORTED)
47 set_target_properties(SyclRuntime::SyclRuntime
48 PROPERTIES INTERFACE_LINK_LIBRARIES "${SyclRuntime_LIBRARY}"
50 set_target_properties(SyclRuntime::SyclRuntime
51 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SyclRuntime_INCLUDE_DIRS}"
55 set(SyclRuntime_FOUND FALSE)
58 find_package_handle_standard_args(SyclRuntime
61 SyclRuntime_INCLUDE_DIRS
63 SyclRuntime_LIBRARY_DIR
67 mark_as_advanced(SyclRuntime_LIBRARY SyclRuntime_INCLUDE_DIRS)
70 find_package_message(SyclRuntime "Found SyclRuntime: ${SyclRuntime_LIBRARY}" "")
72 find_package_message(SyclRuntime "Could not find SyclRuntime" "")