about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@comsys.rwth-aachen.de>2023-05-28 18:42:05 +0200
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2023-06-07 16:33:51 +0100
commitae1ee275c2268397fb843c4f9a7a04ce8030d1f0 (patch)
tree51f5fd50f46b13ff7125d92230eef8115ae863bb
parentae071d86b503a0a9cba987ff3635dca6e09184ed (diff)
downloadklee-ae1ee275c2268397fb843c4f9a7a04ce8030d1f0.tar.gz
unittests/CMakeLists.txt: fix LLVM find_package support
broken by 3ef5c9d0cd51babb7c4ec2d7bb76d0cb7e47a65c, which removed the
"USE_CMAKE_FIND_PACKAGE_LLVM" variable and no longer includes
AddLLVM.cmake
-rw-r--r--README-CMake.md4
-rw-r--r--unittests/CMakeLists.txt10
2 files changed, 8 insertions, 6 deletions
diff --git a/README-CMake.md b/README-CMake.md
index 9d7ad37d..23cb7a14 100644
--- a/README-CMake.md
+++ b/README-CMake.md
@@ -58,8 +58,8 @@ cmake -DCMAKE_BUILD_TYPE=Release /path/to/klee/src
 * `ENABLE_ZLIB` (BOOLEAN) - Enable zlib support.
 
 * `GTEST_SRC_DIR` (STRING) - Path to Google Test source tree. If it is not
-   specified and `USE_CMAKE_FIND_PACKAGE_LLVM` is used, CMake will try to reuse
-   the version included within the LLVM source tree.
+   specified, CMake will try to reuse the version included within the LLVM
+   source tree or find a system installation of Google Test.
 
 * `GTEST_INCLUDE_DIR` (STRING) - Path to Google Test include directory,
    if it is not under `GTEST_SRC_DIR`.
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index 2641b5b9..ca90aead 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -141,11 +141,8 @@ else()
   # LLVM's 'gtest' target is not reused
 
   if (NOT GTEST_SRC_DIR)
-    if (USE_CMAKE_FIND_PACKAGE_LLVM AND LLVM_BUILD_MAIN_SRC_DIR)
+    if (IS_DIRECTORY "${LLVM_BUILD_MAIN_SRC_DIR}")
       # build from LLVM's utils directory
-      # NOTE: This can only be done using USE_CMAKE_FIND_PACKAGE_LLVM as
-      #       LLVM replaced Google Test's CMakeLists.txt with its own,
-      #       requiring add_llvm_library() from AddLLVM.cmake.
       message(STATUS "Google Test: Building from LLVM's source tree.")
 
       set(GTEST_INCLUDE_DIR
@@ -155,6 +152,11 @@ else()
         "Path to Google Test include directory"
       )
 
+      # LLVM replaced Google Test's CMakeLists.txt with its own, which requires
+      # add_llvm_library() from AddLLVM.cmake.
+      list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
+      include(AddLLVM)
+
       add_subdirectory("${LLVM_BUILD_MAIN_SRC_DIR}/utils/unittest/"
         "${CMAKE_CURRENT_BINARY_DIR}/gtest_build")