-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetectInstalledLLVMVersion.cmake
More file actions
26 lines (26 loc) · 1.04 KB
/
DetectInstalledLLVMVersion.cmake
File metadata and controls
26 lines (26 loc) · 1.04 KB
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
function(detect_llvm_version outputVersionVar outputDirVar libDir)
file(GLOB FILEZ LIST_DIRECTORIES ON "${libDir}/*")
set(latestLLVMVersion "")
set(latestLLVMVersionDir "")
foreach(file ${FILEZ})
if(IS_DIRECTORY "${file}")
get_filename_component(dirName "${file}" NAME)
string(REGEX MATCH "^llvm-(([0-9]+)(.[0-9]+)*)$" MATCHED "${dirName}")
if(MATCHED)
set(libgccVersionCandidate "${CMAKE_MATCH_1}")
message(STATUS "Found LLVM version candidate: ${libgccVersionCandidate}")
if(libgccVersionCandidate VERSION_GREATER latestLLVMVersion)
set(latestLLVMVersion "${libgccVersionCandidate}")
set(latestLLVMVersionDir "${dirName}")
endif()
endif()
endif()
endforeach()
if(latestLLVMVersion)
set(latestLLVMVersionDir "${libDir}/${latestLLVMVersionDir}")
set("${outputDirVar}" "${latestLLVMVersionDir}" PARENT_SCOPE)
set("${outputVersionVar}" "${latestLLVMVersion}" PARENT_SCOPE)
message(STATUS "Detected LLVM version: ${latestLLVMVersion}")
message(STATUS "In directory: ${latestLLVMVersionDir}")
endif()
endfunction()