Skip to content

Commit 3c380c9

Browse files
committed
refactor finding Intel SYCL compiler version
now more robust, with an option for clang versioning (OS compiler) and DPC++ versioning
1 parent bed074b commit 3c380c9

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

libsyclinterface/cmake/modules/FindIntelSyclCompiler.cmake

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,26 @@ execute_process(
9595
if(${clangxx_result} MATCHES "0")
9696
string(REPLACE "\n" ";" IntelSyclCompiler_VERSION_LIST "${clangxx_ver}")
9797
set(IDX 0)
98+
set(IntelSyclCompiler_VERSION "")
9899
foreach(X ${IntelSyclCompiler_VERSION_LIST})
99100
message(STATUS "dpcpp ver[${IDX}]: ${X}")
100-
MATH(EXPR IDX "${IDX}+1")
101-
endforeach()
102-
list(GET IntelSyclCompiler_VERSION_LIST 0 VERSION_STRING)
103-
if("${VERSION_STRING}" MATCHES "Intel SYCL compiler Nightly")
104-
# Handle nightly build version string
105-
list(GET IntelSyclCompiler_VERSION_LIST 1 VERSION_STRING)
106-
endif()
101+
if("x${IntelSyclCompiler_VERSION}" STREQUAL "x")
102+
# Match 'clang version xx.x.x'
103+
string(REGEX MATCH "^.*clang version [0-9]+\\.[0-9]+\\.[0-9]+.*$" _clang_match "${X}")
104+
if(_clang_match)
105+
string(REGEX REPLACE "^.*clang version ([0-9]+\\.[0-9]+\\.[0-9]+).*$" "\\1" IntelSyclCompiler_VERSION "${X}")
106+
endif()
107107

108-
# Get the dpcpp version
109-
string(REGEX MATCH
110-
"[0-9]+\.[0-9]+\.[0-9]+"
111-
IntelSyclCompiler_VERSION
112-
${VERSION_STRING}
113-
)
108+
# Match 'Intel(R) oneAPI DPC++/C++ Compiler xxxx.x.x (...)'
109+
string(REGEX MATCH "^.*Intel\\(R\\) oneAPI DPC\\+\\+\\/C\\+\\+ Compiler [0-9]+\\.[0-9]+\\.[0-9]+.*$" _oneapi_match "${X}")
110+
if(_oneapi_match)
111+
string(REGEX REPLACE "^.*Intel\\(R\\) oneAPI DPC\\+\\+\\/C\\+\\+ Compiler ([0-9]+\\.[0-9]+\\.[0-9]+).*$" "\\1" IntelSyclCompiler_VERSION "${X}")
112+
endif()
113+
endif()
114+
math(EXPR IDX "${IDX}+1")
115+
endforeach()
114116

115-
# Split out the version into major, minor an patch
117+
# Split out the version into major, minor and patch
116118
string(REPLACE "." ";" IntelSyclCompiler_VERSION_LIST1 "${IntelSyclCompiler_VERSION}")
117119
list(GET IntelSyclCompiler_VERSION_LIST1 0 IntelSyclCompiler_VERSION_MAJOR)
118120
list(GET IntelSyclCompiler_VERSION_LIST1 1 IntelSyclCompiler_VERSION_MINOR)

0 commit comments

Comments
 (0)