From ae1ee275c2268397fb843c4f9a7a04ce8030d1f0 Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Sun, 28 May 2023 18:42:05 +0200 Subject: 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 --- README-CMake.md | 4 ++-- unittests/CMakeLists.txt | 10 ++++++---- 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") -- cgit 1.4.1