Skip to content

Commit c9a6012

Browse files
authored
Use find_program to find llvm-config (#500) (#502)
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 b71c980 commit c9a6012

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,14 @@ endif()
295295
if(USE_PREBUILT_LLVM AND UNIX)
296296
# llvm_map_components_to_libnames(... all) returns empty string if llvm is
297297
# pre-built locally in either static or shared type in Ubuntu 22.04 container.
298-
execute_process(COMMAND llvm-config --libs all OUTPUT_VARIABLE ALL_LIBS)
298+
find_program(LLVM_CONFIG_EXE
299+
NAMES llvm-config-${PREFERRED_LLVM_VERSION} llvm-config
300+
PATHS ${LLVM_BINARY_DIR} ${LLVM_BINARY_DIR}/bin)
301+
if(NOT LLVM_CONFIG_EXE)
302+
message(FATAL_ERROR "[OPENCL-CLANG] llvm-config is not found")
303+
endif()
304+
305+
execute_process(COMMAND ${LLVM_CONFIG_EXE} --libs all OUTPUT_VARIABLE ALL_LIBS)
299306
string(REGEX REPLACE "( |\r|\n|-l)+" ";" ALL_LLVM_LIBS ${ALL_LIBS})
300307
set(ALL_LLVM_LIBS "LLVMSPIRVLib${ALL_LLVM_LIBS}")
301308
else()

0 commit comments

Comments
 (0)