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}") ...@@ -40,9 +40,14 @@ message(STATUS "NGRAPH_API_VERSION ${NGRAPH_API_VERSION}")
set(NGRAPH_INCLUDE_PATH set(NGRAPH_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src
) )
# Suppress an OS X-specific warning.
if (POLICY CMP0042) if (APPLE)
cmake_policy(SET CMP0042 OLD) # Suppress an OS X-specific warning.
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
else()
set(MACOS_RPATH ON)
endif()
endif() endif()
project (ngraph) project (ngraph)
...@@ -151,10 +156,12 @@ set(NGRAPH_INSTALL_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ...@@ -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_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(NGRAPH_INSTALL_DOC "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}") set(NGRAPH_INSTALL_DOC "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}")
set(NGRAPH_INSTALL_BIN "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") set(NGRAPH_INSTALL_BIN "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
if (DEFINED NGRAPH_RPATH) if (NOT APPLE)
set(CMAKE_INSTALL_RPATH "$ORIGIN:${NGRAPH_RPATH}") if (DEFINED NGRAPH_RPATH)
else() set(CMAKE_INSTALL_RPATH "$ORIGIN:${NGRAPH_RPATH}")
set(CMAKE_INSTALL_RPATH "$ORIGIN") else()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
endif() endif()
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
......
...@@ -223,6 +223,8 @@ if (NOT APPLE) ...@@ -223,6 +223,8 @@ if (NOT APPLE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-as-needed") set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-as-needed")
endif() endif()
else()
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-rpath,@loader_path")
endif() endif()
# Defines macro in C++ to load backend plugin # Defines macro in C++ to load backend plugin
......
...@@ -21,6 +21,9 @@ set (SRC ...@@ -21,6 +21,9 @@ set (SRC
add_executable(nbench ${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) target_link_libraries(nbench ngraph)
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
target_link_libraries(nbench cpu_backend) 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