obs-scripting: Link _obspython as dynamic_lookup on MacOS

_obspython.so currently links directly against python as @rpath/Python
and has 3 common python install paths set as rpaths so it would only
work if a user had python installed at one of those hardcoded paths.

Don't link _obspython against python at all but instead link it with
"-undefined dynamic_lookup" so when it is imported by python all it's
undefined python symbols get resolved at runtime against the user
supplied python instance loaded into the process earlier.

The rpaths aren't needed anymore this way.
This commit is contained in:
Rat 2019-09-26 23:42:33 +02:00
parent e7801e10ba
commit a44ff34ef0
2 changed files with 7 additions and 17 deletions

View file

@ -373,14 +373,6 @@ if (APPLE)
target_link_libraries(obs
Qt5::MacExtras)
set_target_properties(obs PROPERTIES LINK_FLAGS "-pagezero_size 10000 -image_base 100000000")
set_property(
TARGET obs
APPEND
PROPERTY INSTALL_RPATH
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/"
"/Library/Frameworks/Python.framework/Versions/3.6/lib/"
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/"
)
endif()
define_graphic_modules(obs)

View file

@ -42,7 +42,12 @@ if(CMAKE_VERSION VERSION_GREATER 3.7.2)
else()
SWIG_ADD_MODULE(obspython python obspython.i ../cstrcache.cpp ../cstrcache.h)
endif()
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
IF(APPLE)
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs)
ELSE()
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
ENDIF()
function(install_plugin_bin_swig target additional_target)
if(APPLE)
@ -57,14 +62,7 @@ function(install_plugin_bin_swig target additional_target)
PREFIX "")
if (APPLE)
set_property(
TARGET ${additional_target}
APPEND
PROPERTY INSTALL_RPATH
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/"
"/Library/Frameworks/Python.framework/Versions/3.6/lib/"
"/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/"
)
SET_TARGET_PROPERTIES(${additional_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/obspython.py"