Skip to content

Commit

Permalink
Update with rapids cmake new features (#320)
Browse files Browse the repository at this point in the history
This combines some general CMake style cleanup and brings new rapids-cmake features to RAFT including:

- Usage of `rapids_cmake_install_lib_dir` to make sure we install raft correctly on non-debain based distro's ( lib64 ), while also handling conda installation requirements ( always lib no matter the distro )
- Usage of `rapids_cpm` pre-configured pacakges
- Removal of early termination before `rapids_cpm_find` since a better solution now exists ( rapidsai/rapids-cmake#49 )

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #320
  • Loading branch information
robertmaynard authored Sep 9, 2021
1 parent e806f99 commit f311247
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 66 deletions.
10 changes: 5 additions & 5 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ include(cmake/modules/ConfigureCUDA.cmake)
##############################################################################
# - Requirements -------------------------------------------------------------

if (NOT DISABLE_OPENMP OR NOT ${DISABLE_OPENMP})
if (NOT DISABLE_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
message(VERBOSE "RAFT: OpenMP found in ${OpenMP_CXX_INCLUDE_DIRS}")
endif(OPENMP_FOUND)
endif(NOT DISABLE_OPENMP OR NOT ${DISABLE_OPENMP})
endif()
endif()

# add third party dependencies using CPM
rapids_cpm_init()
Expand All @@ -113,7 +113,7 @@ endif()

##############################################################################
# - install targets-----------------------------------------------------------

rapids_cmake_install_lib_dir( lib_dir )
add_library(raft INTERFACE)
add_library(raft::raft ALIAS raft)
target_include_directories(raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
Expand All @@ -133,7 +133,7 @@ INTERFACE
target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)

install(TARGETS raft
DESTINATION lib
DESTINATION ${lib_dir}
EXPORT raft-exports
)

Expand Down
4 changes: 0 additions & 4 deletions cpp/cmake/thirdparty/get_cuco.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

function(find_and_configure_cuco VERSION)

if(TARGET cuco::cuco)
return()
endif()

rapids_cpm_find(cuco ${VERSION}
GLOBAL_TARGETS cuco::cuco
BUILD_EXPORT_SET raft-exports
Expand Down
27 changes: 4 additions & 23 deletions cpp/cmake/thirdparty/get_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,11 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_gtest VERSION)
function(find_and_configure_gtest )

if(TARGET GTest::gtest)
return()
endif()

rapids_cpm_find(GTest ${VERSION}
GLOBAL_TARGETS gest gtest_main GTest::gtest GTest::gtest_main
CPM_ARGS
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-${VERSION}
GIT_SHALLOW TRUE
OPTIONS "INSTALL_GTEST OFF"
# googletest >= 1.10.0 provides a cmake config file -- use it if it exists
FIND_PACKAGE_ARGUMENTS "CONFIG"
)

if(NOT TARGET GTest::gtest)
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()
include(${rapids-cmake-dir}/cpm/gtest.cmake)
rapids_cpm_gtest()

endfunction()

set(RAFT_MIN_VERSION_gtest 1.10.0)

find_and_configure_gtest(${RAFT_MIN_VERSION_gtest})
find_and_configure_gtest()
2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_nccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

function(find_and_configure_nccl)

if(TARGET nccl::nccl)
if(TARGET NCCL::NCCL)
return()
endif()

Expand Down
27 changes: 4 additions & 23 deletions cpp/cmake/thirdparty/get_rmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,15 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_rmm VERSION)
function(find_and_configure_rmm)

if(TARGET rmm::rmm)
return()
endif()

if(${VERSION} MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
set(MAJOR_AND_MINOR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
else()
set(MAJOR_AND_MINOR "${VERSION}")
endif()

rapids_cpm_find(rmm ${VERSION}
include(${rapids-cmake-dir}/cpm/rmm.cmake)
rapids_cpm_rmm(
GLOBAL_TARGETS rmm::rmm
BUILD_EXPORT_SET raft-exports
INSTALL_EXPORT_SET raft-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/rapidsai/rmm.git
GIT_TAG branch-${MAJOR_AND_MINOR}
GIT_SHALLOW TRUE
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF"
"CUDA_STATIC_RUNTIME ${CUDA_STATIC_RUNTIME}"
"DISABLE_DEPRECATION_WARNING ${DISABLE_DEPRECATION_WARNING}"
)

endfunction()

set(RAFT_MIN_VERSION_rmm "${RAFT_VERSION_MAJOR}.${RAFT_VERSION_MINOR}.00")

find_and_configure_rmm(${RAFT_MIN_VERSION_rmm})
find_and_configure_rmm()
15 changes: 6 additions & 9 deletions cpp/cmake/thirdparty/get_thrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
# =============================================================================

# Use CPM to find or clone thrust
function(find_and_configure_thrust VERSION)
function(find_and_configure_thrust)
include(${rapids-cmake-dir}/cpm/thrust.cmake)

rapids_cpm_find(
Thrust ${VERSION}
rapids_cpm_thrust(
NAMESPACE raft
BUILD_EXPORT_SET raft-exports
INSTALL_EXPORT_SET raft-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/NVIDIA/thrust.git
GIT_TAG ${VERSION}
GIT_SHALLOW TRUE
OPTIONS "THRUST_INSTALL OFF")
)

endfunction()

find_and_configure_thrust(1.12.0)
find_and_configure_thrust()
2 changes: 1 addition & 1 deletion cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ PRIVATE
FAISS::FAISS
GTest::gtest
GTest::gtest_main
OpenMP::OpenMP_CXX
Threads::Threads
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
)

0 comments on commit f311247

Please sign in to comment.