Skip to content

Commit e85b343

Browse files
authored
Use find_program to find llvm-config (#500) (#501)
llvm-config may have a different name in the default path, see #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 llvm is built from source, the name is /usr/local/bin/llvm-config. (cherry picked from commit 8304021)
1 parent 7b62fd8 commit e85b343

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,14 @@ endif()
301301
if(USE_PREBUILT_LLVM AND UNIX)
302302
# llvm_map_components_to_libnames(... all) returns empty string if llvm is
303303
# pre-built locally in either static or shared type in Ubuntu 22.04 container.
304-
execute_process(COMMAND llvm-config --libs all OUTPUT_VARIABLE ALL_LIBS)
304+
find_program(LLVM_CONFIG_EXE
305+
NAMES llvm-config-${PREFERRED_LLVM_VERSION} llvm-config
306+
PATHS ${LLVM_BINARY_DIR} ${LLVM_BINARY_DIR}/bin)
307+
if(NOT LLVM_CONFIG_EXE)
308+
message(FATAL_ERROR "[OPENCL-CLANG] llvm-config is not found")
309+
endif()
310+
311+
execute_process(COMMAND ${LLVM_CONFIG_EXE} --libs all OUTPUT_VARIABLE ALL_LIBS)
305312
string(REGEX REPLACE "( |\r|\n|-l)+" ";" ALL_LLVM_LIBS ${ALL_LIBS})
306313
set(ALL_LLVM_LIBS "LLVMSPIRVLib${ALL_LLVM_LIBS}")
307314
else()

0 commit comments

Comments
 (0)