Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FindSYCL.cmake « Modules « cmake « build_files - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1ccbee179fb5979122357469d813c433ae965256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2021-2022 Intel Corporation

# - Find SYCL library
# Find the native SYCL header and libraries needed by oneAPI implementation
# This module defines
#  SYCL_COMPILER, compiler which will be used for compilation of SYCL code
#  SYCL_LIBRARY, libraries to link against in order to use SYCL.
#  SYCL_INCLUDE_DIR, directories where SYCL headers can be found
#  SYCL_ROOT_DIR, The base directory to search for SYCL files.
#                 This can also be an environment variable.
#  SYCL_FOUND, If false, then don't try to use SYCL.

IF(NOT SYCL_ROOT_DIR AND NOT $ENV{SYCL_ROOT_DIR} STREQUAL "")
  SET(SYCL_ROOT_DIR $ENV{SYCL_ROOT_DIR})
ENDIF()

SET(_sycl_search_dirs
  ${SYCL_ROOT_DIR}
  /usr/lib
  /usr/local/lib
  /opt/intel/oneapi/compiler/latest/linux/
  C:/Program\ Files\ \(x86\)/Intel/oneAPI/compiler/latest/windows
)

# Find DPC++ compiler.
# Since the compiler name is possibly conflicting with the system-wide
# CLang start with looking for either dpcpp or clang binary in the given
# list of search paths only. If that fails, try to look for a system-wide
# dpcpp binary.
FIND_PROGRAM(SYCL_COMPILER
  NAMES
    icpx
    dpcpp
    clang++
  HINTS
    ${_sycl_search_dirs}
  PATH_SUFFIXES
    bin
  NO_CMAKE_FIND_ROOT_PATH
  NAMES_PER_DIR
)

# NOTE: No clang++ here so that we do not pick up a system-wide CLang
# compiler.
if(NOT SYCL_COMPILER)
  FIND_PROGRAM(SYCL_COMPILER
    NAMES
      icpx
      dpcpp
    HINTS
      ${_sycl_search_dirs}
    PATH_SUFFIXES
      bin
  )
endif()

FIND_LIBRARY(SYCL_LIBRARY
  NAMES
    sycl7
    sycl6
    sycl
  HINTS
    ${_sycl_search_dirs}
  PATH_SUFFIXES
    lib64 lib
)

if(WIN32)
  FIND_LIBRARY(SYCL_LIBRARY_DEBUG
    NAMES
      sycl7d
      sycl6d
      sycld
    HINTS
      ${_sycl_search_dirs}
    PATH_SUFFIXES
      lib64 lib
  )
endif()

FIND_PATH(SYCL_INCLUDE_DIR
  NAMES
    sycl/sycl.hpp
  HINTS
    ${_sycl_search_dirs}
  PATH_SUFFIXES
    include
)

IF(EXISTS "${SYCL_INCLUDE_DIR}/sycl/version.hpp")
  FILE(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_major_version REGEX "^#define __LIBSYCL_MAJOR_VERSION[ \t].*$")
  STRING(REGEX MATCHALL "[0-9]+" _libsycl_major_version ${_libsycl_major_version})
  FILE(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_minor_version REGEX "^#define __LIBSYCL_MINOR_VERSION[ \t].*$")
  STRING(REGEX MATCHALL "[0-9]+" _libsycl_minor_version ${_libsycl_minor_version})
  FILE(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_patch_version REGEX "^#define __LIBSYCL_PATCH_VERSION[ \t].*$")
  STRING(REGEX MATCHALL "[0-9]+" _libsycl_patch_version ${_libsycl_patch_version})

  SET(SYCL_VERSION "${_libsycl_major_version}.${_libsycl_minor_version}.${_libsycl_patch_version}")
ENDIF()

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SYCL
  REQUIRED_VARS SYCL_LIBRARY SYCL_INCLUDE_DIR
  VERSION_VAR SYCL_VERSION
)

IF(SYCL_FOUND)
  SET(SYCL_INCLUDE_DIR ${SYCL_INCLUDE_DIR} ${SYCL_INCLUDE_DIR}/sycl)
ELSE()
  SET(SYCL_SYCL_FOUND FALSE)
ENDIF()

MARK_AS_ADVANCED(
  _SYCL_INCLUDE_PARENT_DIR
)