find_package(LLVM REQUIRED CONFIG)
llvm_map_components_to_libnames(llvm_libs
core
support
target
irreader
)
target_include_directories(catguy PRIVATE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(catguy PRIVATE ${LLVM_DEFINITIONS})
target_link_libraries(catguy PRIVATE ${llvm_libs})
The above fails with:
[ 50%] Linking CXX executable catguy
/usr/bin/ld: cannot find -lLLVMCore: No such file or directory
/usr/bin/ld: cannot find -lLLVMTarget: No such file or directory
/usr/bin/ld: cannot find -lLLVMIRReader: No such file or directory
collect2: error: ld returned 1 exit status
But if I change the target_link_libraries to just link_libraries it builds successfully. Can somebody please explain why this happens? and how to fix it?
The above code is mostly from the llvm docs: Building LLVM with CMake - LLVM