Set RUNPATH on CUDA and XPU tests (#144305)

#136627 has almost fixed the issue that test binaries' runpath has not been set correctly, with few cases left.

This PR fixes the rest.

The binaries are found by `auditwheel repair` a wheel built with `BUILD_TEST=1`.

@malfet

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144305
Approved by: https://github.com/malfet
This commit is contained in:
Yichen Yan 2025-01-26 08:40:22 +00:00 committed by PyTorch MergeBot
parent c4523999a1
commit ed015143ef
3 changed files with 4 additions and 2 deletions

View File

@ -18,6 +18,7 @@ if(BUILD_TEST)
target_link_libraries(${test_name} ${C10_CUDA_LIB} ${C10_LIB} gtest_main)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if(INSTALL_TEST)
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
install(TARGETS ${test_name} DESTINATION test)
endif()
endforeach()

View File

@ -14,6 +14,7 @@ if(BUILD_TEST)
target_link_libraries(${test_name} ${C10_XPU_LIB} gtest_main)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if(INSTALL_TEST)
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
install(TARGETS ${test_name} DESTINATION test)
endif()
endforeach()

View File

@ -1787,7 +1787,7 @@ if(BUILD_TEST)
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if(INSTALL_TEST)
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
install(TARGETS ${test_name} DESTINATION test)
# Install PDB files for MSVC builds
if(MSVC AND BUILD_SHARED_LIBS)
@ -1830,7 +1830,7 @@ if(BUILD_TEST)
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if(INSTALL_TEST)
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
install(TARGETS ${test_name} DESTINATION test)
# Install PDB files for MSVC builds
if(MSVC AND BUILD_SHARED_LIBS)