Skip to content

Commit 110e33a

Browse files
rafbielskbenzie
authored andcommitted
Fix CMake CUPTI config (#17457)
Fix-up for #17315 which used incorrect CMake variables for CUPTI: * `CUDAToolkit_cupti_INCLUDE_DIR` should be `CUDAToolkit_CUPTI_INCLUDE_DIR` * `CUDAToolkit_cupti_LIBRARY` should be `CUDA_cupti_LIBRARY` In addition, we discovered that FindCUDAToolkit: * does not set the INCLUDE_DIR variable until CMake 3.24 (while we support back to 3.20) * fails to find the library in CUDA toolkits installed from runfile (https://gitlab.kitware.com/cmake/cmake/-/issues/26770) Fix the variable names and retry the searches with extra paths if the header/library are not found. The REQUIRED option is enabled in the retry, which ensures that if CUPTI is not found then the build fails at CMake configuration instead of later during compilation or linking.
1 parent eae08bc commit 110e33a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

source/adapters/cuda/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,22 @@ if (UR_ENABLE_TRACING AND UNIX)
9393
XPTI_ENABLE_INSTRUMENTATION
9494
XPTI_STATIC_LIBRARY
9595
)
96+
97+
# CUDAToolkit_CUPTI_INCLUDE_DIR is provided by FindCUDAToolkit since CMake
98+
# 3.24, but we support versions back to 3.20. Find it if not found already.
99+
if (NOT CUDAToolkit_CUPTI_INCLUDE_DIR)
100+
find_path(CUDAToolkit_CUPTI_INCLUDE_DIR cupti.h PATHS
101+
"${CUDAToolkit_ROOT_DIR}/extras/CUPTI/include"
102+
${CUDAToolkit_INCLUDE_DIRS}
103+
PATH_SUFFIXES "../extras/CUPTI/include"
104+
"../../../extras/CUPTI/include"
105+
REQUIRED
106+
NO_DEFAULT_PATH)
107+
endif()
108+
96109
target_include_directories(${TARGET_NAME} PRIVATE
97110
${XPTI_INCLUDES}
98-
${CUDAToolkit_cupti_INCLUDE_DIR}
111+
${CUDAToolkit_CUPTI_INCLUDE_DIR}
99112
)
100113
target_sources(${TARGET_NAME} PRIVATE ${XPTI_PROXY_SRC})
101114
endif()

0 commit comments

Comments
 (0)