Skip to content

Commit

Permalink
Merge pull request #5015 from acolinisi/PR--cmake-llvm-dynlib-2
Browse files Browse the repository at this point in the history
cmake: llvm: fix linking against LLVM shared lib
  • Loading branch information
alexreinking authored Jun 10, 2020
2 parents 3609c63 + 10166ad commit ee5f90e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dependencies/llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,23 @@ endif ()

##
# Finish setting up llvm library
#
# Ideally, we would use llvm_config (instead of hardcoding LLVM lib name below):
# if (LLVM_USE_SHARED_LLVM_LIBRARY)
# set(LLVM_USE_SHARED "USE_SHARED")
# endif()
# llvm_config(Halide_LLVM ${LLVM_USE_SHARED} ${LLVM_COMPONENTS})
# However, llvm_config (LLVM 10.0) does not accept INTERFACE_LIBRARY targets,
# so the below code does what llvm_config() does, with the slight difference
# that we link exclusively to the shared library without fallback to static
# libraries for symbols not resolved by the shared library.
##

if (LLVM_USE_SHARED_LLVM_LIBRARY)
set(LLVM_USE_SHARED "USE_SHARED")
set(LLVM_LIBNAMES LLVM)
else ()
llvm_map_components_to_libnames(LLVM_LIBNAMES ${LLVM_COMPONENTS})
endif ()

llvm_map_components_to_libnames(LLVM_LIBNAMES ${LLVM_COMPONENTS})
target_link_libraries(Halide_LLVM INTERFACE ${LLVM_LIBNAMES})

##
Expand Down

0 comments on commit ee5f90e

Please sign in to comment.