From df27d2ce08ff576adde91008ad70b3bfca1af8b3 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 1 Mar 2019 13:00:13 -0700 Subject: [PATCH] llvm7: fix linking This patch makes use of llvm-config which automatically takes care of the command line that should be passed to linker in order to link with llvm7. --- clang_delta/CMakeLists.txt | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/clang_delta/CMakeLists.txt b/clang_delta/CMakeLists.txt index 6493abf0..7d518333 100644 --- a/clang_delta/CMakeLists.txt +++ b/clang_delta/CMakeLists.txt @@ -57,16 +57,14 @@ include_directories(${CLANG_INCLUDE_DIRS}) # only works for LLVM post-4.0 link_directories(${LLVM_LIBRARY_DIRS}) -llvm_map_components_to_libnames(LLVM_LIBS - coverage - irreader - mcparser - objcarcopts - option - passes - profiledata - support -) +find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config DOC "llvm-config executable") +if (NOT LLVM_CONFIG_EXECUTABLE STREQUAL "LLVM_CONFIG_EXECUTABLE-NOTFOUND") + execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs coverage irreader mcparser objcarcopts option passes profiledata support + OUTPUT_VARIABLE LLVM_LIBS + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() set(CLANG_LIBS clangStaticAnalyzerFrontend @@ -242,11 +240,7 @@ add_executable(clang_delta git_version.h ) -# ENE, LLVM 6.0: LLVM_LIBS end up in the link command line anyway. I'm not -# quite sure why! But if you list LLVM_LIBS here, the `clang_delta' binary -# can end up with dynamic link errors when it runs (multiply defined symbols). -# -target_link_libraries(clang_delta ${CLANG_LIBS}) +target_link_libraries(clang_delta ${CLANG_LIBS} ${LLVM_LIBS}) # Custom target for running clang_delta tests #