Skip to content

Commit 09fb801

Browse files
committed
Test FetchContent of UMF on Linux and Windows
Test FetchContent of UMF on Linux and Windows - on Windows with the 'Ninja' and 'NMake Makefiles' generators. Add the fetch_content example based on the basic example. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 1ae1fe6 commit 09fb801

File tree

7 files changed

+263
-45
lines changed

7 files changed

+263
-45
lines changed

.github/workflows/pr_push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
uses: ./.github/workflows/reusable_qemu.yml
6464
with:
6565
short_run: true
66+
FetchContent:
67+
needs: [FastBuild]
68+
uses: ./.github/workflows/reusable_fetch_content.yml
6669
ProxyLib:
6770
needs: [Build]
6871
uses: ./.github/workflows/reusable_proxy_lib.yml
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Test FetchContent of UMF on Linux and Windows (on Windows with the 'Ninja' and 'NMake Makefiles' generators)
2+
name: FetchContent
3+
4+
on: workflow_call
5+
6+
permissions:
7+
contents: read
8+
packages: read
9+
10+
env:
11+
WORK_DIR : "${{github.workspace}}/examples/fetch_content"
12+
BUILD_DIR : "${{github.workspace}}/examples/fetch_content/build"
13+
14+
jobs:
15+
Linux-FetchContent:
16+
runs-on: ubuntu-latest
17+
container:
18+
image: ghcr.io/bb-ur/umf-${{ matrix.os }}:latest
19+
options: --user test_user --cap-add=SYS_NICE --cap-add=SYS_PTRACE
20+
volumes:
21+
- ${{ github.workspace }}:${{ github.workspace }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: ['ubuntu-22.04', 'ubuntu-24.04']
26+
build_type: [Debug, Release]
27+
name: FetchContent-Linux (${{matrix.os}}, build_type=${{matrix.build_type}})
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Configure the fetch_content example
36+
working-directory: ${{env.WORK_DIR}}
37+
# Fetch_Content the UMF code from the current repository (-DUMF_REPO="${{github.workspace}}")
38+
run: >
39+
cmake
40+
-B ${{env.BUILD_DIR}}
41+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
42+
-DUMF_REPO="${{github.workspace}}"
43+
44+
- name: Build the fetch_content example
45+
working-directory: ${{env.WORK_DIR}}
46+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $(nproc)
47+
48+
- name: Run the fetch_content example
49+
working-directory: ${{env.BUILD_DIR}}
50+
run: ./umf_example_fetch_content
51+
52+
# Build and test the fetch_content example with different CMake generators on Windows
53+
Windows-FetchContent:
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
build_type: [Debug, Release]
58+
generator: ['Ninja', 'NMake Makefiles']
59+
name: FetchContent-Windows (generator=${{matrix.generator}}, build_type=${{matrix.build_type}})
60+
runs-on: windows-latest
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Set VCPKG_PATH
69+
run: echo "VCPKG_PATH=${{env.BUILD_DIR}}/vcpkg/packages/hwloc_x64-windows;${{env.BUILD_DIR}}/vcpkg/packages/tbb_x64-windows;${{env.BUILD_DIR}}/vcpkg/packages/jemalloc_x64-windows" >> $env:GITHUB_ENV
70+
71+
- name: Initialize vcpkg
72+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
73+
env:
74+
VCPKG_PATH: ${{env.VCPKG_PATH}}
75+
with:
76+
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
77+
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
78+
vcpkgJsonGlob: '**/vcpkg.json'
79+
80+
- name: Install dependencies
81+
run: vcpkg install --triplet x64-windows
82+
83+
- name: Install Ninja
84+
if: matrix.generator == 'Ninja'
85+
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
86+
87+
- name: Configure MSVC environment
88+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
89+
90+
- name: Configure the fetch_content example
91+
working-directory: ${{env.WORK_DIR}}
92+
# Fetch_Content the UMF code from the current repository (-DUMF_REPO="${{github.workspace}}")
93+
run: >
94+
cmake
95+
-B ${{env.BUILD_DIR}}
96+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
97+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
98+
-DUMF_REPO=${{github.workspace}}
99+
-DCMAKE_C_COMPILER=cl
100+
-DCMAKE_CXX_COMPILER=cl
101+
-G "${{matrix.generator}}"
102+
103+
- name: Build the fetch_content example
104+
working-directory: ${{env.WORK_DIR}}
105+
shell: cmd
106+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS%
107+
108+
- name: Run the fetch_content example
109+
shell: cmd
110+
working-directory: ${{env.BUILD_DIR}}
111+
run: dir .\umf_example_fetch_content.exe

examples/basic/CMakeLists.txt

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
1-
# Copyright (C) 2024 Intel Corporation
1+
# Copyright (C) 2024-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

55
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
6-
project(umf_example_basic LANGUAGES C)
7-
enable_testing()
8-
9-
set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..")
10-
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake")
11-
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
12-
13-
find_package(PkgConfig)
14-
pkg_check_modules(LIBUMF libumf)
15-
if(NOT LIBUMF_FOUND)
16-
find_package(LIBUMF REQUIRED libumf)
17-
endif()
18-
19-
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
20-
if(NOT LIBHWLOC_FOUND)
21-
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
22-
endif()
236

24-
pkg_check_modules(TBB tbb)
25-
if(NOT TBB_FOUND)
26-
find_package(TBB REQUIRED tbb)
27-
endif()
28-
29-
# build the example
7+
project(umf_example_basic LANGUAGES C)
308
set(EXAMPLE_NAME umf_example_basic)
31-
add_executable(${EXAMPLE_NAME} basic.c)
32-
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS})
33-
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})
34-
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc)
35-
36-
# an optional part - adds a test of this example
37-
add_test(
38-
NAME ${EXAMPLE_NAME}
39-
COMMAND ${EXAMPLE_NAME}
40-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
41-
42-
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
439

44-
if(LINUX)
45-
# set LD_LIBRARY_PATH
46-
set_property(
47-
TEST ${EXAMPLE_NAME}
48-
PROPERTY
49-
ENVIRONMENT_MODIFICATION
50-
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
51-
)
52-
endif()
10+
include("${CMAKE_SOURCE_DIR}/../basic/include.cmake")

examples/basic/find_umf.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
pkg_check_modules(LIBUMF libumf)
6+
if(NOT LIBUMF_FOUND)
7+
find_package(LIBUMF REQUIRED libumf)
8+
endif()

examples/basic/include.cmake

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright (C) 2024-2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
# This file is used by two examples: basic and fetch_content.
6+
7+
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
8+
enable_testing()
9+
10+
set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..")
11+
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake")
12+
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
13+
14+
find_package(PkgConfig)
15+
16+
include("find_umf.cmake")
17+
if(NOT LIBUMF_FOUND)
18+
message(FATAL_ERROR "libumf NOT found!")
19+
endif()
20+
21+
message(STATUS "Found libumf:")
22+
message(STATUS " LIBUMF_LIBRARIES = ${LIBUMF_LIBRARIES}")
23+
message(STATUS " LIBUMF_INCLUDE_DIRS = ${LIBUMF_INCLUDE_DIRS}")
24+
message(STATUS " LIBUMF_LIBRARY_DIRS = ${LIBUMF_LIBRARY_DIRS}")
25+
26+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
27+
if(NOT LIBHWLOC_FOUND)
28+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
29+
endif()
30+
31+
pkg_check_modules(TBB tbb)
32+
if(NOT TBB_FOUND)
33+
find_package(TBB REQUIRED tbb)
34+
endif()
35+
36+
# build the example (the basic.c source file is used by two examples: basic and
37+
# fetch_content)
38+
add_executable(${EXAMPLE_NAME} ${CMAKE_SOURCE_DIR}/../basic/basic.c)
39+
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS})
40+
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})
41+
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc)
42+
43+
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
44+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
45+
endif()
46+
47+
# an optional part - adds a test of this example
48+
add_test(
49+
NAME ${EXAMPLE_NAME}
50+
COMMAND ${EXAMPLE_NAME}
51+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
52+
53+
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
54+
55+
if(LINUX)
56+
# set LD_LIBRARY_PATH
57+
set_property(
58+
TEST ${EXAMPLE_NAME}
59+
PROPERTY
60+
ENVIRONMENT_MODIFICATION
61+
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
62+
)
63+
endif()

examples/fetch_content/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
6+
7+
project(umf_example_fetch_content LANGUAGES C)
8+
set(EXAMPLE_NAME umf_example_fetch_content)
9+
10+
include("${CMAKE_SOURCE_DIR}/../basic/include.cmake")

examples/fetch_content/find_umf.cmake

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
message(STATUS "Downloading Unified Memory Framework ...")
6+
7+
include(FetchContent)
8+
9+
if(NOT DEFINED UMF_REPO)
10+
set(UMF_REPO "https://github.com/oneapi-src/unified-memory-framework.git")
11+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
12+
string(REPLACE "\\" "/" OUT_UMF_REPO "${UMF_REPO}")
13+
message(
14+
STATUS
15+
"Replaced \"${UMF_REPO}\" with \"${OUT_UMF_REPO}\" for Windows compatibility"
16+
)
17+
set(UMF_REPO "${OUT_UMF_REPO}")
18+
endif()
19+
20+
if(NOT DEFINED UMF_TAG)
21+
set(UMF_TAG HEAD)
22+
endif()
23+
24+
message(
25+
STATUS
26+
"Will fetch Unified Memory Framework from ${UMF_REPO} at ${UMF_TAG} ..."
27+
)
28+
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
29+
30+
FetchContent_Declare(
31+
unified-memory-framework
32+
GIT_REPOSITORY ${UMF_REPO}
33+
GIT_TAG ${UMF_TAG})
34+
35+
set(UMF_BUILD_TESTS
36+
OFF
37+
CACHE INTERNAL "Do not build UMF tests")
38+
set(UMF_BUILD_EXAMPLES
39+
OFF
40+
CACHE INTERNAL "Do not build UMF examples")
41+
set(UMF_BUILD_SHARED_LIBRARY
42+
OFF
43+
CACHE INTERNAL "Build UMF shared library")
44+
set(UMF_BUILD_LIBUMF_POOL_DISJOINT
45+
ON
46+
CACHE INTERNAL "Build Disjoint Pool")
47+
set(UMF_BUILD_CUDA_PROVIDER
48+
OFF
49+
CACHE INTERNAL "Do not build CUDA provider")
50+
set(UMF_BUILD_LEVEL_ZERO_PROVIDER
51+
OFF
52+
CACHE INTERNAL "Do not build L0 provider")
53+
set(UMF_DISABLE_HWLOC
54+
OFF
55+
CACHE INTERNAL "Enable HWLOC support")
56+
set(UMF_LINK_HWLOC_STATICALLY
57+
OFF
58+
CACHE INTERNAL "UMF_LINK_HWLOC_STATICALLY=OFF")
59+
60+
FetchContent_MakeAvailable(unified-memory-framework)
61+
FetchContent_GetProperties(unified-memory-framework)
62+
63+
set(LIBUMF_INCLUDE_DIRS ${unified-memory-framework_SOURCE_DIR}/include)
64+
set(LIBUMF_LIBRARIES umf::umf umf::headers)
65+
set(LIBUMF_FOUND true)

0 commit comments

Comments
 (0)