From a44ff34ef0fed3313bf2252bfb8eadeda17e13c8 Mon Sep 17 00:00:00 2001 From: Rat <52238970+ratwithacompiler@users.noreply.github.com> Date: Thu, 26 Sep 2019 23:42:33 +0200 Subject: [PATCH] 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. --- UI/CMakeLists.txt | 8 -------- deps/obs-scripting/obspython/CMakeLists.txt | 16 +++++++--------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index a33f9e16d..51b771e56 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -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) diff --git a/deps/obs-scripting/obspython/CMakeLists.txt b/deps/obs-scripting/obspython/CMakeLists.txt index 57b65bdbc..097327329 100644 --- a/deps/obs-scripting/obspython/CMakeLists.txt +++ b/deps/obs-scripting/obspython/CMakeLists.txt @@ -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"