Skip to content

Commit

Permalink
Fix nvtx3 build export (#615)
Browse files Browse the repository at this point in the history
Fixes the following error:

```
CMake Error at /home/coder/rmm/build/conda/cuda-12.2/latest/rmm-targets.cmake:52 (set_target_properties):
  The link interface of target "rmm::rmm" contains:
    nvtx::nvtx3-cpp
  but the target was not found.  Possible reasons include:
    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.
Call Stack (most recent call first):
  /home/coder/rmm/build/conda/cuda-12.2/latest/rmm-config.cmake:75 (include)
  build/conda/cuda-12.2/release/cmake/CPM_0.38.5.cmake:243 (find_package)
  build/conda/cuda-12.2/release/cmake/CPM_0.38.5.cmake:303 (cpm_find_package)
  build/conda/cuda-12.2/release/_deps/rapids-cmake-src/rapids-cmake/cpm/find.cmake:189 (CPMFindPackage)
  build/conda/cuda-12.2/release/_deps/rapids-cmake-src/rapids-cmake/cpm/rmm.cmake:75 (rapids_cpm_find)
  cmake/thirdparty/get_rmm.cmake:20 (rapids_cpm_rmm)
  cmake/thirdparty/get_rmm.cmake:24 (find_and_configure_rmm)
  CMakeLists.txt:192 (include)
```

Authors:
  - Paul Taylor (https:/trxcllnt)
  - Robert Maynard (https:/robertmaynard)

Approvers:
  - Robert Maynard (https:/robertmaynard)

URL: #615
  • Loading branch information
trxcllnt authored May 23, 2024
1 parent 2f2a3c3 commit 1ea1803
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
31 changes: 17 additions & 14 deletions rapids-cmake/cpm/nvtx3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rapids_cpm_nvtx3

.. versionadded:: v24.06.00

Allow projects to find `NVTX3` via `CPM` with built-in tracking of dependencies
Allow projects to find `nvtx3` via `CPM` with built-in tracking of dependencies
for correct export support.

Uses the version of nvtx3 :ref:`specified in the version file <cpm_versions>` for consistency
Expand All @@ -42,10 +42,10 @@ Result Targets

Result Variables
^^^^^^^^^^^^^^^^
:cmake:variable:`NVTX3_SOURCE_DIR` is set to the path to the source directory of nvtx3.
:cmake:variable:`NVTX3_BINARY_DIR` is set to the path to the build directory of nvtx3.
:cmake:variable:`NVTX3_ADDED` is set to a true value if nvtx3 has not been added before.
:cmake:variable:`NVTX3_VERSION` is set to the version of nvtx3 specified by the versions.json.
:cmake:variable:`nvtx3_SOURCE_DIR` is set to the path to the source directory of nvtx3.
:cmake:variable:`nvtx3_BINARY_DIR` is set to the path to the build directory of nvtx3.
:cmake:variable:`nvtx3_ADDED` is set to a true value if nvtx3 has not been added before.
:cmake:variable:`nvtx3_VERSION` is set to the version of nvtx3 specified by the versions.json.

#]=======================================================================]
function(rapids_cpm_nvtx3)
Expand All @@ -72,7 +72,7 @@ function(rapids_cpm_nvtx3)
rapids_cpm_generate_patch_command(nvtx3 ${version} patch_command)

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(NVTX3 ${version} ${ARGN}
rapids_cpm_find(nvtx3 ${version} ${ARGN}
GLOBAL_TARGETS nvtx3-c nvtx3-cpp
CPM_ARGS
GIT_REPOSITORY ${repository}
Expand All @@ -81,15 +81,15 @@ function(rapids_cpm_nvtx3)
EXCLUDE_FROM_ALL ${exclude})

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(NVTX3)
rapids_cpm_display_patch_status(nvtx3)

# Extract the major version value of nvtx3 to use with `rapids-export` to setup compatibility
# rules
include("${rapids-cmake-dir}/cmake/parse_version.cmake")
rapids_cmake_parse_version(MAJOR ${version} ${version})

# Set up install rules Need to be re-entrant safe so only call when `NVTX3_ADDED`
if(NVTX3_ADDED)
# Set up install rules Need to be re-entrant safe so only call when `nvtx3_ADDED`
if(nvtx3_ADDED)
install(TARGETS nvtx3-c nvtx3-cpp EXPORT nvtx3-targets)
if(_RAPIDS_BUILD_EXPORT_SET)
include("${rapids-cmake-dir}/export/export.cmake")
Expand All @@ -98,10 +98,13 @@ function(rapids_cpm_nvtx3)
EXPORT_SET nvtx3-targets
GLOBAL_TARGETS nvtx3-c nvtx3-cpp
NAMESPACE nvtx::)
include("${rapids-cmake-dir}/export/find_package_root.cmake")
rapids_export_find_package_root(BUILD nvtx3 [=[${CMAKE_CURRENT_LIST_DIR}]=]
EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET})
endif()
if(_RAPIDS_INSTALL_EXPORT_SET AND NOT exclude)
include(GNUInstallDirs)
install(DIRECTORY "${NVTX3_SOURCE_DIR}/c/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY "${nvtx3_SOURCE_DIR}/c/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
include("${rapids-cmake-dir}/export/export.cmake")
rapids_export(INSTALL nvtx3
VERSION ${version}
Expand All @@ -112,9 +115,9 @@ function(rapids_cpm_nvtx3)
endif()

# Propagate up variables that CPMFindPackage provide
set(NVTX3_SOURCE_DIR "${NVTX3_SOURCE_DIR}" PARENT_SCOPE)
set(NVTX3_BINARY_DIR "${NVTX3_BINARY_DIR}" PARENT_SCOPE)
set(NVTX3_ADDED "${NVTX3_ADDED}" PARENT_SCOPE)
set(NVTX3_VERSION ${version} PARENT_SCOPE)
set(nvtx3_SOURCE_DIR "${nvtx3_SOURCE_DIR}" PARENT_SCOPE)
set(nvtx3_BINARY_DIR "${nvtx3_BINARY_DIR}" PARENT_SCOPE)
set(nvtx3_ADDED "${nvtx3_ADDED}" PARENT_SCOPE)
set(nvtx3_VERSION ${version} PARENT_SCOPE)

endfunction()
4 changes: 2 additions & 2 deletions rapids-cmake/export/package.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@ generated information will include a :cmake:command:`find_dependency` call for <
Will record <PackageName> is part of the build directory export set

``INSTALL``
Will record <PackageName> is part of the build directory export set
Will record <PackageName> is part of the install directory export set

``VERSION``
.. versionadded:: v22.04.00
Expand Down
6 changes: 3 additions & 3 deletions testing/cpm/cpm_nvtx-export.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ rapids_cpm_nvtx3(BUILD_EXPORT_SET frank INSTALL_EXPORT_SET test)
rapids_cpm_nvtx3(INSTALL_EXPORT_SET test2)

get_target_property(packages rapids_export_install_test PACKAGE_NAMES)
if(NOT NVTX3 IN_LIST packages)
if(NOT nvtx3 IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_nvtx3 failed to record nvtx3 needs to be exported")
endif()

get_target_property(packages rapids_export_install_test2 PACKAGE_NAMES)
if(NOT NVTX3 IN_LIST packages)
if(NOT nvtx3 IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_nvtx3 failed to record nvtx3 needs to be exported")
endif()

get_target_property(packages rapids_export_build_frank PACKAGE_NAMES)
if(NOT NVTX3 IN_LIST packages)
if(NOT nvtx3 IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_nvtx3 failed to record nvtx3 needs to be exported")
endif()

0 comments on commit 1ea1803

Please sign in to comment.