Skip to content

Commit

Permalink
Use new rapids-cmake functionality for rpath handling. (#4966)
Browse files Browse the repository at this point in the history
The new functionality creates a single source of truth defining the location at which a library will be, allowing rapids-cmake to handle the necessary relative paths in the RPATH and avoiding the current error-prone approach that requires each CMakeLists.txt to correctly assign the relative path.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

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

URL: #4966
  • Loading branch information
vyasr authored Nov 2, 2022
1 parent 02d4c64 commit 48e1cb7
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 87 deletions.
8 changes: 6 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ else()
set(cuml_FOUND OFF)
endif()

include(rapids-cython)

if(NOT cuml_FOUND)
# TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required
Expand All @@ -94,7 +95,8 @@ if(NOT cuml_FOUND)
message(STATUS "installing packages")
add_subdirectory(../cpp cuml-cpp)

install(TARGETS ${CUML_CPP_TARGET} DESTINATION cuml/library)
set(cython_lib_dir cuml)
install(TARGETS ${CUML_CPP_TARGET} DESTINATION ${cython_lib_dir})
endif()

set(cuml_sg_libraries cuml::${CUML_CPP_TARGET})
Expand All @@ -107,7 +109,6 @@ if(NOT SINGLEGPU)
)
endif()

include(rapids-cython)
rapids_cython_init()

add_subdirectory(cuml/common)
Expand All @@ -133,3 +134,6 @@ add_subdirectory(cuml/tsa)
add_subdirectory(cuml/experimental/common)
add_subdirectory(cuml/experimental/linear_model)

if(DEFINED cython_lib_dir)
rapids_cython_add_rpath_entries(TARGET cuml PATHS "${cython_lib_dir}")
endif()
5 changes: 1 addition & 4 deletions python/cuml/cluster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX cluster_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/cluster/hdbscan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES ${cuml_sg_libraries}
MODULE_PREFIX cluster_hdbscan_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX common_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()

# todo: ml_cuda_utils.h should be in the include folder of cuML or the functionality
# moved to another file, pointer_utils.pyx needs it
# https://github.com/rapidsai/cuml/issues/4841
Expand Down
5 changes: 1 addition & 4 deletions python/cuml/datasets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX datasets_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
6 changes: 1 addition & 5 deletions python/cuml/decomposition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX decomposition_

ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/ensemble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}"
MODULE_PREFIX ensemble_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/experimental/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX experimental_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/experimental/linear_model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX experimental_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/explainer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX explainer_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/fil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX fil_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/internals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX internals_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()

# We need to include for callbacks_implements.h in the internals folder
target_include_directories(internals_internals PRIVATE ${CMAKE_CURRENT_LIST_DIR})
5 changes: 1 addition & 4 deletions python/cuml/kernel_ridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX kernel_ridge_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/linear_model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX linear_model_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/manifold/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX manifold_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/metrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX metrics_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/metrics/cluster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ rapids_cython_create_modules(
CXX
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library")
endforeach()

5 changes: 1 addition & 4 deletions python/cuml/neighbors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX neighbors_
ASSOCIATED_TARGETS cuml
)

foreach(target IN LISTS targets_using_numpy)
target_include_directories(${target} PRIVATE "${Python_NumPy_INCLUDE_DIRS}")
endforeach()

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/random_projection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX random_projection_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/solvers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES $<IF:$<BOOL:${SINGLE_GPU}>,${cuml_sg_libraries},${cuml_mg_libraries}>
MODULE_PREFIX solvers_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/svm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX svm_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()
5 changes: 1 addition & 4 deletions python/cuml/tsa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX tsa_
ASSOCIATED_TARGETS cuml
)

foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library")
endforeach()

0 comments on commit 48e1cb7

Please sign in to comment.