[mlir] Use StringRef::{starts,ends}_with (NFC)
[llvm-project.git] / mlir / cmake / modules / FindSyclRuntime.cmake
blob38b065a3f284c2c7ac7118df733dca75599570da
1 # CMake find_package() module for SYCL Runtime
3 # Example usage:
5 # find_package(SyclRuntime)
7 # If successful, the following variables will be defined:
8 # SyclRuntime_FOUND
9 # SyclRuntime_INCLUDE_DIRS
10 # SyclRuntime_LIBRARY
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")
19 else()
20     if(LINUX OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
21         set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/linux")
22     elseif(WIN32)
23         set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/windows")
24     endif()
25     list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include")
26     list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include/sycl")
28     set(SyclRuntime_LIBRARY_DIR "${SyclRuntime_ROOT}/lib")
30     message(STATUS "SyclRuntime_LIBRARY_DIR: ${SyclRuntime_LIBRARY_DIR}")
31     find_library(SyclRuntime_LIBRARY
32         NAMES sycl
33         PATHS ${SyclRuntime_LIBRARY_DIR}
34         NO_DEFAULT_PATH
35         )
36 endif()
38 if(SyclRuntime_LIBRARY)
39     set(SyclRuntime_FOUND TRUE)
40     if(NOT TARGET SyclRuntime::SyclRuntime)
41         add_library(SyclRuntime::SyclRuntime INTERFACE IMPORTED)
42         set_target_properties(SyclRuntime::SyclRuntime
43             PROPERTIES INTERFACE_LINK_LIBRARIES "${SyclRuntime_LIBRARY}"
44       )
45       set_target_properties(SyclRuntime::SyclRuntime
46           PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SyclRuntime_INCLUDE_DIRS}"
47       )
48     endif()
49 else()
50     set(SyclRuntime_FOUND FALSE)
51 endif()
53 find_package_handle_standard_args(SyclRuntime
54     REQUIRED_VARS
55         SyclRuntime_FOUND
56         SyclRuntime_INCLUDE_DIRS
57         SyclRuntime_LIBRARY
58         SyclRuntime_LIBRARY_DIR
59     HANDLE_COMPONENTS
62 mark_as_advanced(SyclRuntime_LIBRARY SyclRuntime_INCLUDE_DIRS)
64 if(SyclRuntime_FOUND)
65     find_package_message(SyclRuntime "Found SyclRuntime: ${SyclRuntime_LIBRARY}" "")
66 else()
67     find_package_message(SyclRuntime "Could not find SyclRuntime" "")
68 endif()