74 lines · plain
1# CMake find_package() module for SYCL Runtime2#3# Example usage:4#5# find_package(SyclRuntime)6#7# If successful, the following variables will be defined:8# SyclRuntime_FOUND9# SyclRuntime_INCLUDE_DIRS10# SyclRuntime_LIBRARY11# SyclRuntime_LIBRARIES_DIR12#13 14include(FindPackageHandleStandardArgs)15 16if(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")19else()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")24 elseif(WIN32)25 set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}/windows")26 endif()27 else()28 set(SyclRuntime_ROOT "$ENV{CMPLR_ROOT}")29 endif()30 list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include")31 list(APPEND SyclRuntime_INCLUDE_DIRS "${SyclRuntime_ROOT}/include/sycl")32 33 set(SyclRuntime_LIBRARY_DIR "${SyclRuntime_ROOT}/lib")34 35 message(STATUS "SyclRuntime_LIBRARY_DIR: ${SyclRuntime_LIBRARY_DIR}")36 find_library(SyclRuntime_LIBRARY37 NAMES sycl38 PATHS ${SyclRuntime_LIBRARY_DIR}39 NO_DEFAULT_PATH40 )41endif()42 43if(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::SyclRuntime48 PROPERTIES INTERFACE_LINK_LIBRARIES "${SyclRuntime_LIBRARY}"49 )50 set_target_properties(SyclRuntime::SyclRuntime51 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SyclRuntime_INCLUDE_DIRS}"52 )53 endif()54else()55 set(SyclRuntime_FOUND FALSE)56endif()57 58find_package_handle_standard_args(SyclRuntime59 REQUIRED_VARS60 SyclRuntime_FOUND61 SyclRuntime_INCLUDE_DIRS62 SyclRuntime_LIBRARY63 SyclRuntime_LIBRARY_DIR64 HANDLE_COMPONENTS65)66 67mark_as_advanced(SyclRuntime_LIBRARY SyclRuntime_INCLUDE_DIRS)68 69if(SyclRuntime_FOUND)70 find_package_message(SyclRuntime "Found SyclRuntime: ${SyclRuntime_LIBRARY}" "")71else()72 find_package_message(SyclRuntime "Could not find SyclRuntime" "")73endif()74