about summary refs log tree commit diff homepage
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
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.
-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
-rw-r--r--tools/kleaver/CMakeLists.txt7
-rw-r--r--tools/klee/CMakeLists.txt28
8 files changed, 86 insertions, 29 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})
diff --git a/tools/kleaver/CMakeLists.txt b/tools/kleaver/CMakeLists.txt
index befbcc6e..54452fff 100644
--- a/tools/kleaver/CMakeLists.txt
+++ b/tools/kleaver/CMakeLists.txt
@@ -10,9 +10,10 @@ add_executable(kleaver
 	main.cpp
 )
 
-klee_get_llvm_libs(LLVM_LIBS support)
-set(KLEE_LIBS kleeBasic kleaverSolver kleaverExpr kleeSupport)
+set(KLEE_LIBS
+  kleaverSolver
+)
 
-target_link_libraries(kleaver ${KLEE_LIBS} ${LLVM_LIBS})
+target_link_libraries(kleaver ${KLEE_LIBS})
 
 install(TARGETS kleaver RUNTIME DESTINATION bin)
diff --git a/tools/klee/CMakeLists.txt b/tools/klee/CMakeLists.txt
index 1f9fe63f..9c8c2192 100644
--- a/tools/klee/CMakeLists.txt
+++ b/tools/klee/CMakeLists.txt
@@ -10,33 +10,11 @@ add_executable(klee
 	main.cpp
 )
 
-# FIXME: This shouldn't be done here. Instead the KLEE libraries
-# should declare their LLVM dependencies.
-set(LLVM_COMPONENTS
-	bitreader
-	bitwriter
-	ipo
-	linker
-	support
+set(KLEE_LIBS
+  kleeCore
 )
 
-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()
-
-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})
-
-set(KLEE_LIBS kleeCore kleeBasic kleeModule kleaverSolver kleaverExpr kleeSupport)
-
-target_link_libraries(klee ${KLEE_LIBS} ${LLVM_LIBS})
+target_link_libraries(klee ${KLEE_LIBS})
 
 install(TARGETS klee RUNTIME DESTINATION bin)