Commit 8ee327ca authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Adam Procter

On macos, (#2121)

Use @loader_path for the calling library/executable
Use @rpath for dependent libraries.
parent fea072b7
......@@ -40,9 +40,14 @@ message(STATUS "NGRAPH_API_VERSION ${NGRAPH_API_VERSION}")
set(NGRAPH_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Suppress an OS X-specific warning.
if (POLICY CMP0042)
cmake_policy(SET CMP0042 OLD)
if (APPLE)
# Suppress an OS X-specific warning.
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
else()
set(MACOS_RPATH ON)
endif()
endif()
project (ngraph)
......@@ -151,10 +156,12 @@ set(NGRAPH_INSTALL_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(NGRAPH_INSTALL_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(NGRAPH_INSTALL_DOC "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}")
set(NGRAPH_INSTALL_BIN "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
if (DEFINED NGRAPH_RPATH)
set(CMAKE_INSTALL_RPATH "$ORIGIN:${NGRAPH_RPATH}")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
if (NOT APPLE)
if (DEFINED NGRAPH_RPATH)
set(CMAKE_INSTALL_RPATH "$ORIGIN:${NGRAPH_RPATH}")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
endif()
#-----------------------------------------------------------------------------------------------
......
......@@ -223,6 +223,8 @@ if (NOT APPLE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-as-needed")
endif()
else()
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-rpath,@loader_path")
endif()
# Defines macro in C++ to load backend plugin
......
......@@ -21,6 +21,9 @@ set (SRC
add_executable(nbench ${SRC})
if (APPLE)
set_property(TARGET nbench APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-rpath,@loader_path/../lib")
endif()
target_link_libraries(nbench ngraph)
if (NGRAPH_CPU_ENABLE)
target_link_libraries(nbench cpu_backend)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment