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

Restore changes from #653 and #655 and correct cmake component dependencies #686

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
91 changes: 47 additions & 44 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
Expand All @@ -281,7 +284,6 @@ endif()

target_link_libraries(raft_distance INTERFACE
raft::raft
$<$<BOOL:${RAFT_ENABLE_cuco_DEPENDENCY}>:cuco::cuco>
$<TARGET_NAME_IF_EXISTS:raft_distance_lib>
$<TARGET_NAME_IF_EXISTS:raft::raft_distance_lib>
)
Expand Down Expand Up @@ -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 "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
Expand All @@ -335,7 +339,6 @@ endif()

target_link_libraries(raft_nn INTERFACE
raft::raft
$<$<BOOL:${RAFT_ENABLE_NN_DEPENDENCIES}>:faiss::faiss>
$<TARGET_NAME_IF_EXISTS:raft_nn_lib>
$<TARGET_NAME_IF_EXISTS:raft::raft_nn_lib>)

Expand All @@ -352,12 +355,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)
Expand Down Expand Up @@ -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 "" "")
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)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
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}
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
)
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"
)
vyasr marked this conversation as resolved.
Show resolved Hide resolved

endforeach()

##############################################################################
# - install export -----------------------------------------------------------
set(doc_string
Expand Down Expand Up @@ -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 ----------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions cpp/cmake/modules/raft_export.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
vyasr marked this conversation as resolved.
Show resolved Hide resolved
COMPONENT raft)
endif()
endforeach()

else()
Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/thirdparty/get_cuco.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions cpp/cmake/thirdparty/get_faiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down