From 9e7be1a05b2a7d788946dd97e0bafd2c7c2a77fd Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 16 May 2022 09:45:41 -0400 Subject: [PATCH 1/6] Map CMake install components to conda library packages --- cpp/CMakeLists.txt | 80 ++++++++++++++--------------- cpp/cmake/modules/raft_export.cmake | 4 ++ 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 66811ae850..be268aef59 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -352,12 +352,12 @@ install(TARGETS raft install(TARGETS raft_distance DESTINATION ${lib_dir} - COMPONENT raft_distance + COMPONENT raft EXPORT raft-distance-exports) install(TARGETS raft_nn DESTINATION ${lib_dir} - COMPONENT raft_nn + COMPONENT raft EXPORT raft-nn-exports) if(TARGET raft_distance_lib) @@ -390,6 +390,44 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/raft/version_config.hpp COMPONENT raft DESTINATION include/raft) +############################################################################## +# - export/install optional components -------------------------------------- + +include("${rapids-cmake-dir}/export/write_dependencies.cmake") + +set(raft_components distance nn) +set(raft_install_comp "" "") +if(TARGET raft_distance_lib) + list(APPEND raft_components distance-lib) + list(APPEND raft_install_comp _distance) +endif() +if(TARGET raft_nn_lib) + list(APPEND raft_components nn-lib) + list(APPEND raft_install_comp _nn) +endif() + +foreach(comp install_comp IN ZIP_LISTS raft_components raft_install_comp) + install( + EXPORT raft-${comp}-exports + FILE raft-${comp}-targets.cmake + NAMESPACE raft:: + DESTINATION "${lib_dir}/cmake/raft" + COMPONENT raft${install_comp} + ) + 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/${install_comp}/raft-${comp}-dependencies.cmake" + ) + +endforeach() + ############################################################################## # - install export ----------------------------------------------------------- set(doc_string @@ -458,44 +496,6 @@ raft_export(BUILD raft NAMESPACE raft:: FINAL_CODE_BLOCK code_string) -############################################################################## -# - export/install optional components -------------------------------------- - -include("${rapids-cmake-dir}/export/write_dependencies.cmake") - -set(raft_components distance nn) -set(raft_install_comp distance nn) -if(TARGET raft_distance_lib) - list(APPEND raft_components distance-lib) - list(APPEND raft_install_comp distance) -endif() -if(TARGET raft_nn_lib) - list(APPEND raft_components nn-lib) - list(APPEND raft_install_comp nn) -endif() - -foreach(comp install_comp IN ZIP_LISTS raft_components raft_install_comp) - install( - EXPORT raft-${comp}-exports - FILE raft-${comp}-targets.cmake - NAMESPACE raft:: - DESTINATION "${lib_dir}/cmake/raft" - COMPONENT raft_${install_comp} - ) - 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/${install_comp}/raft-${comp}-dependencies.cmake" - ) - -endforeach() - ############################################################################## # - build test executable ---------------------------------------------------- diff --git a/cpp/cmake/modules/raft_export.cmake b/cpp/cmake/modules/raft_export.cmake index c7c81886e2..b9a8bc6170 100644 --- a/cpp/cmake/modules/raft_export.cmake +++ b/cpp/cmake/modules/raft_export.cmake @@ -210,6 +210,10 @@ function(raft_export type project_name) file(MAKE_DIRECTORY "${scratch_dir}") install(DIRECTORY "${scratch_dir}" DESTINATION "${install_location}" COMPONENT raft_${comp}) + if(EXISTS "${scratch_dir}/raft-${comp}-dependencies.cmake") + install(FILES "${scratch_dir}/raft-${comp}-dependencies.cmake" DESTINATION "${install_location}" + COMPONENT raft) + endif() endforeach() else() From a27fb6c6638ac7936a22143b031988d19260e9db Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 23 May 2022 15:08:42 -0400 Subject: [PATCH 2/6] move dependencies to nn-lib and distance-lib --- cpp/CMakeLists.txt | 11 +++++++---- cpp/cmake/thirdparty/get_cuco.cmake | 4 ++-- cpp/cmake/thirdparty/get_faiss.cmake | 9 ++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index be268aef59..9d81903b9f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -266,7 +266,10 @@ if(RAFT_COMPILE_DIST_LIBRARY) POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON) - target_link_libraries(raft_distance_lib PRIVATE raft::raft) + target_link_libraries(raft_distance_lib + PUBLIC raft::raft + cuco::cuco + ) target_compile_options(raft_distance_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" "$<$:${RAFT_CUDA_FLAGS}>" @@ -281,7 +284,6 @@ endif() target_link_libraries(raft_distance INTERFACE raft::raft - $<$:cuco::cuco> $ $ ) @@ -321,7 +323,9 @@ if(RAFT_COMPILE_NN_LIBRARY) POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON) - target_link_libraries(raft_nn_lib PUBLIC faiss::faiss PRIVATE raft::raft) + target_link_libraries(raft_nn_lib + PUBLIC faiss::faiss + raft::raft) target_compile_options(raft_nn_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" "$<$:${RAFT_CUDA_FLAGS}>" @@ -335,7 +339,6 @@ endif() target_link_libraries(raft_nn INTERFACE raft::raft - $<$:faiss::faiss> $ $) diff --git a/cpp/cmake/thirdparty/get_cuco.cmake b/cpp/cmake/thirdparty/get_cuco.cmake index c35db4c962..9b60839b81 100644 --- a/cpp/cmake/thirdparty/get_cuco.cmake +++ b/cpp/cmake/thirdparty/get_cuco.cmake @@ -18,8 +18,8 @@ function(find_and_configure_cuco VERSION) rapids_cpm_find(cuco ${VERSION} GLOBAL_TARGETS cuco::cuco - BUILD_EXPORT_SET raft-distance-exports - INSTALL_EXPORT_SET raft-distance-exports + BUILD_EXPORT_SET raft-distance-lib-exports + INSTALL_EXPORT_SET raft-distance-lib-exports CPM_ARGS GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git GIT_TAG 6ec8b6dcdeceea07ab4456d32461a05c18864411 diff --git a/cpp/cmake/thirdparty/get_faiss.cmake b/cpp/cmake/thirdparty/get_faiss.cmake index 0eb849775e..f61ba7014c 100644 --- a/cpp/cmake/thirdparty/get_faiss.cmake +++ b/cpp/cmake/thirdparty/get_faiss.cmake @@ -32,7 +32,6 @@ function(find_and_configure_faiss) rapids_cpm_find(faiss ${PKG_VERSION} GLOBAL_TARGETS faiss::faiss - INSTALL_EXPORT_SET raft-nn-exports CPM_ARGS GIT_REPOSITORY https://github.com/facebookresearch/faiss.git GIT_TAG ${PKG_PINNED_TAG} @@ -58,13 +57,13 @@ function(find_and_configure_faiss) endif() # 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 GLOBAL_TARGETS faiss::faiss faiss) - rapids_export_package(INSTALL faiss raft-nn-exports GLOBAL_TARGETS faiss::faiss faiss) + rapids_export_package(BUILD OpenMP raft-nn-lib-exports) # faiss uses openMP but doesn't export a need for it + rapids_export_package(BUILD faiss raft-nn-lib-exports GLOBAL_TARGETS faiss::faiss faiss) + rapids_export_package(INSTALL faiss raft-nn-lib-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") - rapids_export_find_package_root(BUILD faiss [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-nn-exports) + rapids_export_find_package_root(BUILD faiss [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-nn-lib-exports) endfunction() find_and_configure_faiss(VERSION 1.7.0 From 8befd208dfc94034af9d03b7e5bba366922b79ed Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 26 May 2022 08:43:54 -0400 Subject: [PATCH 3/6] Update cpp/CMakeLists.txt Co-authored-by: Vyas Ramasubramani --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9d81903b9f..95c1755b0d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -405,7 +405,7 @@ if(TARGET raft_distance_lib) list(APPEND raft_install_comp _distance) endif() if(TARGET raft_nn_lib) - list(APPEND raft_components nn-lib) + list(APPEND raft_components nn-lib) list(APPEND raft_install_comp _nn) endif() From 2c95382c3644da69ba2ea590611eed554b8aadf0 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 26 May 2022 09:49:27 -0400 Subject: [PATCH 4/6] refactor placement to remove need for an extra install command --- cpp/CMakeLists.txt | 6 +++--- cpp/cmake/modules/raft_export.cmake | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 95c1755b0d..268cabc5ed 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -399,14 +399,14 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/raft/version_config.hpp include("${rapids-cmake-dir}/export/write_dependencies.cmake") set(raft_components distance nn) -set(raft_install_comp "" "") +set(raft_install_comp raft raft) if(TARGET raft_distance_lib) list(APPEND raft_components distance-lib) - list(APPEND raft_install_comp _distance) + list(APPEND raft_install_comp distance) endif() if(TARGET raft_nn_lib) list(APPEND raft_components nn-lib) - list(APPEND raft_install_comp _nn) + list(APPEND raft_install_comp nn) endif() foreach(comp install_comp IN ZIP_LISTS raft_components raft_install_comp) diff --git a/cpp/cmake/modules/raft_export.cmake b/cpp/cmake/modules/raft_export.cmake index b9a8bc6170..c7c81886e2 100644 --- a/cpp/cmake/modules/raft_export.cmake +++ b/cpp/cmake/modules/raft_export.cmake @@ -210,10 +210,6 @@ function(raft_export type project_name) file(MAKE_DIRECTORY "${scratch_dir}") install(DIRECTORY "${scratch_dir}" DESTINATION "${install_location}" COMPONENT raft_${comp}) - if(EXISTS "${scratch_dir}/raft-${comp}-dependencies.cmake") - install(FILES "${scratch_dir}/raft-${comp}-dependencies.cmake" DESTINATION "${install_location}" - COMPONENT raft) - endif() endforeach() else() From a95f798e14626d878c586c95b012f9b74285977c Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 26 May 2022 12:23:32 -0400 Subject: [PATCH 5/6] Make cmake install component names consistent --- cpp/CMakeLists.txt | 6 +++--- cpp/cmake/modules/raft_export.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 268cabc5ed..9902bdded7 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -366,7 +366,7 @@ install(TARGETS raft_nn if(TARGET raft_distance_lib) install(TARGETS raft_distance_lib DESTINATION ${lib_dir} - COMPONENT raft_distance + COMPONENT distance EXPORT raft-distance-lib-exports) install(DIRECTORY include/raft_distance DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) @@ -375,7 +375,7 @@ endif() if(TARGET raft_nn_lib) install(TARGETS raft_nn_lib DESTINATION ${lib_dir} - COMPONENT raft_nn + COMPONENT nn EXPORT raft-nn-lib-exports) endif() @@ -415,7 +415,7 @@ foreach(comp install_comp IN ZIP_LISTS raft_components raft_install_comp) FILE raft-${comp}-targets.cmake NAMESPACE raft:: DESTINATION "${lib_dir}/cmake/raft" - COMPONENT raft${install_comp} + COMPONENT ${install_comp} ) export( EXPORT raft-${comp}-exports diff --git a/cpp/cmake/modules/raft_export.cmake b/cpp/cmake/modules/raft_export.cmake index c7c81886e2..748fa8ad26 100644 --- a/cpp/cmake/modules/raft_export.cmake +++ b/cpp/cmake/modules/raft_export.cmake @@ -209,7 +209,7 @@ function(raft_export type project_name) set(scratch_dir "${PROJECT_BINARY_DIR}/rapids-cmake/${project_name}/export/${comp}/") file(MAKE_DIRECTORY "${scratch_dir}") install(DIRECTORY "${scratch_dir}" DESTINATION "${install_location}" - COMPONENT raft_${comp}) + COMPONENT ${comp}) endforeach() else() From 158670536021b83245567df1658d73f8ec08bee6 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 27 May 2022 08:56:33 -0400 Subject: [PATCH 6/6] Correct failing tests --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 876ad5090a..54a93abe0b 100755 --- a/build.sh +++ b/build.sh @@ -166,6 +166,7 @@ fi if hasArg tests || (( ${NUMARGS} == 0 )); then BUILD_TESTS=ON ENABLE_NN_DEPENDENCIES=ON + COMPILE_NN_LIBRARY=ON CMAKE_TARGET="${CMAKE_TARGET};test_raft" fi