24
24
# If successful, the following variables will be defined:
25
25
# DPCPP_FOUND
26
26
# DPCPP_VERSION
27
+ # DPCPP_VERSION_MAJOR
28
+ # DPCPP_VERSION_MINOR
27
29
# DPCPP_INCLUDE_DIR
28
30
# DPCPP_SYCL_INCLUDE_DIR
29
31
# DPCPP_LIBRARY_DIR
30
32
# DPCPP_SYCL_LIBRARY
31
33
# DPCPP_OPENCL_LIBRARY
32
34
33
- include ( FindPackageHandleStandardArgs )
35
+ include (FindPackageHandleStandardArgs )
34
36
35
37
string (COMPARE EQUAL "${DPCPP_INSTALL_DIR} " "" no_dpcpp_root )
36
38
if (${no_dpcpp_root} )
@@ -57,10 +59,13 @@ execute_process(
57
59
# If dpcpp is found then set the package variables
58
60
if (${dpcpp_result} MATCHES "0" )
59
61
string (REPLACE "\n " ";" DPCPP_VERSION_LIST "${dpcpp_ver} " )
62
+ set (IDX 0 )
60
63
list (GET DPCPP_VERSION_LIST 0 dpcpp_ver_line )
61
64
foreach (X ${DPCPP_VERSION_LIST} )
62
- message (STATUS "dpcpp ver[${dpcpp_result} ]: ${X} " )
65
+ message (STATUS "dpcpp ver[${IDX} ]: ${X} " )
66
+ MATH (EXPR IDX "${IDX} +1" )
63
67
endforeach ()
68
+ list (GET DPCPP_VERSION_LIST 0 VERSION_STRING )
64
69
65
70
# check if llvm-cov and llvm-profdata are packaged as part of dpcpp
66
71
find_program (LLVM_COV_EXE
@@ -89,7 +94,13 @@ if(${dpcpp_result} MATCHES "0")
89
94
90
95
# set package-level variables
91
96
set (DPCPP_ROOT ${DPCPP_INSTALL_DIR} )
92
- list (GET DPCPP_VERSION_LIST 0 DPCPP_VERSION )
97
+ # Get the dpcpp version
98
+ string (REGEX MATCH "[0-9]+\. [0-9]+\. [0-9]+" DPCPP_VERSION ${VERSION_STRING} )
99
+ # Split out the version into major, minor an patch
100
+ string (REPLACE "." ";" DPCPP_VERSION_LIST1 "${DPCPP_VERSION} " )
101
+ list (GET DPCPP_VERSION_LIST1 0 DPCPP_VERSION_MAJOR )
102
+ list (GET DPCPP_VERSION_LIST1 1 DPCPP_VERSION_MINOR )
103
+ list (GET DPCPP_VERSION_LIST1 2 DPCPP_VERSION_PATCH )
93
104
set (DPCPP_INCLUDE_DIR ${DPCPP_INSTALL_DIR} /include )
94
105
set (DPCPP_SYCL_INCLUDE_DIR ${DPCPP_INSTALL_DIR} /include/sycl )
95
106
set (DPCPP_LIBRARY_DIR ${DPCPP_INSTALL_DIR} /lib )
@@ -100,15 +111,26 @@ if(${dpcpp_result} MATCHES "0")
100
111
set (DPCPP_SYCL_LIBRARY ${DPCPP_INSTALL_DIR} /lib/libsycl.so )
101
112
set (DPCPP_OPENCL_LIBRARY ${DPCPP_INSTALL_DIR} /lib/libOpenCL.so )
102
113
endif ()
103
- set (DPCPP_FOUND TRUE )
104
114
else ()
105
115
message (STATUS "DPCPP needed to build dpctl_sycl_interface" )
106
116
return ()
107
117
endif ()
108
118
119
+ # Check if a specific version of DPCPP is requested
120
+ if (DPCPP_FIND_VERSION )
121
+ string (COMPARE EQUAL ${DPCPP_FIND_VERSION} ${DPCPP_VERSION} VERSION_MATCH )
122
+ if (VERSION_MATCH )
123
+ set (DPCPP_FOUND TRUE )
124
+ endif ()
125
+ else ()
126
+ set (DPCPP_FOUND TRUE )
127
+ endif ()
128
+
109
129
find_package_handle_standard_args (DPCPP DEFAULT_MSG
110
130
DPCPP_FOUND
111
131
DPCPP_VERSION
132
+ DPCPP_VERSION_MAJOR
133
+ DPCPP_VERSION_MINOR
112
134
DPCPP_INCLUDE_DIR
113
135
DPCPP_SYCL_INCLUDE_DIR
114
136
DPCPP_LIBRARY_DIR
0 commit comments