Skip to content

Commit 89025a1

Browse files
committed
Fix fetching L0 and CUDA headers and add UMF_CUDA_INCLUDE_DIR
Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0 headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR). Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR). Ref: #825 Fixes: #827 Signed-off-by: Lukasz Dorau <[email protected]>
1 parent bb00c56 commit 89025a1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)
66

77
set(UMF_LEVEL_ZERO_INCLUDE_DIR
88
""
9-
CACHE PATH "Directory containing the Level Zero Headers")
9+
CACHE PATH "Directory containing the Level Zero headers")
10+
set(UMF_CUDA_INCLUDE_DIR
11+
""
12+
CACHE PATH "Directory containing the CUDA headers")
1013

1114
# Compile definitions for UMF library.
1215
#
1316
# TODO: Cleanup the compile definitions across all the CMake files
1417
set(UMF_COMMON_COMPILE_DEFINITIONS UMF_VERSION=${UMF_VERSION})
1518

16-
# Only fetch L0 loader if needed (L0 provider and GPU tests are ON), and not
17-
# already provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
18-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (UMF_BUILD_GPU_TESTS
19-
OR (NOT UMF_LEVEL_ZERO_INCLUDE_DIR)))
19+
# Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
20+
# headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
21+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
2022
include(FetchContent)
2123

2224
set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
@@ -44,7 +46,9 @@ elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER)
4446
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
4547
endif()
4648

47-
if(UMF_BUILD_CUDA_PROVIDER)
49+
# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
50+
# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
51+
if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
4852
include(FetchContent)
4953

5054
set(CUDA_REPO
@@ -64,6 +68,10 @@ if(UMF_BUILD_CUDA_PROVIDER)
6468
${cuda-headers_SOURCE_DIR}
6569
CACHE PATH "Path to CUDA headers")
6670
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
71+
elseif(UMF_BUILD_CUDA_PROVIDER)
72+
# Only header is needed to build UMF
73+
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
74+
message(STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS}")
6775
endif()
6876

6977
add_subdirectory(utils)

0 commit comments

Comments
 (0)