about summary refs log tree commit diff homepage
path: root/unittests
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 /unittests
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
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CMakeLists.txt10
1 files changed, 6 insertions, 4 deletions
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")