From fb28a5d401ae128fb60e197b22859229d925644a Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 11 May 2022 19:50:23 -0700 Subject: [PATCH] Fail to build the Python library if linking against a pre-built C++ library without the distance component. --- cpp/CMakeLists.txt | 8 -------- python/pylibraft/CMakeLists.txt | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f1c703a5ae..a2b22a0c4e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -137,14 +137,6 @@ if(RAFT_COMPILE_LIBRARIES) set(RAFT_COMPILE_NN_LIBRARY ON) endif() -if(distance IN_LIST raft_FIND_COMPONENTS) - set(RAFT_COMPILE_DIST_LIBRARY ON) -endif() - -if(nn IN_LIST raft_FIND_COMPONENTS) - set(RAFT_COMPILE_NN_LIBRARY ON) -endif() - if(RAFT_COMPILE_DIST_LIBRARY) set(RAFT_ENABLE_cuco_DEPENDENCY ON) endif() diff --git a/python/pylibraft/CMakeLists.txt b/python/pylibraft/CMakeLists.txt index 5ca2c90ee2..874ec6462b 100644 --- a/python/pylibraft/CMakeLists.txt +++ b/python/pylibraft/CMakeLists.txt @@ -36,6 +36,14 @@ option(FIND_RAFT_CPP "Search for existing RAFT C++ installations before defaulti # If the user requested it we attempt to find RAFT. if(FIND_RAFT_CPP) find_package(raft ${pylibraft_version} REQUIRED COMPONENTS distance) + # TODO: I find it odd that the raft-config.cmake includes the corresponding + # component lib-target/dependency as OPTIONAL. This leads to the variables + # raft_distance_FOUND and raft_nn_FOUND to always be set to true, and it + # means that the find_package call won't fail if a user requests a + # component that hasn't been installed. Is that an error? + if(NOT TARGET raft::raft_distance_lib) + message(FATAL_ERROR "Building against a preexisting libraft library requires the distance component of that library to have been built!") + endif() else() set(raft_FOUND OFF) endif()