Skip to content

Commit 47bca4f

Browse files
committed
Make the custom_file_provider example standalone
Make the custom_file_provider example standalone: - add own standalone CMakeLists.txt file - add this example to the umf-standalone_examples test. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent 303f8cb commit 47bca4f

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (C) 2024 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+
project(umf_example_custom_file_provider 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()
23+
24+
pkg_check_modules(TBB tbb)
25+
if(NOT TBB_FOUND)
26+
find_package(TBB REQUIRED tbb)
27+
endif()
28+
29+
# build the example
30+
set(EXAMPLE_NAME umf_example_custom_file_provider)
31+
add_executable(${EXAMPLE_NAME} custom_file_provider.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}
35+
${LIBHWLOC_LIBRARIES})
36+
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")
43+
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()

test/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,15 @@ if(LINUX
494494
OR UMF_USE_UBSAN
495495
OR UMF_USE_TSAN
496496
OR UMF_USE_MSAN))
497+
497498
set(EXAMPLES "")
499+
498500
if(UMF_POOL_SCALABLE_ENABLED)
499-
set(EXAMPLES ${EXAMPLES} basic)
501+
set(EXAMPLES ${EXAMPLES} basic custom_file_provider)
500502
else()
501503
message(
502504
STATUS
503-
"The basic example requires TBB to be installed and added to the default library search path - skipping"
505+
"The basic and custom_file_provider examples require TBB to be installed and added to the default library search path - skipping"
504506
)
505507
endif()
506508

0 commit comments

Comments
 (0)