about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-11-18 18:18:58 +0000
committerDan Liew <delcypher@gmail.com>2016-11-18 21:01:20 +0000
commitdda296e09ee53ed85ccf1c3f08e7e809adce612e (patch)
treec53130ee61c9b65b95d8507a8e5902aff56151a9 /lib
parent82ab37990126ac9501d5775c2257ae4314986016 (diff)
downloadklee-dda296e09ee53ed85ccf1c3f08e7e809adce612e.tar.gz
[CMake] Re-express LLVM and KLEE library dependencies as
transitive dependencies on KLEE's libraries rather than on the final
binaries. This is better because it means we can build
other tools that use KLEE's libraries and not need to express the
needed LLVM dependencies.

It also makes it clearer what the dependencies are between KLEE
libraries. This has illustrated a problem with the `kleeBasic`
library. It contains `ConstructSolverChain.cpp` which clearly
belongs in `kleaverSolver` not in `kleeBasic`. This will be fixed
later.
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/CMakeLists.txt15
-rw-r--r--lib/Core/CMakeLists.txt25
-rw-r--r--lib/Expr/CMakeLists.txt6
-rw-r--r--lib/Module/CMakeLists.txt15
-rw-r--r--lib/Solver/CMakeLists.txt13
-rw-r--r--lib/Support/CMakeLists.txt6
6 files changed, 79 insertions, 1 deletions
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index 13f76d42..988a564e 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -12,3 +12,18 @@ klee_add_component(kleeBasic
 	KTest.cpp
 	Statistics.cpp
 )
+set(LLVM_COMPONENTS
+  support
+)
+
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleeBasic PUBLIC ${LLVM_LIBS})
+
+target_link_libraries(kleeBasic PRIVATE
+  # FIXME: THIS IS STUPID.
+  # `ConstructSolverChain.cpp` should be in
+  # `kleaverSolver` not in in `kleeBasic`.
+  # We are creating a circular dependency because
+  # of this because `kleaverSolver` depends on `kleeBasic`.
+  kleaverSolver
+)
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index 05e2cffa..79c529d0 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -27,3 +27,28 @@ klee_add_component(kleeCore
 	TimingSolver.cpp
 	UserSearcher.cpp
 )
+
+# TODO: Work out what the correct LLVM components are for
+# kleeCore.
+set(LLVM_COMPONENTS
+  core
+  support
+)
+
+if ("${LLVM_PACKAGE_VERSION}" VERSION_EQUAL "3.6" OR
+    "${LLVM_PACKAGE_VERSION}" VERSION_GREATER "3.6")
+  list(APPEND LLVM_COMPONENTS mcjit executionengine native)
+else()
+  list(APPEND LLVM_COMPONENTS jit engine)
+endif()
+
+
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleeCore PUBLIC ${LLVM_LIBS})
+target_link_libraries(kleeCore PRIVATE
+  kleeBasic
+  kleeModule
+  kleaverSolver
+  kleaverExpr
+  kleeSupport
+)
diff --git a/lib/Expr/CMakeLists.txt b/lib/Expr/CMakeLists.txt
index 6ea77544..c7dbb8b7 100644
--- a/lib/Expr/CMakeLists.txt
+++ b/lib/Expr/CMakeLists.txt
@@ -21,3 +21,9 @@ klee_add_component(kleaverExpr
 	Parser.cpp
 	Updates.cpp
 )
+
+set(LLVM_COMPONENTS
+  support
+)
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleaverExpr PUBLIC ${LLVM_LIBS})
diff --git a/lib/Module/CMakeLists.txt b/lib/Module/CMakeLists.txt
index a952ed17..4d993047 100644
--- a/lib/Module/CMakeLists.txt
+++ b/lib/Module/CMakeLists.txt
@@ -18,3 +18,18 @@ klee_add_component(kleeModule
 	PhiCleaner.cpp
 	RaiseAsm.cpp
 )
+
+set(LLVM_COMPONENTS
+  bitreader
+  bitwriter
+  ipo
+  linker
+  support
+)
+
+if ("${LLVM_PACKAGE_VERSION}" VERSION_EQUAL "3.3" OR
+    "${LLVM_PACKAGE_VERSION}" VERSION_GREATER "3.3")
+  list(APPEND LLVM_COMPONENTS irreader)
+endif()
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleeModule PUBLIC ${LLVM_LIBS})
diff --git a/lib/Solver/CMakeLists.txt b/lib/Solver/CMakeLists.txt
index 8add4ad6..7864b2de 100644
--- a/lib/Solver/CMakeLists.txt
+++ b/lib/Solver/CMakeLists.txt
@@ -29,4 +29,15 @@ klee_add_component(kleaverSolver
 	Z3Solver.cpp
 )
 
-target_link_libraries(kleaverSolver PRIVATE ${KLEE_SOLVER_LIBRARIES})
+set(LLVM_COMPONENTS
+  support
+)
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleaverSolver PUBLIC ${LLVM_LIBS})
+
+target_link_libraries(kleaverSolver PRIVATE
+  kleeBasic
+  kleaverExpr
+  kleeSupport
+  ${KLEE_SOLVER_LIBRARIES})
+
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index 4bf7ea7d..0e76062a 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -18,3 +18,9 @@ klee_add_component(kleeSupport
 )
 
 target_link_libraries(kleeSupport PRIVATE ${ZLIB_LIBRARIES})
+
+set(LLVM_COMPONENTS
+  support
+)
+klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
+target_link_libraries(kleeSupport PUBLIC ${LLVM_LIBS})