From 9ddad07ae866664c0fe53f605bad331be78d54e9 Mon Sep 17 00:00:00 2001 From: pauleonix Date: Tue, 2 Jul 2024 14:57:25 +0200 Subject: [PATCH] Add documentation for CPM usage - Add section in README.md that describes issue with CPM's single argument syntax. - Update link to CPM.cmake repo (old link redirected to this new one). - Add optional INTERFACE argument to CMake snippets for completeness. Co-authored-by: Robert Maynard --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f6cceb49..1ded7db5c 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Done! You are ready to develop for the RMM OSS project. ### Caching third-party dependencies -RMM uses [CPM.cmake](https://github.com/TheLartians/CPM.cmake) to +RMM uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to handle third-party dependencies like spdlog, Thrust, GoogleTest, GoogleBenchmark. In general you won't have to worry about it. If CMake finds an appropriate version on your system, it uses it (you can @@ -156,7 +156,7 @@ integrate RMM into your own CMake project. In your `CMakeLists.txt`, just add ```cmake find_package(rmm [VERSION]) # ... -target_link_libraries( (PRIVATE|PUBLIC) rmm::rmm) +target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm) ``` Since RMM is a header-only library, this does not actually link RMM, @@ -171,6 +171,27 @@ Thrust. If you want to customize it, you can set the variables `THRUST_HOST_SYSTEM` and `THRUST_DEVICE_SYSTEM`; see [Thrust's CMake documentation](https://github.com/NVIDIA/cccl/blob/main/thrust/thrust/cmake/README.md). +### Using CPM to manage RMM + +RMM uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to manage +its dependencies on [CCCL](https://github.com/nvidia/cccl) and others, +you can use it for your project's dependecy on RMM itself. + +There is an issue with using CPM's *single-argument compact syntax* for +RMM/CCCL as it transitively marks targets as `SYSTEM` dependencies. +This causes the CCCL headers pulled in through CPM to be of lower priority +to the preprocessor than the (potentially outdated) CCCL headers provided +by the CUDA SDK. To avoid this issue, use CPM's *multi-argument syntax* +instead: + +```cmake +CPMAddPackage(NAME rmm [VERSION] + GITHUB_REPOSITORY rapidsai/rmm + SYSTEM Off) +# ... +target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm) +``` + # Using RMM in C++ The first goal of RMM is to provide a common interface for device and host memory allocation.