Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
Update mac build to ease the rpath issues
Browse files Browse the repository at this point in the history
Summary:
TSIA - for rationale, see comments.
Closes #272

Differential Revision: D4905583

Pulled By: Yangqing

fbshipit-source-id: f6cdbc6b51512da03a4aec3f53de720d35c948b6
  • Loading branch information
Yangqing authored and facebook-github-bot committed Apr 18, 2017
1 parent e2efb83 commit f6bbde0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ endfunction(prepend)

# ---[ CMake scripts + modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
set(CMAKE_MACOSX_RPATH 1)

enable_testing()

Expand Down
17 changes: 17 additions & 0 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ if (BUILD_PYTHON)
target_link_libraries(
caffe2_pybind11_state ${Caffe2_MAIN_LIBS} ${Caffe2_DEPENDENCY_LIBS}
${Caffe2_PYTHON_DEPENDENCY_LIBS})
# Add rpath to the python target, so that we will be able to load it. This
# is in order to ease the problem of anaconda's ipython DYLD bug, detailed
# here:
# https://github.com/BVLC/caffe/issues/2720
# https://github.com/ipython/ipython/issues/8878
if (APPLE)
add_custom_command(
TARGET caffe2_pybind11_state POST_BUILD
COMMAND install_name_tool -add_rpath ${CMAKE_INSTALL_PREFIX}/lib
$<TARGET_FILE:caffe2_pybind11_state>)
endif()
install(
TARGETS caffe2_pybind11_state DESTINATION
${CMAKE_INSTALL_PREFIX}/caffe2/python)
Expand All @@ -180,6 +191,12 @@ if (BUILD_PYTHON)
target_link_libraries(
caffe2_pybind11_state_gpu ${Caffe2_MAIN_LIBS} ${Caffe2_DEPENDENCY_LIBS}
${Caffe2_PYTHON_DEPENDENCY_LIBS})
if (APPLE)
add_custom_command(
TARGET caffe2_pybind11_state_gpu POST_BUILD
COMMAND install_name_tool -add_rpath ${CMAKE_INSTALL_PREFIX}/lib
$<TARGET_FILE:caffe2_pybind11_state_gpu>)
endif()
install(
TARGETS caffe2_pybind11_state_gpu DESTINATION
${CMAKE_INSTALL_PREFIX}/caffe2/python)
Expand Down

0 comments on commit f6bbde0

Please sign in to comment.