Skip to content

Commit e041fca

Browse files
authored
Merge pull request #2211 from IntelPython/fix-intel-sycl-compiler-cmake-os-ci
Fix CMake error in OS compiler workflow
2 parents 2e67f59 + 04a9f04 commit e041fca

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

libsyclinterface/cmake/modules/FindIntelSyclCompiler.cmake

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +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)
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 "${_clang_match}")
106+
endif()
103107

104-
# Get the dpcpp version
105-
string(REGEX MATCH
106-
"[0-9]+\.[0-9]+\.[0-9]+"
107-
IntelSyclCompiler_VERSION
108-
${VERSION_STRING}
109-
)
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 "${_oneapi_match}")
112+
endif()
113+
endif()
114+
math(EXPR IDX "${IDX}+1")
115+
endforeach()
110116

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

0 commit comments

Comments
 (0)