about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-11-22 09:50:41 +0000
committerDan Liew <delcypher@gmail.com>2016-11-22 20:23:22 +0000
commitc003a21a8fc1849e3661d6b7b996a26ae8edaea8 (patch)
tree75b5ffb3bd85e413d6ec5d9952c489be1562d772
parent699ad8c143983097cb24fac45c37f3246c7fab7b (diff)
downloadklee-c003a21a8fc1849e3661d6b7b996a26ae8edaea8.tar.gz
[CMake] Fix determining the system libraries needed by LLVM from
`llvm-config` when using LLVM 3.5 and newer.

In newer versions of `llvm-config`, `--ldflags` doesn't give
the system libraries anymore. Instead we need to use `--system-libs`.

Issue reported by @ryosa .
-rw-r--r--cmake/find_llvm.cmake9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmake/find_llvm.cmake b/cmake/find_llvm.cmake
index b1d3dc27..df730e12 100644
--- a/cmake/find_llvm.cmake
+++ b/cmake/find_llvm.cmake
@@ -149,7 +149,14 @@ else()
     string_to_list("${_llvm_libs}" _llvm_libs_list)
 
     # Now find the system libs that are needed.
-    _run_llvm_config(_system_libs "--ldflags")
+    if (${LLVM_PACKAGE_VERSION} VERSION_LESS "3.5")
+      # For LLVM 3.4 and older system libraries
+      # appeared in the output of `--ldflags`.
+      _run_llvm_config(_system_libs "--ldflags")
+      # TODO: Filter out `-L<path>` flag.
+    else()
+      _run_llvm_config(_system_libs "--system-libs")
+    endif()
     string_to_list("${_system_libs}" _system_libs_list)
 
     # Create an imported target for each LLVM library