From f708fe388ee206105fd7894388283995e88ab7f9 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 17 Oct 2024 14:13:24 -0400 Subject: [PATCH] We need to enable the c_api by default (#416) Remove a collection of unneccesarily complex CMake logic. Major change is that we explicitly opt-in to building the C API bindings by default since it is a hard requirement for our python bindings, and the project has numerous conditions to disable it. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Ben Frederickson (https://github.com/benfred) URL: https://github.com/rapidsai/cuvs/pull/416 --- cpp/CMakeLists.txt | 18 ++++-------------- cpp/test/CMakeLists.txt | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3e98a247e..746245791 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -53,8 +53,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(BUILD_SHARED_LIBS "Build cuvs shared libraries" ON) option(BUILD_TESTS "Build cuvs unit-tests" ON) -option(BUILD_C_LIBRARY "Build cuVS C API library" OFF) -option(BUILD_C_TESTS "Build cuVS C API tests" OFF) +option(BUILD_C_LIBRARY "Build cuVS C API library" ON) option(BUILD_CUVS_BENCH "Build cuVS ann benchmarks" OFF) option(BUILD_CAGRA_HNSWLIB "Build CAGRA+hnswlib interface" ON) option(BUILD_MG_ALGOS "Build with multi-GPU support" ON) @@ -72,21 +71,12 @@ option(DISABLE_OPENMP "Disable OpenMP" OFF) option(CUVS_NVTX "Enable nvtx markers" OFF) option(CUVS_RAFT_CLONE_ON_PIN "Explicitly clone RAFT branch when pinned to non-feature branch" ON) -if((BUILD_TESTS OR BUILD_C_LIBRARY) AND NOT BUILD_CPU_ONLY) - -endif() - if(BUILD_CPU_ONLY) set(BUILD_SHARED_LIBS OFF) set(BUILD_TESTS OFF) set(BUILD_C_LIBRARY OFF) -endif() - -if(NOT BUILD_C_LIBRARY) - set(BUILD_C_TESTS OFF) -endif() - -if(NOT BUILD_SHARED_LIBS) + set(BUILD_CAGRA_HNSWLIB OFF) +elseif(NOT BUILD_SHARED_LIBS) set(BUILD_TESTS OFF) set(BUILD_C_LIBRARY OFF) set(BUILD_CAGRA_HNSWLIB OFF) @@ -771,7 +761,7 @@ endif() # ################################################################################################## # * build test executable ---------------------------------------------------- -if(BUILD_TESTS OR BUILD_C_TESTS) +if(BUILD_TESTS) add_subdirectory(internal) add_subdirectory(test) endif() diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index f4d35e438..60007825c 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -215,7 +215,9 @@ if(BUILD_TESTS) ) endif() -if(BUILD_C_TESTS) +if(TARGET cuvs::c_api) + enable_language(C) + ConfigureTest(NAME INTEROP_TEST PATH core/interop.cu C_LIB) ConfigureTest( NAME DISTANCE_C_TEST PATH distance/run_pairwise_distance_c.c distance/pairwise_distance_c.cu @@ -239,19 +241,37 @@ if(BUILD_C_TESTS) target_link_libraries(NEIGHBORS_HNSW_TEST PRIVATE hnswlib::hnswlib) target_compile_definitions(NEIGHBORS_HNSW_TEST PUBLIC CUVS_BUILD_CAGRA_HNSWLIB) endif() -endif() -# ################################################################################################## -# Install tests #################################################################################### -# ################################################################################################## -rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/libcuvs) - -if(BUILD_C_TESTS) - enable_language(C) add_executable(cuvs_c_test core/c_api.c) target_link_libraries(cuvs_c_test PUBLIC cuvs::c_api) add_executable(cuvs_c_neighbors_test neighbors/c_api.c) target_link_libraries(cuvs_c_neighbors_test PUBLIC cuvs::c_api) + + set_target_properties( + cuvs_c_test cuvs_c_neighbors_test + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$" + INSTALL_RPATH "\$ORIGIN/../../../lib" + ) + + rapids_test_add( + NAME cuvs_c_test + COMMAND cuvs_c_test + GPUS 1 + PERCENT 100 + INSTALL_COMPONENT_SET testing + ) + rapids_test_add( + NAME cuvs_c_neighbors_test + COMMAND cuvs_c_neighbors_test + GPUS 1 + PERCENT 100 + INSTALL_COMPONENT_SET testing + ) endif() + +# ################################################################################################## +# Install tests #################################################################################### +# ################################################################################################## +rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/libcuvs)