Currently, llvm_config(target) method cannot be used with a target of type INTERFACE_LIBRARY like so:
add_library(Halide_LLVM INTERFACE) set(LLVM_USE_SHARED "USE_SHARED") llvm_config(Halide_LLVM ${LLVM_USE_SHARED} ${LLVM_COMPONENTS})
CMake throws an error:
-- Using LLVMConfig.cmake in: /usr/lib/llvm/10/lib64/cmake/llvm CMake Error at /usr/lib/llvm/10/lib64/cmake/llvm/LLVM-Config.cmake:91 (target_link_libraries): INTERFACE library can only be used with the INTERFACE keyword of target_link_libraries Call Stack (most recent call first): dependencies/llvm/CMakeLists.txt:135 (llvm_config)
llvm_config() method seems to be the preferred way to link a library/app against libLLVM.so, as opposed to hardcoding the LLVM library name into a manual call to target_link_libraries(). But, can't use llvm_config() if the target happens to be of type INTERFACE_LIBRARY instead of SHARED_LIBRARY, for example.
This patch adds support for INTERFACE_LIBRARY target type to llvm_config().
This would be useful to Halide's cmake script (https://halide-lang.org).