Skip to content

Commit be7aa95

Browse files
Support for macOS (#251)
Co-authored-by: Dmitriy Suponitskiy <[email protected]>
1 parent 5b3e86a commit be7aa95

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

CMakeLists.txt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)