Skip to content

Commit 3392550

Browse files
Merge pull request #1300 from bratpiorka/rrudnick_fix_populate
do not use FetchContent_Populate in CMake >= 3.28
2 parents e66a3cb + b551fcf commit 3392550

File tree

3 files changed

+64
-31
lines changed

3 files changed

+64
-31
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
install_tbb: ['ON']
2727
disable_hwloc: ['OFF']
2828
link_hwloc_statically: ['OFF']
29-
cmake_ver: ['latest']
29+
cmake_ver: ['default']
3030
include:
3131
- os: 'ubuntu-22.04'
3232
build_type: Release
@@ -48,7 +48,7 @@ jobs:
4848
install_tbb: 'ON'
4949
disable_hwloc: 'OFF'
5050
link_hwloc_statically: 'OFF'
51-
cmake_ver: 'latest'
51+
cmake_ver: '3.28.0'
5252
- os: 'ubuntu-24.04'
5353
build_type: Debug
5454
compiler: {c: gcc, cxx: g++}
@@ -58,7 +58,7 @@ jobs:
5858
install_tbb: 'ON'
5959
disable_hwloc: 'OFF'
6060
link_hwloc_statically: 'OFF'
61-
cmake_ver: 'latest'
61+
cmake_ver: 'default'
6262
# test level_zero_provider='OFF' and cuda_provider='OFF'
6363
- os: 'ubuntu-22.04'
6464
build_type: Release
@@ -69,7 +69,7 @@ jobs:
6969
install_tbb: 'ON'
7070
disable_hwloc: 'OFF'
7171
link_hwloc_statically: 'OFF'
72-
cmake_ver: 'latest'
72+
cmake_ver: 'default'
7373
# test icx compiler
7474
- os: 'ubuntu-22.04'
7575
build_type: Release
@@ -80,7 +80,7 @@ jobs:
8080
install_tbb: 'ON'
8181
disable_hwloc: 'OFF'
8282
link_hwloc_statically: 'OFF'
83-
cmake_ver: 'latest'
83+
cmake_ver: 'default'
8484
# test lld linker
8585
- os: 'ubuntu-24.04'
8686
build_type: Release
@@ -92,7 +92,7 @@ jobs:
9292
disable_hwloc: 'OFF'
9393
link_hwloc_statically: 'OFF'
9494
llvm_linker: '-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld"'
95-
cmake_ver: 'latest'
95+
cmake_ver: 'default'
9696
# test without installing TBB
9797
- os: 'ubuntu-22.04'
9898
build_type: Release
@@ -103,7 +103,7 @@ jobs:
103103
install_tbb: 'OFF'
104104
disable_hwloc: 'OFF'
105105
link_hwloc_statically: 'OFF'
106-
cmake_ver: 'latest'
106+
cmake_ver: 'default'
107107
- os: 'ubuntu-22.04'
108108
build_type: Debug
109109
compiler: {c: gcc, cxx: g++}
@@ -113,7 +113,7 @@ jobs:
113113
install_tbb: 'ON'
114114
disable_hwloc: 'ON'
115115
link_hwloc_statically: 'OFF'
116-
cmake_ver: 'latest'
116+
cmake_ver: 'default'
117117
- os: 'ubuntu-22.04'
118118
build_type: Release
119119
compiler: {c: gcc, cxx: g++}
@@ -123,7 +123,7 @@ jobs:
123123
install_tbb: 'ON'
124124
disable_hwloc: 'OFF'
125125
link_hwloc_statically: 'ON'
126-
cmake_ver: 'latest'
126+
cmake_ver: 'default'
127127
runs-on: ${{matrix.os}}
128128

129129
steps:
@@ -137,8 +137,8 @@ jobs:
137137
sudo apt-get update
138138
sudo apt-get install -y clang libnuma-dev lcov
139139
140-
- name: Install cmake (minimum supported version)
141-
if: matrix.cmake_ver != 'latest'
140+
- name: Install cmake (non-default version)
141+
if: matrix.cmake_ver != 'default'
142142
run: |
143143
sudo apt-get remove --purge -y cmake
144144
wget https://github.com/Kitware/CMake/releases/download/v${{matrix.cmake_ver}}/cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh

CMakeLists.txt

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,24 @@ if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
412412

413413
message(STATUS "Fetching Level Zero loader (${LEVEL_ZERO_LOADER_TAG}) "
414414
"from ${LEVEL_ZERO_LOADER_REPO} ...")
415-
FetchContent_Declare(
416-
level-zero-loader
417-
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
418-
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
419-
EXCLUDE_FROM_ALL)
420-
# Only populate the repo - we don't need to build it
421-
FetchContent_Populate(level-zero-loader)
415+
416+
# We don't want to build and include Level Zero binaries to our install
417+
# target. For CMake >= 3.28 we use EXCLUDE_FROM_ALL flag to do that, but
418+
# for older versions we need to use FetchContent_Populate.
419+
if(CMAKE_VERSION VERSION_LESS 3.28)
420+
FetchContent_Declare(
421+
level-zero-loader
422+
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
423+
GIT_TAG ${LEVEL_ZERO_LOADER_TAG})
424+
FetchContent_Populate(level-zero-loader)
425+
else()
426+
FetchContent_Declare(
427+
level-zero-loader
428+
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
429+
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
430+
EXCLUDE_FROM_ALL)
431+
FetchContent_MakeAvailable(level-zero-loader)
432+
endif()
422433

423434
set(LEVEL_ZERO_INCLUDE_DIRS
424435
${level-zero-loader_SOURCE_DIR}/include
@@ -457,13 +468,24 @@ if(UMF_BUILD_CUDA_PROVIDER)
457468

458469
message(
459470
STATUS "Fetching CUDA (${CUDA_TAG}) headers from ${CUDA_REPO} ...")
460-
FetchContent_Declare(
461-
cuda-headers
462-
GIT_REPOSITORY ${CUDA_REPO}
463-
GIT_TAG ${CUDA_TAG}
464-
EXCLUDE_FROM_ALL)
465-
# Only populate the repo - we don't need to build it
466-
FetchContent_Populate(cuda-headers)
471+
472+
# We don't want to build and include CUDA binaries to our install
473+
# target. For CMake >= 3.28 we could use EXCLUDE_FROM_ALL flag to do
474+
# that, but for older versions we need to use FetchContent_Populate.
475+
if(CMAKE_VERSION VERSION_LESS 3.28)
476+
FetchContent_Declare(
477+
cuda-headers
478+
GIT_REPOSITORY ${CUDA_REPO}
479+
GIT_TAG ${CUDA_TAG})
480+
FetchContent_Populate(cuda-headers)
481+
else()
482+
FetchContent_Declare(
483+
cuda-headers
484+
GIT_REPOSITORY ${CUDA_REPO}
485+
GIT_TAG ${CUDA_TAG}
486+
EXCLUDE_FROM_ALL)
487+
FetchContent_MakeAvailable(cuda-headers)
488+
endif()
467489

468490
set(CUDA_INCLUDE_DIRS
469491
${cuda-headers_SOURCE_DIR}

examples/cuda_shared_memory/CMakeLists.txt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,23 @@ set(CUDA_REPO "https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
2828
set(CUDA_TAG cuda-12.5.1)
2929
message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")
3030

31-
FetchContent_Declare(
32-
cuda-headers
33-
GIT_REPOSITORY ${CUDA_REPO}
34-
GIT_TAG ${CUDA_TAG}
35-
EXCLUDE_FROM_ALL)
36-
FetchContent_Populate(cuda-headers)
31+
# We don't want to build and include CUDA binaries to our install target. For
32+
# CMake >= 3.28 we use EXCLUDE_FROM_ALL flag to do that, but for older versions
33+
# we need to use FetchContent_Populate.
34+
if(CMAKE_VERSION VERSION_LESS 3.28)
35+
FetchContent_Declare(
36+
cuda-headers
37+
GIT_REPOSITORY ${CUDA_REPO}
38+
GIT_TAG ${CUDA_TAG})
39+
FetchContent_Populate(cuda-headers)
40+
else()
41+
FetchContent_Declare(
42+
cuda-headers
43+
GIT_REPOSITORY ${CUDA_REPO}
44+
GIT_TAG ${CUDA_TAG}
45+
EXCLUDE_FROM_ALL)
46+
FetchContent_MakeAvailable(cuda-headers)
47+
endif()
3748

3849
set(CUDA_INCLUDE_DIRS
3950
${cuda-headers_SOURCE_DIR}

0 commit comments

Comments
 (0)