Skip to content

Commit

Permalink
[FIX] Ensure hnswlib can be found from RAFT's build dir (#2145)
Browse files Browse the repository at this point in the history
This PR fixes using RAFT from a build dir, i.e. `cmake -S cuml/cpp -B cuml/cpp/build -Draft_ROOT=raft/cpp/build`.

Without this fix, CMake errors when cuML does `find_package(RAFT)` with the following error:
```
CMake Error at raft/cpp/build/latest/raft-targets.cmake:56 (set_target_properties):
  The link interface of target "raft::raft" contains:

    hnswlib::hnswlib

  but the target was not found.  Possible reasons include:


    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.
```

Authors:
  - Paul Taylor (https://github.com/trxcllnt)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)
  - Bradley Dice (https://github.com/bdice)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #2145
  • Loading branch information
trxcllnt authored Feb 2, 2024
1 parent d403ab4 commit 6328be7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions cpp/cmake/thirdparty/get_hnswlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,30 @@ function(find_and_configure_hnswlib)
install(TARGETS hnswlib EXPORT hnswlib-exports)
install(DIRECTORY "${hnswlib_SOURCE_DIR}/hnswlib/" DESTINATION include/hnswlib)

# write export rules
rapids_export(
BUILD hnswlib
VERSION ${PKG_VERSION}
EXPORT_SET hnswlib-exports
GLOBAL_TARGETS hnswlib
NAMESPACE hnswlib::)
# write install export rules
rapids_export(
INSTALL hnswlib
VERSION ${PKG_VERSION}
EXPORT_SET hnswlib-exports
GLOBAL_TARGETS hnswlib
NAMESPACE hnswlib::)
endif()

# write build export rules
rapids_export(
BUILD hnswlib
VERSION ${PKG_VERSION}
EXPORT_SET hnswlib-exports
GLOBAL_TARGETS hnswlib
NAMESPACE hnswlib::)

include("${rapids-cmake-dir}/export/find_package_root.cmake")

# When using RAFT from the build dir, ensure hnswlib is also found in RAFT's build dir. This
# line adds `set(hnswlib_ROOT "${CMAKE_CURRENT_LIST_DIR}")` to build/raft-dependencies.cmake
rapids_export_find_package_root(
BUILD hnswlib [=[${CMAKE_CURRENT_LIST_DIR}]=] EXPORT_SET raft-exports
)
endif()
endfunction()

Expand Down

0 comments on commit 6328be7

Please sign in to comment.