Skip to content

Commit

Permalink
We need to enable the c_api by default (#416)
Browse files Browse the repository at this point in the history
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: #416
  • Loading branch information
robertmaynard authored Oct 17, 2024
1 parent c86e74d commit f708fe3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
18 changes: 4 additions & 14 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
38 changes: 29 additions & 9 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "$<BUILD_INTERFACE:${CUVS_BINARY_DIR}/gtests>"
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)

0 comments on commit f708fe3

Please sign in to comment.