From dda296e09ee53ed85ccf1c3f08e7e809adce612e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 18 Nov 2016 18:18:58 +0000 Subject: [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. --- lib/Basic/CMakeLists.txt | 15 +++++++++++++++ lib/Core/CMakeLists.txt | 25 +++++++++++++++++++++++++ lib/Expr/CMakeLists.txt | 6 ++++++ lib/Module/CMakeLists.txt | 15 +++++++++++++++ lib/Solver/CMakeLists.txt | 13 ++++++++++++- lib/Support/CMakeLists.txt | 6 ++++++ 6 files changed, 79 insertions(+), 1 deletion(-) (limited to 'lib') 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}) -- cgit 1.4.1