From 8323ef0235ff083a46aae153118200ad3157a2a3 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 30 Aug 2024 12:21:29 -0400 Subject: [PATCH] Fix RPATH on autoschedulers --- packaging/CMakeLists.txt | 46 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 6222dc3acfc4..e86d09d72ebb 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -17,6 +17,25 @@ set(Halide_INSTALL_PLUGINDIR "${CMAKE_INSTALL_LIBDIR}" set(Halide_INSTALL_TOOLSDIR "${CMAKE_INSTALL_DATADIR}/tools" CACHE STRING "Path to Halide build-time tools and sources") +## +# RPATH patching helper +## + +function(_Halide_compute_rpath) + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "ORIGIN_DIR;LIB_DIR" "TARGETS") + if (APPLE) + set(rbase @loader_path) + else () + set(rbase $ORIGIN) + endif () + + file(RELATIVE_PATH lib_dir + ${CMAKE_CURRENT_BINARY_DIR}/${ARG_ORIGIN_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${ARG_LIB_DIR}) + + set_target_properties(${ARG_TARGETS} PROPERTIES INSTALL_RPATH "${rbase};${rbase}/${lib_dir}") +endfunction() + ## # Main library exports ## @@ -30,10 +49,20 @@ install(TARGETS Halide Halide_Generator Halide_GenGen FILE_SET HEADERS COMPONENT Halide_Development) if (WITH_AUTOSCHEDULERS) - install(TARGETS Halide_Adams2019 Halide_Li2018 Halide_Mullapudi2016 Halide_Anderson2021 + set(autoschedulers Halide_Adams2019 Halide_Li2018 Halide_Mullapudi2016 Halide_Anderson2021) + + install(TARGETS ${autoschedulers} EXPORT Halide_Interfaces LIBRARY DESTINATION ${Halide_INSTALL_PLUGINDIR} COMPONENT Halide_Runtime NAMELINK_COMPONENT Halide_Development) + + if (NOT CMAKE_INSTALL_RPATH) + _Halide_compute_rpath( + TARGETS ${autoschedulers} + ORIGIN_DIR "${Halide_INSTALL_PLUGINDIR}" + LIB_DIR "${CMAKE_INSTALL_LIBDIR}" + ) + endif () endif () ## @@ -75,21 +104,6 @@ if (WITH_AUTOSCHEDULERS AND WITH_UTILS) ) endif () -function(_Halide_compute_rpath) - cmake_parse_arguments(PARSE_ARGV 0 ARG "" "ORIGIN_DIR;LIB_DIR" "TARGETS") - if (APPLE) - set(rbase @loader_path) - else () - set(rbase $ORIGIN) - endif () - - file(RELATIVE_PATH lib_dir - ${CMAKE_CURRENT_BINARY_DIR}/${ARG_ORIGIN_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${ARG_LIB_DIR}) - - set_target_properties(${ARG_TARGETS} PROPERTIES INSTALL_RPATH "${rbase};${rbase}/${lib_dir}") -endfunction() - if (NOT CMAKE_INSTALL_RPATH) _Halide_compute_rpath( TARGETS ${utils}