Skip to content

do not use FetchContent_Populate in CMake >= 3.28 #1300

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

Merged
merged 1 commit into from
May 9, 2025
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
22 changes: 11 additions & 11 deletions .github/workflows/reusable_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
install_tbb: ['ON']
disable_hwloc: ['OFF']
link_hwloc_statically: ['OFF']
cmake_ver: ['latest']
cmake_ver: ['default']
include:
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -48,7 +48,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: '3.28.0'
- os: 'ubuntu-24.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
Expand All @@ -58,7 +58,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: 'default'
# test level_zero_provider='OFF' and cuda_provider='OFF'
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -69,7 +69,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: 'default'
# test icx compiler
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -80,7 +80,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: 'default'
# test lld linker
- os: 'ubuntu-24.04'
build_type: Release
Expand All @@ -92,7 +92,7 @@ jobs:
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
llvm_linker: '-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld"'
cmake_ver: 'latest'
cmake_ver: 'default'
# test without installing TBB
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -103,7 +103,7 @@ jobs:
install_tbb: 'OFF'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: 'default'
- os: 'ubuntu-22.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
Expand All @@ -113,7 +113,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'ON'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
cmake_ver: 'default'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
Expand All @@ -123,7 +123,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'ON'
cmake_ver: 'latest'
cmake_ver: 'default'
runs-on: ${{matrix.os}}

steps:
Expand All @@ -137,8 +137,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y clang libnuma-dev lcov

- name: Install cmake (minimum supported version)
if: matrix.cmake_ver != 'latest'
- name: Install cmake (non-default version)
if: matrix.cmake_ver != 'default'
run: |
sudo apt-get remove --purge -y cmake
wget https://github.com/Kitware/CMake/releases/download/v${{matrix.cmake_ver}}/cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh
Expand Down
50 changes: 36 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,24 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER)

message(STATUS "Fetching Level Zero loader (${LEVEL_ZERO_LOADER_TAG}) "
"from ${LEVEL_ZERO_LOADER_REPO} ...")
FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
# Only populate the repo - we don't need to build it
FetchContent_Populate(level-zero-loader)

# We don't want to build and include Level Zero binaries to our install
# target. For CMake >= 3.28 we use EXCLUDE_FROM_ALL flag to do that, but
# for older versions we need to use FetchContent_Populate.
if(CMAKE_VERSION VERSION_LESS 3.28)
FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG})
FetchContent_Populate(level-zero-loader)
else()
FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(level-zero-loader)
endif()

set(LEVEL_ZERO_INCLUDE_DIRS
${level-zero-loader_SOURCE_DIR}/include
Expand Down Expand Up @@ -457,13 +468,24 @@ if(UMF_BUILD_CUDA_PROVIDER)

message(
STATUS "Fetching CUDA (${CUDA_TAG}) headers from ${CUDA_REPO} ...")
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
# Only populate the repo - we don't need to build it
FetchContent_Populate(cuda-headers)

# We don't want to build and include CUDA binaries to our install
# target. For CMake >= 3.28 we could use EXCLUDE_FROM_ALL flag to do
# that, but for older versions we need to use FetchContent_Populate.
if(CMAKE_VERSION VERSION_LESS 3.28)
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG})
FetchContent_Populate(cuda-headers)
else()
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(cuda-headers)
endif()

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
Expand Down
23 changes: 17 additions & 6 deletions examples/cuda_shared_memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,23 @@ set(CUDA_REPO "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
set(CUDA_TAG cuda-12.5.1)
message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")

FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_Populate(cuda-headers)
# We don't want to build and include CUDA binaries to our install target. For
# CMake >= 3.28 we use EXCLUDE_FROM_ALL flag to do that, but for older versions
# we need to use FetchContent_Populate.
if(CMAKE_VERSION VERSION_LESS 3.28)
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG})
FetchContent_Populate(cuda-headers)
else()
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(cuda-headers)
endif()

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
Expand Down
Loading