about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2023-03-22 11:13:20 +0000
committerFrank Busse <f.busse@imperial.ac.uk>2023-03-22 20:52:25 +0000
commit5607a7f1910e579acc0b93b1ae2caba88e7d5fd7 (patch)
tree586a8d40348940aed51a6c406dd35984da159ecb
parent318c63700372099a60566a3af4e0ec02dfd22073 (diff)
downloadklee-5607a7f1910e579acc0b93b1ae2caba88e7d5fd7.tar.gz
Change `llvm_map_components_to_libnames` to `llvm_config` CMake function
With recent LLVM versions, this should allow to link against dynamic LLVM
libraries.
-rw-r--r--CMakeLists.txt5
-rw-r--r--lib/Basic/CMakeLists.txt3
-rw-r--r--lib/Core/CMakeLists.txt4
-rw-r--r--lib/Expr/CMakeLists.txt3
-rw-r--r--lib/Module/CMakeLists.txt5
-rw-r--r--lib/Solver/CMakeLists.txt4
-rw-r--r--lib/Support/CMakeLists.txt4
-rw-r--r--test/CMakeLists.txt4
-rw-r--r--tools/kleaver/CMakeLists.txt4
-rw-r--r--unittests/CMakeLists.txt2
10 files changed, 20 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd8e9d75..024d8a50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -185,6 +185,11 @@ if (NOT EXISTS "${LLVM_AS}")
   message(FATAL_ERROR "Failed to find llvm-as at \"${LLVM_AS}\"")
 endif()
 
+# Check for dynamic linking
+if (LLVM_LINK_LLVM_DYLIB)
+  set(USE_LLVM_SHARED USE_SHARED)
+endif()
+
 ################################################################################
 # C++ version
 ################################################################################
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index 5671c144..db630893 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -11,8 +11,7 @@ add_library(kleeBasic
   Statistics.cpp
 )
 
-llvm_map_components_to_libnames(llvm_libs support)
-target_link_libraries(kleeBasic PRIVATE ${llvm_libs})
+llvm_config(kleeBasic "${USE_LLVM_SHARED}" support)
 target_compile_options(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
 target_compile_definitions(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
 
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index 0905a7f0..fa5c2b5a 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -36,8 +36,8 @@ target_link_libraries(kleeCore PRIVATE
   kleeSupport
 )
 
-llvm_map_components_to_libnames(llvm_libs core executionengine mcjit native support)
-target_link_libraries(kleeCore PRIVATE ${llvm_libs} ${SQLITE3_LIBRARIES})
+llvm_config(kleeCore "${USE_LLVM_SHARED}" core executionengine mcjit native support)
+target_link_libraries(kleeCore PRIVATE ${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 6b8a873b..f9a5a83b 100644
--- a/lib/Expr/CMakeLists.txt
+++ b/lib/Expr/CMakeLists.txt
@@ -26,8 +26,7 @@ add_library(kleaverExpr
   Updates.cpp
 )
 
-llvm_map_components_to_libnames(llvm_libs support)
-target_link_libraries(kleaverExpr PRIVATE ${llvm_libs})
+llvm_config(kleaverExpr "${USE_LLVM_SHARED}" support)
 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 c81d395e..e1f548e8 100644
--- a/lib/Module/CMakeLists.txt
+++ b/lib/Module/CMakeLists.txt
@@ -26,7 +26,8 @@ add_library(kleeModule
   ${KLEE_MODULE_COMPONENT_SRCS}
 )
 
-llvm_map_components_to_libnames(llvm_libs bitreader
+llvm_config(kleeModule "${USE_LLVM_SHARED}"
+  bitreader
   bitwriter
   codegen
   ipo
@@ -42,8 +43,6 @@ llvm_map_components_to_libnames(llvm_libs bitreader
   binaryformat
   )
 
-target_link_libraries(kleeModule PRIVATE ${llvm_libs})
-
 target_link_libraries(kleeModule PRIVATE
   kleeSupport
 )
diff --git a/lib/Solver/CMakeLists.txt b/lib/Solver/CMakeLists.txt
index 81a64882..dbebe145 100644
--- a/lib/Solver/CMakeLists.txt
+++ b/lib/Solver/CMakeLists.txt
@@ -32,12 +32,12 @@ add_library(kleaverSolver
   Z3Solver.cpp
 )
 
-llvm_map_components_to_libnames(llvm_libs support)
+llvm_config(kleaverSolver "${USE_LLVM_SHARED}" support)
 target_link_libraries(kleaverSolver PRIVATE
   kleeBasic
   kleaverExpr
   kleeSupport
-  ${KLEE_SOLVER_LIBRARIES} ${llvm_libs})
+  ${KLEE_SOLVER_LIBRARIES})
 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 7ff4daa3..a6f13954 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -18,9 +18,9 @@ add_library(kleeSupport
   TreeStream.cpp
 )
 
-llvm_map_components_to_libnames(llvm_libs support)
+llvm_config(kleeSupport "${USE_LLVM_SHARED}" support)
 
-target_link_libraries(kleeSupport PRIVATE ${llvm_libs} ${ZLIB_LIBRARIES} ${TCMALLOC_LIBRARIES})
+target_link_libraries(kleeSupport PRIVATE ${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})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 226eb08a..b4716dae 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -96,7 +96,7 @@ if (DOWNLOAD_FILECHECK_SOURCE)
   add_executable(FileCheck
     ${FILECHECK_SRC_FILE}
   )
-  llvm_map_components_to_libnames(FILECHECK_NEEDED_LIBS support)
+  llvm_config(FileCheck "${USE_LLVM_SHARED}" support)
   target_include_directories(FileCheck PRIVATE ${LLVM_INCLUDE_DIRS})
   target_link_libraries(FileCheck PRIVATE ${FILECHECK_NEEDED_LIBS})
 endif()
@@ -117,7 +117,7 @@ if (DOWNLOAD_NOT_SOURCE)
   add_executable("not"
     ${NOT_SRC_FILE}
   )
-  llvm_map_components_to_libnames(NOT_NEEDED_LIBS support)
+  llvm_config("not" "${USE_LLVM_SHARED}" support)
   target_include_directories("not" PRIVATE ${LLVM_INCLUDE_DIRS})
   target_link_libraries("not" PRIVATE ${NOT_NEEDED_LIBS})
 endif()
diff --git a/tools/kleaver/CMakeLists.txt b/tools/kleaver/CMakeLists.txt
index acc681e5..c2960a7e 100644
--- a/tools/kleaver/CMakeLists.txt
+++ b/tools/kleaver/CMakeLists.txt
@@ -10,9 +10,9 @@ add_executable(kleaver
   main.cpp
 )
 
-llvm_map_components_to_libnames(llvm_libs core support)
+llvm_config(kleaver "${USE_LLVM_SHARED}" core support)
 
-target_link_libraries(kleaver kleaverSolver ${llvm_libs})
+target_link_libraries(kleaver PRIVATE kleaverSolver)
 target_include_directories(kleaver PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
 target_compile_options(kleaver PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
 target_compile_definitions(kleaver PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index 9e30a9b7..17644edd 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -201,7 +201,7 @@ endif()
 
 add_library(unittest_main)
 target_sources(unittest_main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp")
-llvm_map_components_to_libnames(UNITTEST_MAIN_LIBS support)
+llvm_config(unittest_main "${USE_LLVM_SHARED}" support)
 
 target_link_libraries(unittest_main
   PUBLIC