From 75f4db81725c4ef6675c342e89c5706f11ef1a49 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 9 Mar 2021 16:11:48 -0500 Subject: [PATCH] Make sure rmm::rmm CMake target is visibile to cudf users (#7524) 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: https://github.com/rapidsai/cudf/pull/7524 --- cpp/cmake/thirdparty/CUDF_GetRMM.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake b/cpp/cmake/thirdparty/CUDF_GetRMM.cmake index b4a6a67c24d..ccefaf2ff33 100644 --- a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake +++ b/cpp/cmake/thirdparty/CUDF_GetRMM.cmake @@ -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)