Skip to content

Commit 6b0e8e8

Browse files
committed
Fix LD_LIBRARY_PATH for tests that use libze_loader
1 parent 7e2544d commit 6b0e8e8

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

benchmark/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ function(add_umf_benchmark)
8686
set_property(TEST ${BENCH_NAME} PROPERTY ENVIRONMENT_MODIFICATION
8787
"${DLL_PATH_LIST}")
8888
endif()
89+
if(LINUX)
90+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
91+
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
92+
# should use it instead of system one.
93+
set_property(
94+
TEST ${BENCH_NAME}
95+
PROPERTY ENVIRONMENT_MODIFICATION
96+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
97+
)
98+
endif()
8999

90100
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
91101
target_compile_definitions(${BENCH_NAME}

examples/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ if(UMF_BUILD_GPU_EXAMPLES
7272
set_property(TEST ${EXAMPLE_NAME} PROPERTY ENVIRONMENT_MODIFICATION
7373
"${DLL_PATH_LIST}")
7474
endif()
75+
if(LINUX)
76+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
77+
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
78+
# should use it instead of system one.
79+
set_property(
80+
TEST ${EXAMPLE_NAME}
81+
PROPERTY ENVIRONMENT_MODIFICATION
82+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
83+
)
84+
endif()
7585
else()
7686
message(STATUS "GPU Level Zero shared memory example requires "
7787
"UMF_BUILD_GPU_EXAMPLES, UMF_BUILD_LEVEL_ZERO_PROVIDER and "
@@ -151,6 +161,16 @@ if(UMF_BUILD_GPU_EXAMPLES
151161
set_property(TEST ${EXAMPLE_NAME} PROPERTY ENVIRONMENT_MODIFICATION
152162
"${DLL_PATH_LIST}")
153163
endif()
164+
if(LINUX)
165+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
166+
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
167+
# should use it instead of system one.
168+
set_property(
169+
TEST ${EXAMPLE_NAME}
170+
PROPERTY ENVIRONMENT_MODIFICATION
171+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
172+
)
173+
endif()
154174
else()
155175
message(
156176
STATUS

examples/ipc_level_zero/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

@@ -69,6 +69,6 @@ if(LINUX)
6969
TEST ${EXAMPLE_NAME}
7070
PROPERTY
7171
ENVIRONMENT_MODIFICATION
72-
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
72+
"LD_LIBRARY_PATH=path_list_prepend:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
7373
)
7474
endif()

examples/level_zero_shared_memory/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

@@ -70,6 +70,6 @@ if(LINUX)
7070
TEST ${EXAMPLE_NAME}
7171
PROPERTY
7272
ENVIRONMENT_MODIFICATION
73-
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
73+
"LD_LIBRARY_PATH=path_list_prepend:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
7474
)
7575
endif()

test/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ function(add_umf_test)
154154
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT_MODIFICATION
155155
"${DLL_PATH_LIST}")
156156
endif()
157+
if(LINUX)
158+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
159+
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
160+
# should use it instead of system one.
161+
set_property(
162+
TEST ${TEST_NAME}
163+
PROPERTY ENVIRONMENT_MODIFICATION
164+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
165+
)
166+
endif()
157167
endfunction()
158168

159169
add_subdirectory(common)
@@ -535,6 +545,16 @@ function(add_umf_ipc_test)
535545
if(NOT UMF_TESTS_FAIL_ON_SKIP)
536546
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_RETURN_CODE 125)
537547
endif()
548+
if(LINUX)
549+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
550+
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
551+
# should use it instead of system one.
552+
set_property(
553+
TEST ${TEST_NAME}
554+
PROPERTY ENVIRONMENT_MODIFICATION
555+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
556+
)
557+
endif()
538558
endfunction()
539559

540560
if(LINUX)
@@ -740,5 +760,15 @@ if(LINUX
740760
"${CMAKE_INSTALL_PREFIX}" "${STANDALONE_CMAKE_OPTIONS}"
741761
${EXAMPLES}
742762
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
763+
if(LINUX)
764+
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is
765+
# required because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so
766+
# and tests should use it instead of system one.
767+
set_property(
768+
TEST umf-standalone_examples
769+
PROPERTY
770+
ENVIRONMENT_MODIFICATION
771+
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib")
772+
endif()
743773
endif()
744774
endif()

0 commit comments

Comments
 (0)