about summary refs log tree commit diff homepage
path: root/unittests
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 /unittests
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 'unittests')
-rw-r--r--unittests/Assignment/CMakeLists.txt4
-rw-r--r--unittests/CMakeLists.txt11
-rw-r--r--unittests/DiscretePDF/CMakeLists.txt6
-rw-r--r--unittests/Expr/CMakeLists.txt5
-rw-r--r--unittests/RNG/CMakeLists.txt4
-rw-r--r--unittests/Ref/CMakeLists.txt4
-rw-r--r--unittests/Searcher/CMakeLists.txt6
-rw-r--r--unittests/Solver/CMakeLists.txt9
-rw-r--r--unittests/Time/CMakeLists.txt3
-rw-r--r--unittests/TreeStream/CMakeLists.txt3
10 files changed, 48 insertions, 7 deletions
diff --git a/unittests/Assignment/CMakeLists.txt b/unittests/Assignment/CMakeLists.txt
index e5dd1b4c..647aae4c 100644
--- a/unittests/Assignment/CMakeLists.txt
+++ b/unittests/Assignment/CMakeLists.txt
@@ -1,3 +1,7 @@
 add_klee_unit_test(AssignmentTest
   AssignmentTest.cpp)
 target_link_libraries(AssignmentTest PRIVATE kleaverExpr kleaverSolver)
+target_compile_options(AssignmentTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(AssignmentTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(AssignmentTest PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index 88d5de91..9e30a9b7 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -46,9 +46,9 @@ endfunction()
 if (TARGET gtest)
   # try to reuse LLVM's 'gtest' target
 
-  message(WARNING "LLVM exports its 'gtest' CMake target (for Google Test), so"
-    "KLEE cannot create its own. Thus, KLEE will reuse the existing one. This"
-    "is, however, only recommended if LLVM and KLEE were built using the same"
+  message(WARNING "LLVM exports its 'gtest' CMake target (for Google Test), so "
+    "KLEE cannot create its own. Thus, KLEE will reuse the existing one. This "
+    "is, however, only recommended if LLVM and KLEE were built using the same "
     "compiler and linker flags (to prevent compatibility issues).\n"
     "To prevent CMake from reusing the target or to use a different version "
     "of Google Test, try either of the following:\n"
@@ -166,6 +166,8 @@ else()
   endif()
 endif()
 
+enable_testing()
+
 
 # This keeps track of all the unit test
 # targets so we can ensure they are built
@@ -199,7 +201,8 @@ endif()
 
 add_library(unittest_main)
 target_sources(unittest_main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp")
-klee_get_llvm_libs(UNITTEST_MAIN_LIBS Support)
+llvm_map_components_to_libnames(UNITTEST_MAIN_LIBS support)
+
 target_link_libraries(unittest_main
   PUBLIC
   ${GTEST_TARGET_NAME}
diff --git a/unittests/DiscretePDF/CMakeLists.txt b/unittests/DiscretePDF/CMakeLists.txt
index 07ec1f89..f3b23fc9 100644
--- a/unittests/DiscretePDF/CMakeLists.txt
+++ b/unittests/DiscretePDF/CMakeLists.txt
@@ -1,4 +1,8 @@
 add_klee_unit_test(DiscretePDFTest
   DiscretePDFTest.cpp)
 # FIXME add the following line to link against libgtest.a
-target_link_libraries(DiscretePDFTest PRIVATE kleaverSolver)
\ No newline at end of file
+target_link_libraries(DiscretePDFTest PRIVATE kleaverSolver)
+target_compile_options(DiscretePDFTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(DiscretePDFTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(DiscretePDFTest PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/unittests/Expr/CMakeLists.txt b/unittests/Expr/CMakeLists.txt
index 34bc5a01..56646715 100644
--- a/unittests/Expr/CMakeLists.txt
+++ b/unittests/Expr/CMakeLists.txt
@@ -2,3 +2,8 @@ add_klee_unit_test(ExprTest
   ExprTest.cpp
   ArrayExprTest.cpp)
 target_link_libraries(ExprTest PRIVATE kleaverExpr kleeSupport kleaverSolver)
+target_compile_options(ExprTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(ExprTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(ExprTest PRIVATE ${KLEE_INCLUDE_DIRS})
+
diff --git a/unittests/RNG/CMakeLists.txt b/unittests/RNG/CMakeLists.txt
index 866f9158..67363323 100644
--- a/unittests/RNG/CMakeLists.txt
+++ b/unittests/RNG/CMakeLists.txt
@@ -1,3 +1,7 @@
 add_klee_unit_test(RNGTest
   RNGTest.cpp)
 target_link_libraries(RNGTest PRIVATE kleeSupport)
+target_compile_options(RNGTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(RNGTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(RNGTest PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/unittests/Ref/CMakeLists.txt b/unittests/Ref/CMakeLists.txt
index facd26a3..f60927d8 100644
--- a/unittests/Ref/CMakeLists.txt
+++ b/unittests/Ref/CMakeLists.txt
@@ -1,3 +1,7 @@
 add_klee_unit_test(RefTest
   RefTest.cpp)
 target_link_libraries(RefTest PRIVATE kleaverExpr)
+target_compile_options(RefTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(RefTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(RefTest PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/unittests/Searcher/CMakeLists.txt b/unittests/Searcher/CMakeLists.txt
index 29358470..c35b407f 100644
--- a/unittests/Searcher/CMakeLists.txt
+++ b/unittests/Searcher/CMakeLists.txt
@@ -1,4 +1,8 @@
 add_klee_unit_test(SearcherTest
   SearcherTest.cpp)
 target_link_libraries(SearcherTest PRIVATE kleeCore)
-target_include_directories(SearcherTest BEFORE PUBLIC "../../lib")
+target_include_directories(SearcherTest BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/lib")
+target_compile_options(SearcherTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(SearcherTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+
+target_include_directories(SearcherTest PRIVATE ${KLEE_INCLUDE_DIRS})
\ No newline at end of file
diff --git a/unittests/Solver/CMakeLists.txt b/unittests/Solver/CMakeLists.txt
index c3dc63b6..c3cd357c 100644
--- a/unittests/Solver/CMakeLists.txt
+++ b/unittests/Solver/CMakeLists.txt
@@ -1,9 +1,16 @@
 add_klee_unit_test(SolverTest
   SolverTest.cpp)
 target_link_libraries(SolverTest PRIVATE kleaverSolver)
+target_compile_options(SolverTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(SolverTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+target_include_directories(SolverTest PRIVATE ${KLEE_INCLUDE_DIRS})
+
 
 if (${ENABLE_Z3})
   add_klee_unit_test(Z3SolverTest
     Z3SolverTest.cpp)
-target_link_libraries(Z3SolverTest PRIVATE kleaverSolver)
+  target_link_libraries(Z3SolverTest PRIVATE kleaverSolver)
+  target_compile_options(Z3SolverTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+  target_compile_definitions(Z3SolverTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+  target_include_directories(Z3SolverTest PRIVATE ${KLEE_INCLUDE_DIRS})
 endif()
diff --git a/unittests/Time/CMakeLists.txt b/unittests/Time/CMakeLists.txt
index 6a860582..0280a4bb 100644
--- a/unittests/Time/CMakeLists.txt
+++ b/unittests/Time/CMakeLists.txt
@@ -1,3 +1,6 @@
 add_klee_unit_test(TimeTest
   TimeTest.cpp)
 target_link_libraries(TimeTest PRIVATE kleeSupport)
+target_compile_options(TimeTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(TimeTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+target_include_directories(TimeTest PRIVATE ${KLEE_INCLUDE_DIRS})
diff --git a/unittests/TreeStream/CMakeLists.txt b/unittests/TreeStream/CMakeLists.txt
index ff9b4c3e..db9ef3db 100644
--- a/unittests/TreeStream/CMakeLists.txt
+++ b/unittests/TreeStream/CMakeLists.txt
@@ -1,3 +1,6 @@
 add_klee_unit_test(TreeStreamTest
   TreeStreamTest.cpp)
 target_link_libraries(TreeStreamTest PRIVATE kleeBasic kleeSupport)
+target_compile_options(TreeStreamTest PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
+target_compile_definitions(TreeStreamTest PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})
+target_include_directories(TreeStreamTest PRIVATE ${KLEE_INCLUDE_DIRS})