set(LLVM0_ROOT ${CMAKE_SOURCE_DIR}/llvm)
set(LLVM0_INCLUDE_DIRS ${LLVM0_ROOT}/include)
set(LLVM0_LIB_DIR ${LLVM0_ROOT}/lib)

find_library(LIBLLVM_CORE_LIBRARY NAMES LLVMCore HINTS ${LLVM0_LIB_DIR})
find_library(LIBLLVM_SUPPORT_LIBRARY NAMES LLVMSupport HINTS ${LLVM0_LIB_DIR})
find_library(LIBLLVM_ANALYSIS_LIBRARY NAMES LLVMAnalysis HINTS ${LLVM0_LIB_DIR})
find_library(LIBLLVM_BITREADER_LIBRARY NAMES LLVMBitReader HINTS ${LLVM0_LIB_DIR})
find_library(LIBLLVM_ASMPARSER_LIBRARY NAMES LLVMAsmParser HINTS ${LLVM0_LIB_DIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_Args(LLVMV0 DEFAULT_MSG
        LIBLLVM_CORE_LIBRARY LLVM0_INCLUDE_DIRS)

mark_as_advanced(LLVM0_INCLUDE_DIRS)

add_library(llvm::core INTERFACE IMPORTED)
set_property(TARGET llvm::core PROPERTY INTERFACE_LINK_LIBRARIES ${LIBLLVM_CORE_LIBRARY})
add_library(llvm::support INTERFACE IMPORTED)
set_property(TARGET llvm::support PROPERTY INTERFACE_LINK_LIBRARIES ${LIBLLVM_SUPPORT_LIBRARY})
add_library(llvm::analysis INTERFACE IMPORTED)
set_property(TARGET llvm::analysis PROPERTY INTERFACE_LINK_LIBRARIES ${LIBLLVM_ANALYSIS_LIBRARY})
add_library(llvm::bitcode INTERFACE IMPORTED)
set_property(TARGET llvm::bitcode PROPERTY INTERFACE_LINK_LIBRARIES ${LIBLLVM_BITREADER_LIBRARY} ${LIBLLVM_ASMPARSER_LIBRARY})

