@@ -218,6 +218,64 @@ if(hwloc_targ_SOURCE_DIR)
218218 endif ()
219219endif ()
220220
221+ # Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
222+ # headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
223+ if (UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
224+ include (FetchContent)
225+
226+ set (LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git" )
227+ set (LEVEL_ZERO_LOADER_TAG v1.17.39)
228+
229+ message (
230+ STATUS
231+ "Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG} ) from ${LEVEL_ZERO_LOADER_REPO} ..."
232+ )
233+
234+ FetchContent_Declare(
235+ level-zero-loader
236+ GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
237+ GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
238+ EXCLUDE_FROM_ALL )
239+ FetchContent_MakeAvailable(level-zero-loader)
240+
241+ set (LEVEL_ZERO_INCLUDE_DIRS
242+ ${level-zero-loader_SOURCE_DIR}/include
243+ CACHE PATH "Path to Level Zero Headers" )
244+ message (STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS} " )
245+ elseif (UMF_BUILD_LEVEL_ZERO_PROVIDER)
246+ # Only header is needed to build UMF
247+ set (LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR} )
248+ message (STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS} " )
249+ endif ()
250+
251+ # Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
252+ # headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
253+ if (UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
254+ include (FetchContent)
255+
256+ set (CUDA_REPO
257+ "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git" )
258+ set (CUDA_TAG cuda-12.5.1)
259+
260+ message (STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ..." )
261+
262+ FetchContent_Declare(
263+ cuda-headers
264+ GIT_REPOSITORY ${CUDA_REPO}
265+ GIT_TAG ${CUDA_TAG}
266+ EXCLUDE_FROM_ALL )
267+ FetchContent_MakeAvailable(cuda-headers)
268+
269+ set (CUDA_INCLUDE_DIRS
270+ ${cuda-headers_SOURCE_DIR}
271+ CACHE PATH "Path to CUDA headers" )
272+ message (STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS} " )
273+ elseif (UMF_BUILD_CUDA_PROVIDER)
274+ # Only header is needed to build UMF
275+ set (CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR} )
276+ message (STATUS "CUDA include directory: ${CUDA_INCLUDE_DIRS} " )
277+ endif ()
278+
221279# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
222280# set, because in this case the build type is determined after a CMake
223281# configuration is done (at the build time)
0 commit comments