Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nvtx3 build export #615

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()