From 768fe879aff021fbefc6089a11e1f32d9aabedbb Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 18 Feb 2022 14:25:37 -0500 Subject: [PATCH 1/2] raft-config is idempotent no matter RAFT_COMPILE_LIBRARIES value This allows us to correctly handle raft with and without compiled libraries. --- cpp/CMakeLists.txt | 12 +++++++++--- cpp/cmake/modules/config.cmake.in | 5 ++++- cpp/cmake/thirdparty/get_faiss.cmake | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ea0ef2c2f1..7d0ca15985 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -267,7 +267,7 @@ install(TARGETS raft DESTINATION ${lib_dir} EXPORT raft-exports) install(TARGETS raft_distance - DESTINATION ${lib_dir} + DESTINATION $lib_dir} EXPORT raft-distance-exports) install(TARGETS raft_nn DESTINATION ${lib_dir} @@ -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() @@ -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 diff --git a/cpp/cmake/modules/config.cmake.in b/cpp/cmake/modules/config.cmake.in index bfafe3555a..4895a3baac 100644 --- a/cpp/cmake/modules/config.cmake.in +++ b/cpp/cmake/modules/config.cmake.in @@ -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}/@project_name@-dependencies.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-dependencies.cmake") @@ -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() @@ -58,6 +60,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/@project_name@-targets.cmake" 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() diff --git a/cpp/cmake/thirdparty/get_faiss.cmake b/cpp/cmake/thirdparty/get_faiss.cmake index 1079db3294..8c29d2b321 100644 --- a/cpp/cmake/thirdparty/get_faiss.cmake +++ b/cpp/cmake/thirdparty/get_faiss.cmake @@ -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") From 4313dc6238004c6ee6241dd048b3e8cdff2db678 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 18 Feb 2022 14:58:48 -0500 Subject: [PATCH 2/2] Correct typo --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7d0ca15985..118a48525a 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -267,7 +267,7 @@ install(TARGETS raft DESTINATION ${lib_dir} EXPORT raft-exports) install(TARGETS raft_distance - DESTINATION $lib_dir} + DESTINATION ${lib_dir} EXPORT raft-distance-exports) install(TARGETS raft_nn DESTINATION ${lib_dir}