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

Simplify raft component CMake logic, and allow compilation without FAISS #428

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
07644ec
add option to build faiss shared libs
trxcllnt Sep 30, 2021
f3e1f09
add FAISS::FAISS to the list of global targets
trxcllnt Sep 30, 2021
e038644
update cuco
trxcllnt Sep 30, 2021
3fa9c94
create a faissTargets export-set
trxcllnt Sep 30, 2021
fc132ef
Merge branch 'fix/build-shared-faiss' into fix/node-rapids-21.10
trxcllnt Sep 30, 2021
85572d0
add faiss to raft-exports
trxcllnt Sep 30, 2021
b19a4b6
revert
trxcllnt Sep 30, 2021
6c74570
Merge branch 'fix/build-shared-faiss' into fix/node-rapids-21.10
trxcllnt Sep 30, 2021
14785ff
create a faiss-exports export-set
trxcllnt Sep 30, 2021
25b62e6
mark faiss to be found as part of resolving raft-exports dependencies
trxcllnt Sep 30, 2021
76edf36
create faiss-exports export set
trxcllnt Sep 30, 2021
92851b3
create faiss-exports export set
trxcllnt Sep 30, 2021
8e266ef
export faiss::faiss target to build export set
trxcllnt Oct 5, 2021
9d535fb
Merge branch 'fix/node-rapids-21.10' into fix/build-shared-faiss
trxcllnt Oct 5, 2021
7c990b1
Merge branch 'branch-21.10' of github.com:rapidsai/raft into fix/buil…
trxcllnt Oct 5, 2021
3a20c64
Merge branch 'branch-21.12' of github.com:rapidsai/raft into fix/buil…
trxcllnt Oct 5, 2021
83e3aa6
fix faiss GLOBAL_TARGETS
trxcllnt Oct 6, 2021
2773edc
update rapids-cmake version
trxcllnt Oct 6, 2021
3ff1c4d
fix naming for generated Findfaiss.cmake module so we find conda-inst…
trxcllnt Oct 6, 2021
cbb6f2d
ensure faiss::faiss target is available in build and install export sets
trxcllnt Oct 7, 2021
713a872
add gtest to raft-exports, remove dead code
trxcllnt Oct 7, 2021
ceb4d8b
update CMake faiss variable name
trxcllnt Oct 12, 2021
1d3ffab
make -v set cmake --log-level=VERBOSE
trxcllnt Oct 12, 2021
b48e393
update cuco hash to the commit that uses rapids-cmake v21.12
trxcllnt Oct 13, 2021
dc076ae
Merge branch 'branch-21.12' of github.com:rapidsai/raft into fix/buil…
trxcllnt Oct 14, 2021
e824384
Merge branch 'branch-21.12' of github.com:rapidsai/raft into fix/buil…
trxcllnt Nov 10, 2021
078e33c
Merge branch 'branch-21.12' of github.com:rapidsai/raft into fix/buil…
trxcllnt Nov 11, 2021
30dafb6
Merge branch 'branch-22.02' of github.com:rapidsai/raft into fix/buil…
trxcllnt Nov 18, 2021
aedc6d7
update cuco version
trxcllnt Nov 19, 2021
245ea3d
Merge branch 'branch-22.02' of github.com:rapidsai/raft into fix/buil…
trxcllnt Nov 20, 2021
2b99f1a
Merge branch 'branch-22.02' of github.com:rapidsai/raft into fix/buil…
trxcllnt Dec 1, 2021
bb4b7c7
move faiss into separate raft-faiss-exports export set, only include …
trxcllnt Dec 1, 2021
e798ab1
check for faiss in raft_FIND_COMPONENTS for build side export set too
trxcllnt Dec 2, 2021
2d5898d
pass EXCLUDE_FROM_ALL in get_faiss.cmake
trxcllnt Dec 2, 2021
2cb3c3a
enable CUDA language in code_string
trxcllnt Dec 2, 2021
23912f5
pass TRUE
trxcllnt Dec 2, 2021
fc306f6
drop CUDA from the list of global languages
trxcllnt Dec 2, 2021
61c263a
link raft to faiss if faiss component is requested
trxcllnt Dec 2, 2021
41bd51b
link raft to faiss if faiss component requested
trxcllnt Dec 8, 2021
4a95f2e
Merge branch 'branch-22.02' of github.com:rapidsai/raft into fix/buil…
trxcllnt Dec 15, 2021
082eea9
Merge branch 'branch-22.02' of github.com:rapidsai/raft into fix/buil…
trxcllnt Dec 16, 2021
ce8a005
fix FAISS::FAISS -> faiss::faiss
trxcllnt Dec 16, 2021
c39685a
Simplify raft component CMake logic, and allow compilation without FAISS
robertmaynard Dec 20, 2021
af46a09
Add RAFT_ENABLE_NN_COMPONENT CMake build option
robertmaynard Dec 20, 2021
1e9b9bd
Adding option to turn off buildign all shared libs
cjnolet Dec 20, 2021
7fc712c
Refactor get_faiss to export faiss::faiss build target
trxcllnt Dec 20, 2021
a85b085
RAFT_ENABLE_NN_COMPONENT is a dependent option of RAFT_BUILD_SHARED_LIBS
robertmaynard Dec 20, 2021
260a727
Using lowercase faiss target
cjnolet Dec 20, 2021
bb4a7f3
Changing RAFT_BUILD_SHARED_LIBS -> RAFT_COMPILE_LIBRARIES
cjnolet Dec 20, 2021
8c02d2c
Passing deps transitively
cjnolet Dec 21, 2021
ebb7c1d
Moving faiss back to test target. We need to figure out how to pass
cjnolet Dec 21, 2021
c1e9c2d
Another round of cmake cleanups
robertmaynard Dec 22, 2021
fef8446
Merge "Add option to build faiss shared libs" into refactor_cmake_raf…
robertmaynard Dec 22, 2021
52e8635
Refactor again now that I understand the libs are an optimization
robertmaynard Dec 22, 2021
293302f
Move `nn` and `distance` to CMake components
robertmaynard Jan 4, 2022
61e5b3c
Make searching for faiss a controllable option
robertmaynard Jan 6, 2022
3701daf
Merge branch 'branch-22.02' into refactor_cmake_raft_target_logic
robertmaynard Jan 6, 2022
60c81a7
fix typo
trxcllnt Jan 13, 2022
55301e7
Merge branch 'branch-22.02' of github.com:rapidsai/raft into refactor…
trxcllnt Jan 13, 2022
d20e5ef
add GTest targets to install side of raft-exports export set
trxcllnt Jan 14, 2022
1594f7f
install gtest if not already installed
trxcllnt Jan 14, 2022
1c74204
revert get_gtest.cmake changes
trxcllnt Jan 14, 2022
0bc750b
remove raft_ prefix from global targets list
trxcllnt Jan 17, 2022
a3c0370
revert previous change, move target_link_libraries below add_library …
trxcllnt Jan 17, 2022
ea209c1
fix _lib name to add prefix
trxcllnt Jan 18, 2022
7093ad5
add missing PKG_ prefix
trxcllnt Jan 18, 2022
f613e39
guard creating alias targets when added as a submodule via CPM
trxcllnt Jan 18, 2022
b2e0b01
update cuco hash
trxcllnt Jan 19, 2022
ad90d9b
Merge branch 'branch-22.02' of github.com:rapidsai/raft into refactor…
trxcllnt Jan 19, 2022
902657c
Replace the use of RMM's CUDA Python bindings with those from CUDA-Py…
shwina Jan 19, 2022
d7f0074
Add cuda-python to dev env
shwina Jan 19, 2022
c7666ad
Remove older comment about cudaStream_t attribute
shwina Jan 19, 2022
8446e2f
Style
shwina Jan 19, 2022
4de51ed
0 -> cudaSuccess
shwina Jan 19, 2022
9d1bdc5
Add raft_export while rapids-cmake adds a export(COMPONENT) feature
robertmaynard Jan 19, 2022
4f2d14b
Merge remote-tracking branch 'ashwin/replace-rmm-cuda-python-bindings…
cjnolet Jan 19, 2022
1a2c611
raft_export marks components as found
robertmaynard Jan 19, 2022
14f1937
add unprefixed raft_distance_lib and raft_nn_lib to handle both BUILD…
trxcllnt Jan 20, 2022
2d2b23a
Merge branch 'branch-22.02' of github.com:rapidsai/raft into refactor…
trxcllnt Jan 20, 2022
cb69067
add versions.json to force Thrust v1.15.0
trxcllnt Jan 21, 2022
47bbfd0
Using cuco branch w/ thrust 1.15
cjnolet Jan 21, 2022
2685783
Reordering cuco and rmm cmake includes
cjnolet Jan 21, 2022
2aa4ea9
Reverting previous changes
cjnolet Jan 21, 2022
c51fc3e
add get_thrust.cmake back in to ensure we get Thrust v1.15.0
trxcllnt Jan 21, 2022
93ed2c7
Merge branch 'refactor_cmake_raft_target_logic' of github.com:robertm…
trxcllnt Jan 21, 2022
5670308
revert cuco dependency hash
trxcllnt Jan 21, 2022
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
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ PYTHON_DEPS_CLONE=${REPODIR}/python/external_repositories
BUILD_DIRS="${CPP_RAFT_BUILD_DIR} ${PY_RAFT_BUILD_DIR} ${PYTHON_DEPS_CLONE}"

# Set defaults for vars modified by flags to this script
CMAKE_LOG_LEVEL=""
VERBOSE_FLAG=""
BUILD_ALL_GPU_ARCH=0
BUILD_GTEST=OFF
Expand Down Expand Up @@ -84,6 +85,7 @@ fi
# Process flags
if hasArg -v; then
VERBOSE_FLAG=-v
CMAKE_LOG_LEVEL="--log-level=VERBOSE"
set -x
fi
if hasArg -g; then
Expand Down Expand Up @@ -147,13 +149,13 @@ if (( ${NUMARGS} == 0 )) || hasArg cppraft; then
echo "Building for *ALL* supported GPU architectures..."
fi

cmake -S ${REPODIR}/cpp -B ${CPP_RAFT_BUILD_DIR} \
cmake -S ${REPODIR}/cpp -B ${CPP_RAFT_BUILD_DIR} ${CMAKE_LOG_LEVEL} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${RAFT_CMAKE_CUDA_ARCHITECTURES} \
-DNVTX=${NVTX} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DBUILD_GTEST=${BUILD_GTEST} \
-DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS}
-DRAFT_USE_FAISS_STATIC=${BUILD_STATIC_FAISS}


# Run all c++ targets at once
Expand Down
240 changes: 177 additions & 63 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ option(DISABLE_DEPRECATION_WARNINGS "Disable depreaction warnings " ON)
option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(NVTX "Enable nvtx markers" OFF)

option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ON)
option(RAFT_ENABLE_NN_DEPENDENCIES "Search for raft::nn dependencies like faiss" ${RAFT_COMPILE_LIBRARIES})
include(CMakeDependentOption)
cmake_dependent_option(RAFT_USE_FAISS_STATIC "Build and statically link the FAISS library for nearest neighbors search on GPU" ON RAFT_COMPILE_LIBRARIES OFF)
Copy link
Member

Choose a reason for hiding this comment

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

I opened a PR w/ cuml to integrate the changes in this PR but it looks like it's trying to build FAISS from source every time now, rather than using the shared lib that's already installed w/ conda.

I also tried removing the explicit call to get_faiss and linking of the FAISS::FAISS targets in cuml but it didn't seem to make a difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your PR doesn't change the version of RAFT it is using to this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good catch. I've been building locally w/ CPM_raft_SOURCE, though. Let me update the PR as well.

Copy link
Member

Choose a reason for hiding this comment

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

Here it looks like it's building FAISS from source in CI in cuml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR changes the name of the searched package to faiss ( lowercase ) to follow modern CMake patterns, while your cuml PR keeps the existing behavior of using FAISS.

This for CPM means they are distinctly different projects. When we look at the build logs we see the following:

-- CPM: using local package [email protected]
-- CPM: raft: adding package [email protected] (bde7c0027191f29c9dadafe4f6e68ca0ee31fb30)

So we can see that FAISS was found locally, and faiss is going to be built from source.
In general we wouldn't expect RAFT search again for faiss but given the mismatch on names it does so.

As for why RAFT is building faiss from source, the cuml get_raft.cmake project file currently enables CPM_DOWNLOAD_ALL which forces raft and all dependencies to be built from source and not search for a local copy.

So what can you do?

  1. Update cuml to search for faiss instead of FAISS
  2. Don't have get_raft in cuml always trying to build raft from source. Since this will also stop the benifits of raft::nn and raft::distance

Copy link
Member

@cjnolet cjnolet Jan 11, 2022

Choose a reason for hiding this comment

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

I've verified (at least locally) that changing the faiss target (and GLOBAL_TARGETS for faiss to faiss::faiss) works when both with and without CPM_raft_SOURCE.

We're working towards item number 2. conda packaging will make that much easier to implement and maintain.

Thanks again, @robertmaynard!


message(VERBOSE "RAFT: Build RAFT unit-tests: ${BUILD_TESTS}")
message(VERBOSE "RAFT: Enable detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "RAFT: Disable depreaction warnings " ${DISABLE_DEPRECATION_WARNINGS})
Expand Down Expand Up @@ -100,96 +105,143 @@ endif()
# add third party dependencies using CPM
rapids_cpm_init()

# thrust and libcudacxx need to be before cuco!
# thrust before rmm/cuco so we get the right version of thrust/cub
include(cmake/thirdparty/get_thrust.cmake)
include(cmake/thirdparty/get_rmm.cmake)
include(cmake/thirdparty/get_libcudacxx.cmake)
include(cmake/thirdparty/get_cuco.cmake)
include(cmake/thirdparty/get_libcudacxx.cmake)
include(cmake/thirdparty/get_faiss.cmake)
cjnolet marked this conversation as resolved.
Show resolved Hide resolved

if(BUILD_TESTS)
include(cmake/thirdparty/get_faiss.cmake)
include(cmake/thirdparty/get_gtest.cmake)
include(cmake/thirdparty/get_nccl.cmake)
include(cmake/thirdparty/get_ucx.cmake)
endif()

##############################################################################
# - install targets-----------------------------------------------------------
rapids_cmake_install_lib_dir( lib_dir )

include(CPack)

file(GLOB_RECURSE RAFT_DISTANCE_SOURCES "src/distance/specializations/*.cu")
file(GLOB_RECURSE RAFT_NN_SOURCES "src/nn/specializations/*.cu" )

add_library(raft_distance SHARED ${RAFT_DISTANCE_SOURCES})
add_library(raft::raft_distance ALIAS raft_distance)

add_library(raft_nn SHARED ${RAFT_NN_SOURCES})
add_library(raft::raft_nn ALIAS raft_nn)
# - raft ---------------------------------------------------------------------

add_library(raft INTERFACE)
add_library(raft::raft ALIAS raft)
target_include_directories(raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

target_include_directories(raft_distance PUBLIC "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
target_include_directories(raft INTERFACE
"$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

target_include_directories(raft_nn PUBLIC "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(raft INTERFACE
raft::Thrust
CUDA::cublas
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
$<$<BOOL:${NVTX}>:CUDA::nvToolsExt>
rmm::rmm
cuco::cuco)

target_compile_definitions(raft INTERFACE $<$<BOOL:${NVTX}>:NVTX_ENABLED>)
target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)

set(RAFT_LINK_LIBRARIES
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
$<$<BOOL:${NVTX}>:CUDA::nvToolsExt>
rmm::rmm
cuco::cuco
)
##############################################################################
# - raft_distance ------------------------------------------------------------
add_library(raft_distance INTERFACE)

target_link_libraries(raft INTERFACE ${RAFT_LINK_LIBRARIES})
target_link_libraries(raft_distance PUBLIC ${RAFT_LINK_LIBRARIES})
target_link_libraries(raft_nn PUBLIC ${RAFT_LINK_LIBRARIES} FAISS::FAISS)
if(TARGET raft_distance AND (NOT TARGET raft::distance))
add_library(raft::distance ALIAS raft_distance)
endif()

set(RAFT_COMPILE_DEFINITIONS
$<$<BOOL:${NVTX}>:NVTX_ENABLED>
)
set_target_properties(raft_distance PROPERTIES EXPORT_NAME distance)

if(RAFT_COMPILE_LIBRARIES)
add_library(raft_distance_lib SHARED
src/distance/specializations/detail
src/distance/specializations/detail/canberra.cu
src/distance/specializations/detail/chebyshev.cu
src/distance/specializations/detail/correlation.cu
src/distance/specializations/detail/cosine.cu
src/distance/specializations/detail/hamming_unexpanded.cu
src/distance/specializations/detail/hellinger_expanded.cu
src/distance/specializations/detail/jensen_shannon.cu
src/distance/specializations/detail/kl_divergence.cu
src/distance/specializations/detail/l1.cu
src/distance/specializations/detail/l2_expanded.cu
src/distance/specializations/detail/l2_sqrt_expanded.cu
src/distance/specializations/detail/l2_sqrt_unexpanded.cu
src/distance/specializations/detail/l2_unexpanded.cu
src/distance/specializations/detail/lp_unexpanded.cu
)
set_target_properties(raft_distance_lib PROPERTIES OUTPUT_NAME raft_distance)

target_link_libraries(raft_distance_lib PRIVATE raft::raft)
target_compile_options(raft_distance_lib
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)
target_compile_definitions(raft_distance_lib
INTERFACE "RAFT_DISTANCE_COMPILED")

install(TARGETS raft_distance_lib
DESTINATION ${lib_dir}
EXPORT raft-distance-exports)
endif()

target_compile_definitions(raft INTERFACE ${RAFT_COMPILE_DEFINITIONS})
target_compile_definitions(raft_distance PRIVATE ${RAFT_COMPILE_DEFINITIONS})
target_compile_definitions(raft_nn PRIVATE ${RAFT_COMPILE_DEFINITIONS})
target_link_libraries(raft_distance INTERFACE raft::raft
$<TARGET_NAME_IF_EXISTS:raft_distance_lib>
$<TARGET_NAME_IF_EXISTS:raft::raft_distance_lib>)

target_compile_options(raft_distance
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)
##############################################################################
# - raft_nn ------------------------------------------------------------------
add_library(raft_nn INTERFACE)

if(TARGET raft_nn AND (NOT TARGET raft::nn))
add_library(raft::nn ALIAS raft_nn)
endif()

target_compile_options(raft_nn
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)
set_target_properties(raft_nn PROPERTIES EXPORT_NAME nn)

if(RAFT_COMPILE_LIBRARIES)
add_library(raft_nn_lib SHARED
src/nn/specializations/ball_cover.cu
src/nn/specializations/detail/ball_cover_lowdim.cu
src/nn/specializations/fused_l2_knn.cu
src/nn/specializations/knn.cu
)
set_target_properties(raft_nn_lib PROPERTIES OUTPUT_NAME raft_nn)

target_link_libraries(raft_nn_lib PRIVATE raft::raft faiss::faiss)
target_compile_options(raft_nn_lib
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)
target_compile_definitions(raft_nn_lib
INTERFACE "RAFT_NN_COMPILED")

install(TARGETS raft_nn_lib
DESTINATION ${lib_dir}
EXPORT raft-nn-exports)
endif()

target_compile_features(raft_distance PUBLIC cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_features(raft_nn PUBLIC cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_link_libraries(raft_nn INTERFACE raft::raft faiss::faiss
$<TARGET_NAME_IF_EXISTS:raft_nn_lib>
$<TARGET_NAME_IF_EXISTS:raft::raft_nn_lib>)

install(TARGETS raft_distance
##############################################################################
# - install targets-----------------------------------------------------------
rapids_cmake_install_lib_dir( lib_dir )
include(GNUInstallDirs)
include(CPack)

install(TARGETS raft
DESTINATION ${lib_dir}
EXPORT raft-exports)

install(TARGETS raft_distance
DESTINATION ${lib_dir}
EXPORT raft-distance-exports)
install(TARGETS raft_nn
DESTINATION ${lib_dir}
EXPORT raft-exports)
EXPORT raft-nn-exports)

install(TARGETS raft
DESTINATION ${lib_dir}
EXPORT raft-exports)

include(GNUInstallDirs)
install(DIRECTORY include/raft/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/raft
)
Expand All @@ -207,26 +259,88 @@ Provide targets for the RAFT: RAPIDS Analytics Framework Toolkit.
RAPIDS Analytics Framework Toolkit contains shared representations,
mathematical computational primitives, and utilities that accelerate
building analytics and data science algorithms in the RAPIDS ecosystem.

Optional Components:
- nn
- distance

Imported Targets:
- raft::raft
- raft::nn brought in by the `nn` optional component
- raft::distance brought in by the `distance` optional component

]=])

rapids_export(INSTALL raft
set(code_string
[=[
thrust_create_target(raft::Thrust FROM_OPTIONS)

if(distance IN_LIST raft_FIND_COMPONENTS)
enable_language(CUDA)
endif()

if(nn IN_LIST raft_FIND_COMPONENTS)
enable_language(CUDA)

if(TARGET faiss AND (NOT TARGET faiss::faiss))
add_library(faiss::faiss ALIAS faiss)
elseif(TARGET faiss::faiss AND (NOT TARGET faiss))
add_library(faiss ALIAS faiss::faiss)
endif()
endif()
]=]
)

# Use `rapids_export` for 22.04 as it will have COMPONENT support
include(cmake/modules/raft_export.cmake)
raft_export(INSTALL raft
EXPORT_SET raft-exports
GLOBAL_TARGETS raft raft_distance# since we can't hook into EXPORT SETS
COMPONENTS nn distance
GLOBAL_TARGETS raft nn distance
NAMESPACE raft::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
)

##############################################################################
# - build export -------------------------------------------------------------

rapids_export(BUILD raft
raft_export(BUILD raft
EXPORT_SET raft-exports
GLOBAL_TARGETS raft raft_distance raft_nn# since we can't hook into EXPORT SETS
LANGUAGES CUDA
COMPONENTS nn distance
GLOBAL_TARGETS raft raft_distance raft_nn
DOCUMENTATION doc_string
NAMESPACE raft::
FINAL_CODE_BLOCK code_string
)

##############################################################################
# - export/install optional components --------------------------------------

include("${rapids-cmake-dir}/export/write_dependencies.cmake")

set(raft_components distance nn)
foreach(comp IN LISTS raft_components)
install(
EXPORT raft-${comp}-exports
FILE raft-${comp}-targets.cmake
NAMESPACE raft::
DESTINATION "${lib_dir}/cmake/raft"
)
export(
EXPORT raft-${comp}-exports
FILE ${RAFT_BINARY_DIR}/raft-${comp}-targets.cmake
NAMESPACE raft::
)
rapids_export_write_dependencies(
BUILD raft-${comp}-exports "${PROJECT_BINARY_DIR}/raft-${comp}-dependencies.cmake"
)
rapids_export_write_dependencies(
INSTALL raft-${comp}-exports "${PROJECT_BINARY_DIR}/rapids-cmake/raft/export/raft-${comp}-dependencies.cmake"
)

endforeach()

##############################################################################
# - build test executable ----------------------------------------------------

Expand Down
Loading