From c5c5046bbf55b188adefd2db5af13af56276bfc0 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Wed, 23 Aug 2023 20:47:55 +0200 Subject: [PATCH] CMake: support LLVM as a single shared library --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d51da30de2..9545f67832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,17 @@ if (WITH_LLVM) add_definitions("-DHAVE_TARGET_X86=1") endif() - llvm_map_components_to_libnames(llvm_libs ${LPYTHON_LLVM_COMPONENTS}) + if (TARGET LLVMCore) + # If `LLVMCore` target is present, then LLVM is distributed as separate + # libraries and llvm_map_components_to_libnames() should work: + llvm_map_components_to_libnames(llvm_libs ${LPYTHON_LLVM_COMPONENTS}) + else() + # Workaround for https://github.com/llvm/llvm-project/issues/34593 + # If LLVM is distributed as a single library (the LLVMCore target is + # missing), we set `llvm_libs` to "LLVM" which links against the single + # `libLLVM.so` shared library. + set(llvm_libs "LLVM") + endif() unset(LPYTHON_LLVM_COMPONENTS) add_library(p::llvm INTERFACE IMPORTED)