Skip to content

Commit

Permalink
Use find_program to find llvm-config (intel#500)
Browse files Browse the repository at this point in the history
llvm-config may have a different name in the default path, see intel#497.
On Ubuntu 22.04,
* https://apt.llvm.org/llvm.sh installs llvm-config-{VERSION} to
  /usr/bin folder. It is a symlink to /usr/lib/llvm-{VERSION}/bin/llvm-config.
* If latest llvm is built from source, the name is /usr/local/bin/llvm-config.

(cherry picked from commit 8304021)
  • Loading branch information
wenju-he committed Oct 31, 2023
1 parent b71c980 commit f013e39
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,14 @@ endif()
if(USE_PREBUILT_LLVM AND UNIX)
# llvm_map_components_to_libnames(... all) returns empty string if llvm is
# pre-built locally in either static or shared type in Ubuntu 22.04 container.
execute_process(COMMAND llvm-config --libs all OUTPUT_VARIABLE ALL_LIBS)
find_program(LLVM_CONFIG_EXE
NAMES llvm-config-${PREFERRED_LLVM_VERSION} llvm-config
PATHS ${LLVM_BINARY_DIR} ${LLVM_BINARY_DIR}/bin)
if(NOT LLVM_CONFIG_EXE)
message(FATAL_ERROR "[OPENCL-CLANG] llvm-config is not found")
endif()

execute_process(COMMAND ${LLVM_CONFIG_EXE} --libs all OUTPUT_VARIABLE ALL_LIBS)
string(REGEX REPLACE "( |\r|\n|-l)+" ";" ALL_LLVM_LIBS ${ALL_LIBS})
set(ALL_LLVM_LIBS "LLVMSPIRVLib${ALL_LLVM_LIBS}")
else()
Expand Down

0 comments on commit f013e39

Please sign in to comment.