From 28f2001328d004a1c5c706fb5acf35b0a4661c37 Mon Sep 17 00:00:00 2001 From: Rob Earhart Date: Tue, 23 Jul 2019 11:21:12 -0700 Subject: [PATCH] PlaidML RPATH fixes (#3287) * Added rpath setting for PlaidML backend * Fix colons * Separate build and install rpath * Explicitly set target properties --- CMakeLists.txt | 4 ++-- src/ngraph/runtime/plaidml/CMakeLists.txt | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33e1779557f..b0d95e0f2c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,12 +306,12 @@ set(NGRAPH_INSTALL_DOC "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}") set(NGRAPH_INSTALL_BIN "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") if (LINUX) if (DEFINED NGRAPH_RPATH) + set(CMAKE_BUILD_RPATH "$ORIGIN:${NGRAPH_RPATH}") set(CMAKE_INSTALL_RPATH "$ORIGIN:${NGRAPH_RPATH}") else() + set(CMAKE_BUILD_RPATH "$ORIGIN") set(CMAKE_INSTALL_RPATH "$ORIGIN") endif() - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) endif() #----------------------------------------------------------------------------------------------- diff --git a/src/ngraph/runtime/plaidml/CMakeLists.txt b/src/ngraph/runtime/plaidml/CMakeLists.txt index aabcca1bbae..d48f2adaf95 100644 --- a/src/ngraph/runtime/plaidml/CMakeLists.txt +++ b/src/ngraph/runtime/plaidml/CMakeLists.txt @@ -74,3 +74,11 @@ target_include_directories(plaidml_backend SYSTEM PUBLIC ${PLAIDML_INCLUDE_DIRS} target_link_libraries(plaidml_backend PUBLIC ngraph libplaidml) install(TARGETS plaidml_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB}) +set(CMAKE_MACOSX_RPATH 1) +if(APPLE) + set_property(TARGET plaidml_backend PROPERTY INSTALL_RPATH "@loader_path/;@loader_path/../../..") +elseif(DEFINED NGRAPH_RPATH) + set_property(TARGET plaidml_backend PROPERTY INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../..;${NGRAPH_RPATH}") +else() + set_property(TARGET plaidml_backend PROPERTY INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../..") +endif()