diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index 8f2f55c69c..2411717001 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -75,13 +75,13 @@ add_dependencies(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_depende if (MSVC) # if MSVC, pybind11 looks for release version of python lib (pybind11/detail/common.h undefs _DEBUG) target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${PYTHON_LIBRARY_RELEASE} ${ONNXRUNTIME_SO_LINK_FLAG}) +elseif (APPLE) + set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${ONNXRUNTIME_SO_LINK_FLAG}) + set_target_properties(onnxruntime_pybind11_state PROPERTIES INSTALL_RPATH "@loader_path") else() target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${PYTHON_LIBRARY} ${ONNXRUNTIME_SO_LINK_FLAG}) - if (APPLE) - set_target_properties(onnxruntime_pybind11_state PROPERTIES INSTALL_RPATH "@loader_path") - else() - set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-Xlinker -rpath=\$ORIGIN") - endif() + set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-Xlinker -rpath=\$ORIGIN") endif() set_target_properties(onnxruntime_pybind11_state PROPERTIES PREFIX "") diff --git a/setup.py b/setup.py index ea32fa84bf..2a8954809d 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ except ImportError: bdist_wheel = None # Additional binaries -if platform.system() == 'Linux': +if platform.system() == 'Linux' or platform.system() == 'Darwin': libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.so.0', 'libmklml_intel.so', 'libiomp5.so'] else: libs = ['onnxruntime_pybind11_state.pyd', 'mkldnn.dll', 'mklml.dll', 'libiomp5md.dll']