summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2016-02-09 22:15:30 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2016-02-09 22:15:30 +0000
commit89d9b333b0759fc32a35dd595ea9fa5d39d2ae7e (patch)
tree4eb6ca6acb4c1822d3fef77aac8bc946a82bedd7
parent36ab260b0d9b774d914154c5dda1a211acb0b8ae (diff)
downloadllvm-89d9b333b0759fc32a35dd595ea9fa5d39d2ae7e.tar.gz
Have Mac builds use @rpath when supported in CMake
The -install_name linker flag will use "@rpath/" when supported in CMake which is the recommended usage for dynamic libraries on Mac OSX. llvm-svn: 260300
-rw-r--r--openmp/runtime/CMakeLists.txt8
-rwxr-xr-xopenmp/runtime/tools/check-depends.pl2
2 files changed, 10 insertions, 0 deletions
diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt
index c4875f4cfdf8..641b8f4631b1 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -112,6 +112,14 @@ set(LIBOMP_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING
"For Mac builds, semicolon separated list of architectures to build for universal fat binary.")
set(CMAKE_OSX_ARCHITECTURES ${LIBOMP_OSX_ARCHITECTURES})
+# Should @rpath be used for dynamic libraries on Mac?
+# The if(NOT DEFINED) is there to guard a cached value of the variable if one
+# exists so there is no interference with what the user wants. Also, no cache entry
+# is created so there are no inadvertant effects on other parts of LLVM.
+if(NOT DEFINED CMAKE_MACOSX_RPATH)
+ set(CMAKE_MACOSX_RPATH TRUE)
+endif()
+
# User specified flags. These are appended to the configured flags.
set(LIBOMP_CFLAGS "" CACHE STRING
"Appended user specified C compiler flags.")
diff --git a/openmp/runtime/tools/check-depends.pl b/openmp/runtime/tools/check-depends.pl
index 48e312aa0105..47e7e5a3d356 100755
--- a/openmp/runtime/tools/check-depends.pl
+++ b/openmp/runtime/tools/check-depends.pl
@@ -185,6 +185,8 @@ sub get_deps_otool($) {
or parse_error( $tool, @bulk, $i );
++ $i;
if ( $name =~ m{\.dylib\z} ) {
+ # Added "@rpath/" enables dynamic load of the library designated at link time.
+ $name = '@rpath/' . $name;
# In case of dynamic library otool print the library itself as a dependent library.
( $i < @bulk and $bulk[ $i ] =~ m{^\s+\Q$name\E\s+\(compatibility version.*\)$} )
or parse_error( $tool, @bulk, $i );