Skip to content

Commit e41198f

Browse files
authored
Merge pull request #7 from snrkiwi/fix-rpath
cmake: Correctly set RPATH accounting for OS X and CMake versions
2 parents 18b189e + 9492379 commit e41198f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,19 @@ SET_TARGET_PROPERTIES(${LOG4CPP_LIBRARY_NAME} PROPERTIES VERSION ${VERSION} SOVE
9696
# in dependent libraries/executables. Without this, CMake drops the path and
9797
# the dependency becomes just the lib name (which requires working DYLD_xxx)
9898
SET_TARGET_PROPERTIES(${LOG4CPP_LIBRARY_NAME} PROPERTIES
99-
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
99+
INSTALL_RPATH_USE_LINK_PATH ON)
100+
# Set INSTALL_NAME_DIR for MacOS X to tell users of this library how to find it:
101+
if(APPLE)
102+
if (CMAKE_VERSION VERSION_LESS "3.0.0")
103+
SET_TARGET_PROPERTIES( ${LOG4CPP_LIBRARY_NAME} PROPERTIES
104+
INSTALL_NAME_DIR "@rpath"
105+
)
106+
else()
107+
# cope with CMake 3.x
108+
SET_TARGET_PROPERTIES( ${LOG4CPP_LIBRARY_NAME} PROPERTIES
109+
MACOSX_RPATH ON)
110+
endif()
111+
endif()
100112

101113
ADD_DEFINITIONS(${LOG4CPP_CFLAGS})
102114

0 commit comments

Comments
 (0)