Skip to content

Commit

Permalink
Make sure rmm::rmm CMake target is visibile to cudf users (rapidsai#7524
Browse files Browse the repository at this point in the history
)

Presume that a project is using `cudf` via CPM like the following, and the machine doesn't have cudf installed, but does have rmm.
```
CPMAddPackage(NAME  cudf
        VERSION         "0.19.0"
        GIT_REPOSITORY  https://github.com/rapidsai/cudf.git
        GIT_TAG         branch-0.19
        GIT_SHALLOW     TRUE
        SOURCE_SUBDIR   cpp
        OPTIONS         "BUILD_TESTS OFF"
                        "BUILD_BENCHMARKS OFF"
                        "ARROW_STATIC_LIB ON"
                        "JITIFY_USE_CACHE ON"
                        "CUDA_STATIC_RUNTIME ON"
                        "DISABLE_DEPRECATION_WARNING ON"
                        "AUTO_DETECT_CUDA_ARCHITECTURES ON"
    )

add_library(cudf_example cudf_example.cu)
target_link_libraries(cudf_example PRIVATE cudf::cudf)

add_library(rmm_example rmm_example.cu)
target_link_libraries(rmm_example PRIVATE rmm::rmm)
```

While CPM will fail to find `cudf`, it will find the local install of `rmm` and use it. This poses a problem as CMake import targets have different default visibility compared to 'real' targets. This means that while `cudf::cudf` can see and resolve `rmm::rmm` the `rmm_example` executable won't be able to.

This change makes it possible for users of cudf via CPM to directly access the `rmm::rmm` target

Authors:
  - Robert Maynard (@robertmaynard)

Approvers:
  - Keith Kraus (@kkraus14)

URL: rapidsai#7524
  • Loading branch information
robertmaynard authored and hyperbolic2346 committed Mar 23, 2021
1 parent 0784a31 commit 75f4db8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cpp/cmake/thirdparty/CUDF_GetRMM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ function(find_and_configure_rmm VERSION)
cudf_restore_if_enabled(BUILD_TESTS)
cudf_restore_if_enabled(BUILD_BENCHMARKS)

#Make sure consumers of cudf can also see rmm::rmm
if(TARGET rmm::rmm)
get_target_property(rmm_is_imported rmm::rmm IMPORTED)
if(rmm_is_imported)
set_target_properties(rmm::rmm PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
endif()
if(NOT rmm_BINARY_DIR IN_LIST CMAKE_PREFIX_PATH)
list(APPEND CMAKE_PREFIX_PATH "${rmm_BINARY_DIR}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
Expand Down

0 comments on commit 75f4db8

Please sign in to comment.