Skip to content

Commit 213cf4b

Browse files
committed
CDRIVER-1349 always set rpath on mac
1 parent 9502b85 commit 213cf4b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,25 @@ if (UNIX AND NOT APPLE)
520520
set (SHM_LIB -lrt)
521521
endif ()
522522

523-
if (APPLE)
524-
cmake_policy (SET CMP0042 OLD)
525-
endif ()
523+
# Ensure the default behavior: don't ignore RPATH settings.
524+
set (CMAKE_SKIP_BUILD_RPATH OFF)
525+
526+
# Ensure the default behavior: don't use the final install destination as the
527+
# temporary RPATH for executables (ensure we can run tests and programs from
528+
# the build directory).
529+
530+
set (CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
531+
# Include any custom library paths in the final RPATH.
532+
533+
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
534+
# Install libs with names like @rpath/libmongoc-1.0.0.dylib, not bare names.
535+
536+
set (CMAKE_MACOSX_RPATH ON)
537+
538+
# https://cmake.org/cmake/help/v3.11/policy/CMP0042.html
539+
# Enable a CMake 3.0+ policy that sets CMAKE_MACOSX_RPATH by default, and
540+
# silence a CMake 3.11 warning that the old behavior is deprecated.
541+
cmake_policy (SET CMP0042 NEW)
526542

527543
if (MSVC)
528544
add_definitions (-D_CRT_SECURE_NO_WARNINGS)

0 commit comments

Comments
 (0)