@@ -75,13 +75,26 @@ pybind11_add_module(openfhe
7575# The next line ensures that the installed openfhe module can find its shared library dependencies
7676# in the 'lib/' subdirectory relative to itself without requiring LD_LIBRARY_PATH.
7777### target_link_options(openfhe PRIVATE "-Wl,-rpath=$ORIGIN/lib" "-Wl,--disable-new-dtags")
78- target_link_options (openfhe PRIVATE "-Wl,--enable-new-dtags" "-Wl,-rpath,\$ ORIGIN/lib" )
79-
80- # Also set target RPATH properties (survive install/copying)
81- set_target_properties (openfhe PROPERTIES
82- BUILD_RPATH "\$ ORIGIN/lib"
83- INSTALL_RPATH "\$ ORIGIN/lib"
84- )
78+ if (UNIX AND NOT APPLE )
79+ target_link_options (openfhe PRIVATE "-Wl,--enable-new-dtags" "-Wl,-rpath,\$ ORIGIN/lib" )
80+ # Also set target RPATH properties (survive install/copying)
81+ set_target_properties (openfhe PROPERTIES
82+ BUILD_RPATH "\$ ORIGIN/lib"
83+ INSTALL_RPATH "\$ ORIGIN/lib"
84+ )
85+ elseif (APPLE )
86+ # Enable RPATH use on macOS
87+ set (CMAKE_MACOSX_RPATH ON )
88+ # Set install-time rpath for all targets (unless overridden)
89+ set (CMAKE_INSTALL_RPATH "@loader_path/lib" )
90+
91+ target_link_options (openfhe PRIVATE "-Wl,-rpath,@loader_path/lib" )
92+ # Also set target RPATH properties (survive install/copying)
93+ set_target_properties (openfhe PROPERTIES
94+ BUILD_RPATH "@loader_path/lib"
95+ INSTALL_RPATH "@loader_path/lib"
96+ )
97+ endif ()
8598
8699
87100### Python installation
0 commit comments