about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2023-02-23 21:47:53 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-03-17 22:38:16 +0000
commit3ef5c9d0cd51babb7c4ec2d7bb76d0cb7e47a65c (patch)
treea2cb9e4c193d674b4f49634d0f546b65ce547860 /lib
parent7a4a9b9b47d2fe9b90cee95d68d89faa24a118d4 (diff)
downloadklee-3ef5c9d0cd51babb7c4ec2d7bb76d0cb7e47a65c.tar.gz
[cmake] Use LLVM's CMake functionality only
LLVM became more complex, use LLVM's CMake functionality directly instead
of replicating this behaviour in KLEE's build system.

Use the correct build flags provided by LLVM itself.
This is influenced by the way LLVM is built in the first place.

Remove older CMake support (< 3.0).
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/CMakeLists.txt13
-rw-r--r--lib/Core/CMakeLists.txt20
-rw-r--r--lib/Expr/CMakeLists.txt12
-rw-r--r--lib/Module/CMakeLists.txt21
-rw-r--r--lib/Solver/CMakeLists.txt15
-rw-r--r--lib/Support/CMakeLists.txt13
6 files changed, 48 insertions, 46 deletions
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index d156116f..5671c144 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -6,13 +6,14 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-klee_add_component(kleeBasic
+add_library(kleeBasic
   KTest.cpp
   Statistics.cpp
 )
-set(LLVM_COMPONENTS
-  support
-)
 
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleeBasic PUBLIC ${LLVM_LIBS})
+llvm_map_components_to_libnames(llvm_libs support)
+target_link_libraries(kleeBasic PRIVATE ${llvm_libs})
+target_compile_options(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(kleeBasic PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index de52cd11..0905a7f0 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -6,7 +6,7 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-klee_add_component(kleeCore
+add_library(kleeCore
   AddressSpace.cpp
   MergeHandler.cpp
   CallPathManager.cpp
@@ -28,18 +28,6 @@ klee_add_component(kleeCore
   UserSearcher.cpp
 )
 
-# TODO: Work out what the correct LLVM components are for
-# kleeCore.
-set(LLVM_COMPONENTS
-  core
-  executionengine
-  mcjit
-  native
-  support
-)
-
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleeCore PUBLIC ${LLVM_LIBS} ${SQLITE3_LIBRARIES})
 target_link_libraries(kleeCore PRIVATE
   kleeBasic
   kleeModule
@@ -47,3 +35,9 @@ target_link_libraries(kleeCore PRIVATE
   kleaverExpr
   kleeSupport
 )
+
+llvm_map_components_to_libnames(llvm_libs core executionengine mcjit native support)
+target_link_libraries(kleeCore PRIVATE ${llvm_libs} ${SQLITE3_LIBRARIES})
+target_include_directories(kleeCore PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${SQLITE3_INCLUDE_DIRS})
+target_compile_options(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
diff --git a/lib/Expr/CMakeLists.txt b/lib/Expr/CMakeLists.txt
index f469a1de..6b8a873b 100644
--- a/lib/Expr/CMakeLists.txt
+++ b/lib/Expr/CMakeLists.txt
@@ -6,7 +6,7 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-klee_add_component(kleaverExpr
+add_library(kleaverExpr
   ArrayCache.cpp
   ArrayExprOptimizer.cpp
   ArrayExprRewriter.cpp
@@ -26,8 +26,8 @@ klee_add_component(kleaverExpr
   Updates.cpp
 )
 
-set(LLVM_COMPONENTS
-  support
-)
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleaverExpr PUBLIC ${LLVM_LIBS})
+llvm_map_components_to_libnames(llvm_libs support)
+target_link_libraries(kleaverExpr PRIVATE ${llvm_libs})
+target_include_directories(kleaverExpr PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
+target_compile_options(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
diff --git a/lib/Module/CMakeLists.txt b/lib/Module/CMakeLists.txt
index 6c2a24b3..c81d395e 100644
--- a/lib/Module/CMakeLists.txt
+++ b/lib/Module/CMakeLists.txt
@@ -22,22 +22,31 @@ set(KLEE_MODULE_COMPONENT_SRCS
   RaiseAsm.cpp
 )
 
-klee_add_component(kleeModule
+add_library(kleeModule
   ${KLEE_MODULE_COMPONENT_SRCS}
 )
 
-set(LLVM_COMPONENTS
-  bitreader
+llvm_map_components_to_libnames(llvm_libs bitreader
   bitwriter
   codegen
   ipo
   irreader
   linker
   support
-)
+  scalaropts
+  instcombine
+  transformutils
+  analysis
+  object
+  mc
+  binaryformat
+  )
+
+target_link_libraries(kleeModule PRIVATE ${llvm_libs})
 
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleeModule PUBLIC ${LLVM_LIBS})
 target_link_libraries(kleeModule PRIVATE
   kleeSupport
 )
+target_include_directories(kleeModule PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
+target_compile_options(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
diff --git a/lib/Solver/CMakeLists.txt b/lib/Solver/CMakeLists.txt
index 31c8302a..81a64882 100644
--- a/lib/Solver/CMakeLists.txt
+++ b/lib/Solver/CMakeLists.txt
@@ -6,7 +6,7 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-klee_add_component(kleaverSolver
+add_library(kleaverSolver
   AssignmentValidatingSolver.cpp
   CachingSolver.cpp
   CexCachingSolver.cpp
@@ -32,15 +32,14 @@ klee_add_component(kleaverSolver
   Z3Solver.cpp
 )
 
-set(LLVM_COMPONENTS
-  support
-)
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleaverSolver PUBLIC ${LLVM_LIBS})
-
+llvm_map_components_to_libnames(llvm_libs support)
 target_link_libraries(kleaverSolver PRIVATE
   kleeBasic
   kleaverExpr
   kleeSupport
-  ${KLEE_SOLVER_LIBRARIES})
+  ${KLEE_SOLVER_LIBRARIES} ${llvm_libs})
+target_include_directories(kleaverSolver PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${KLEE_SOLVER_INCLUDE_DIRS})
+target_compile_options(kleaverSolver PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleaverSolver PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
 
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index 7145930f..7ff4daa3 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -6,7 +6,7 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-klee_add_component(kleeSupport
+add_library(kleeSupport
   CompressionStream.cpp
   ErrorHandling.cpp
   FileHandling.cpp
@@ -18,10 +18,9 @@ klee_add_component(kleeSupport
   TreeStream.cpp
 )
 
-target_link_libraries(kleeSupport PRIVATE ${ZLIB_LIBRARIES})
+llvm_map_components_to_libnames(llvm_libs support)
 
-set(LLVM_COMPONENTS
-  support
-)
-klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
-target_link_libraries(kleeSupport PUBLIC ${LLVM_LIBS})
+target_link_libraries(kleeSupport PRIVATE ${llvm_libs} ${ZLIB_LIBRARIES} ${TCMALLOC_LIBRARIES})
+target_include_directories(kleeSupport PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${TCMALLOC_INCLUDE_DIR})
+target_compile_options(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})