File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,14 @@ function(SP3_add_python_module)
149149 INSTALL_RPATH "${CMAKE_INSTALL_PREFIX} /${LIBRARY_OUTPUT_DIRECTORY} "
150150 )
151151
152+ if (APPLE )
153+ set_target_properties (
154+ ${PROJECT_NAME}
155+ PROPERTIES
156+ INSTALL_NAME_DIR "@rpath/${SP3_PYTHON_PACKAGES_DIRECTORY} /${DESTINATION} "
157+ )
158+ endif ()
159+
152160 if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "MSVC" )
153161 set_target_properties (
154162 ${A_TARGET}
Original file line number Diff line number Diff line change @@ -98,6 +98,22 @@ message("-- Python user site: ${PYTHON_USER_SITE}")
9898message ("-- pybind11 version: ${pybind11_VERSION} " )
9999message ("-- pybind11 config: ${pybind11_CONFIG} " )
100100
101+ # When using python3 from XCode on MacOS, the RPath is wrongly set to XCode frameworks directory:
102+ # LC_LOAD_DYLIB @rpath/Python3.framework/Versions/3.7/Python3
103+ # LC_RPATH /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib
104+ # Hence LC_RPATH/LC_LOAD_DYLIB does not exists.
105+ # Until this is fixed (not sure if it comes from pybind11, cmake or XCode), we can add another path to RPATH:
106+ # LC_LOAD_DYLIB @rpath/Python3.framework/Versions/3.7/Python3
107+ # LC_RPATH /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib
108+ # /Applications/Xcode.app/Contents/Developer/Library/Frameworks <----- ADDED
109+ # And now one combination of LC_RPATH/LC_LOAD_DYLIB will be valid.
110+ # This should't change anything for those that use other python libs than XCode (homebrew for example) since the
111+ # LC_LOAD_DYLIB from XCode is quite unique.
112+ if (APPLE )
113+ set (CMAKE_INSTALL_RPATH "/Applications/Xcode.app/Contents/Developer/Library/Frameworks" )
114+ set (CMAKE_BUILD_RPATH "/Applications/Xcode.app/Contents/Developer/Library/Frameworks" )
115+ endif ()
116+
101117add_subdirectory (Plugin)
102118add_subdirectory (bindings)
103119add_subdirectory (examples)
You can’t perform that action at this time.
0 commit comments