diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-10-07 20:06:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-10-26 13:27:29 (GMT) |
commit | 95bd6317bc199135775a2f19ee7890d3e6991e3d (patch) | |
tree | 03aa603bb0dc380a0a29184d434013ccb99e4577 /Modules | |
parent | c9b8c792719b2c46abf33f0ff0223db51453bf8f (diff) | |
download | CMake-95bd6317bc199135775a2f19ee7890d3e6991e3d.zip CMake-95bd6317bc199135775a2f19ee7890d3e6991e3d.tar.gz CMake-95bd6317bc199135775a2f19ee7890d3e6991e3d.tar.bz2 |
RPATH: Record support for $ORIGIN on various *BSD
All of NetBSD, FreeBSD, OpenBSD and DragonFly BSD support `$ORIGIN`,
but the last two require `-z origin` as documented at
https://lekensteyn.nl/rpath.html
The `-z origin` option causes a flag bit to be set and has no effect if
the `RPATH` does not contain expandable tokens.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Platform/DragonFly.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/FreeBSD.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/NetBSD.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/OpenBSD.cmake | 4 |
4 files changed, 11 insertions, 0 deletions
diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake index c22677b..12e5f3c 100644 --- a/Modules/Platform/DragonFly.cmake +++ b/Modules/Platform/DragonFly.cmake @@ -3,3 +3,7 @@ # see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361 include(Platform/FreeBSD) + +# DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for FreeBSD since 10.2-RELEASE. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index ce4d3ce..082e9f6 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -6,6 +6,8 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +# Does not require -z origin since 10.2-RELEASE +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 1004eb3..a8f4cc8 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -6,6 +6,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 6466a0a..97e2a6a 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -15,6 +15,10 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH) "${LDCONFIG_HINTS}") endif() +# OpenBSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for NetBSD. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) # OpenBSD has no multilib |