Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cmake's find_package to link to GTest #3278

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,12 @@ if(FAISS_OPT_LEVEL STREQUAL "avx512")
target_link_libraries(faiss_test PRIVATE faiss_avx512)
endif()

include(FetchContent)
FetchContent_Declare(googletest
URL "https://github.com/google/googletest/archive/release-1.12.1.tar.gz")
set(BUILD_GMOCK CACHE BOOL OFF)
set(INSTALL_GTEST CACHE BOOL OFF)
FetchContent_MakeAvailable(googletest)

find_package(OpenMP REQUIRED)
find_package(GTest CONFIG REQUIRED)

target_link_libraries(faiss_test PRIVATE
OpenMP::OpenMP_CXX
gtest_main
GTest::gtest_main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaks cmake

cmake . -B build   -DFAISS_ENABLE_GPU=OFF   -DBLA_VENDOR=OpenBLAS   -DFAISS_ENABLE_PYTHON=OFF   -DBUILD_TESTING=ON   -DBUILD_SHARED_LIBS=ON -DBLAS_LIBRARIES=/home/ckerchner/install/lib/libopenblas.so -DLAPACK_LIBRARIES=/home/ckerchner/install/lib/libopenblas.so
-- The CXX compiler identification is IBMClang 17.1.2.3
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/IBM/openxlC/17.1.2/bin/ibm-clang++_r - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_CXX: -openmp
-- Found OpenMP: TRUE
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Could NOT find MKL (missing: MKL_LIBRARIES)
-- Found BLAS: /home/ckerchner/install/lib/libopenblas.so
-- Found LAPACK: /home/ckerchner/install/lib/libopenblas.so
CMake Error at tests/CMakeLists.txt:63 (find_package):
  Could not find a package configuration file provided by "GTest" with any of
  the following names:

    GTestConfig.cmake
    gtest-config.cmake

  Add the installation prefix of "GTest" to CMAKE_PREFIX_PATH or set
  "GTest_DIR" to a directory containing one of the above files.  If "GTest"
  provides a separate development package or SDK, be sure it has been
  installed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::raft>
)

Expand Down