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 diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 66811ae850..9902bdded7 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> $ $) @@ -352,18 +355,18 @@ 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) 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}) @@ -372,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() @@ -390,6 +393,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 raft raft) +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 ${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 +499,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..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() 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