Skip to content

Commit

Permalink
raft-config is idempotent no matter RAFT_COMPILE_LIBRARIES value (#516)
Browse files Browse the repository at this point in the history
This allows us to correctly handle raft with and without compiled libraries.

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #516
  • Loading branch information
robertmaynard authored Feb 18, 2022
1 parent 1409002 commit 98d60db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ install(TARGETS raft_nn
if(TARGET raft_distance_lib)
install(TARGETS raft_distance_lib
DESTINATION ${lib_dir}
EXPORT raft-distance-exports)
EXPORT raft-distance-lib-exports)
endif()

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


Expand Down Expand Up @@ -364,6 +364,12 @@ raft_export(BUILD raft
include("${rapids-cmake-dir}/export/write_dependencies.cmake")

set(raft_components distance nn)
if(TARGET raft_distance_lib)
list(APPEND raft_components distance-lib)
endif()
if(TARGET raft_nn_lib)
list(APPEND raft_components nn-lib)
endif()
foreach(comp IN LISTS raft_components)
install(
EXPORT raft-${comp}-exports
Expand Down
5 changes: 4 additions & 1 deletion cpp/cmake/modules/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ foreach(lang IN LISTS rapids_global_languages)
endforeach()
unset(rapids_global_languages)

set(rapids_allowed_components @RAPIDS_COMPONENTS@)
set(rapids_base_components @RAPIDS_COMPONENTS@)
set(rapids_allowed_components ${rapids_base_components})

if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Expand All @@ -50,6 +51,7 @@ foreach(comp IN LISTS rapids_allowed_components)
# this way if a dependency can't be found we fail
if(${comp} IN_LIST @project_name@_FIND_COMPONENTS)
include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}-dependencies.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}-lib-dependencies.cmake" OPTIONAL)
endif()
endforeach()

Expand All @@ -58,6 +60,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]" OPTIONAL)
foreach(comp IN LISTS rapids_allowed_components)
if(${comp} IN_LIST @project_name@_FIND_COMPONENTS)
include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}-targets.cmake" OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-${comp}-lib-targets.cmake" OPTIONAL)
set(@project_name@_${comp}_FOUND TRUE)
endif()
endforeach()
Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/thirdparty/get_faiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function(find_and_configure_faiss)

# We generate the faiss-config files when we built faiss locally, so always do `find_dependency`
rapids_export_package(BUILD OpenMP raft-nn-exports) # faiss uses openMP but doesn't export a need for it
rapids_export_package(BUILD faiss raft-nn-exports)
rapids_export_package(INSTALL faiss raft-nn-exports)
rapids_export_package(BUILD faiss raft-nn-exports GLOBAL_TARGETS faiss::faiss faiss)
rapids_export_package(INSTALL faiss raft-nn-exports GLOBAL_TARGETS faiss::faiss faiss)

# Tell cmake where it can find the generated faiss-config.cmake we wrote.
include("${rapids-cmake-dir}/export/find_package_root.cmake")
Expand Down

0 comments on commit 98d60db

Please sign in to comment.