22# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
5+ message (STATUS "CMake version: ${CMAKE_VERSION} " )
56cmake_minimum_required (VERSION 3.14.0 FATAL_ERROR)
7+
68# needed when UMF is used as an external project
79set (UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
810
@@ -404,16 +406,17 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
404406 GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
405407 GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
406408 EXCLUDE_FROM_ALL )
407- FetchContent_MakeAvailable(level-zero-loader)
409+ # Only populate the repo - we don't need to build it
410+ FetchContent_Populate(level-zero-loader)
408411
409412 set (LEVEL_ZERO_INCLUDE_DIRS
410413 ${level-zero-loader_SOURCE_DIR}/include
411- CACHE PATH "Path to Level Zero Headers " )
412- message (STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS} " )
414+ CACHE PATH "Path to Level Zero headers " )
415+ message (STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS} " )
413416elseif (UMF_BUILD_LEVEL_ZERO_PROVIDER)
414417 # Only header is needed to build UMF
415418 set (LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR} )
416- message (STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS} " )
419+ message (STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS} " )
417420endif ()
418421
419422# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
@@ -423,14 +426,15 @@ if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
423426 "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git" )
424427 set (CUDA_TAG cuda-12.5.1)
425428
426- message (STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ..." )
429+ message (STATUS "Fetching CUDA ( ${CUDA_TAG} ) from ${CUDA_REPO} ..." )
427430
428431 FetchContent_Declare(
429432 cuda-headers
430433 GIT_REPOSITORY ${CUDA_REPO}
431434 GIT_TAG ${CUDA_TAG}
432435 EXCLUDE_FROM_ALL )
433- FetchContent_MakeAvailable(cuda-headers)
436+ # Only populate the repo - we don't need to build it
437+ FetchContent_Populate(cuda-headers)
434438
435439 set (CUDA_INCLUDE_DIRS
436440 ${cuda-headers_SOURCE_DIR}
@@ -707,16 +711,31 @@ else()
707711 )
708712endif ()
709713
710- if ((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER)
711- find_package (CUDA REQUIRED cuda)
712- if (CUDA_LIBRARIES)
713- set (UMF_CUDA_ENABLED TRUE )
714- else ()
715- message (
716- STATUS "Disabling tests and examples that use the CUDA provider "
717- "because the CUDA libraries they require were not found." )
714+ if (UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
715+ if (UMF_BUILD_CUDA_PROVIDER)
716+ find_package (CUDA REQUIRED cuda)
717+ if (CUDA_LIBRARIES)
718+ set (UMF_CUDA_ENABLED TRUE )
719+ else ()
720+ message (
721+ STATUS
722+ "Disabling tests and examples that use the CUDA Provider "
723+ "because the CUDA libraries they require were not found." )
724+ endif ()
725+ endif ()
726+
727+ if (UMF_BUILD_LEVEL_ZERO_PROVIDER)
728+ find_package (ZE_LOADER REQUIRED ze_loader)
729+ if (ZE_LOADER_LIBRARIES)
730+ set (UMF_LEVEL_ZERO_ENABLED TRUE )
731+ else ()
732+ message (
733+ STATUS
734+ "Disabling tests and examples that use the Level Zero Provider "
735+ "because the Level Zero libraries they require were not found."
736+ )
737+ endif ()
718738 endif ()
719- # TODO do the same for ze_loader
720739endif ()
721740
722741add_subdirectory (src)
0 commit comments