[llvm-branch-commits] [llvm] 0ebc1fb - [CMake] Don't enable BUILD_WITH_INSTALL_RPATH when using custom build rpath

Raul Tambre via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 7 22:35:48 PST 2021


Author: Raul Tambre
Date: 2021-01-08T08:31:10+02:00
New Revision: 0ebc1fb29f278db0665423f15c53e6ee9601dddb

URL: https://github.com/llvm/llvm-project/commit/0ebc1fb29f278db0665423f15c53e6ee9601dddb
DIFF: https://github.com/llvm/llvm-project/commit/0ebc1fb29f278db0665423f15c53e6ee9601dddb.diff

LOG: [CMake] Don't enable BUILD_WITH_INSTALL_RPATH when using custom build rpath

When `BUILD_WITH_INSTALL_RPATH` is enabled it prevents using a custom rpath only
for the build tree as the install rpath will be used. This makes it impossible to run a
runtimes build when compiling with Clang and wanting the installed rpath to be
empty (i.e. `-DCMAKE_BUILD_RPATH="<some path>" -DCMAKE_SKIP_INSTALL_RPATH=ON`).

Disable `BUILD_WITH_INSTALL_RPATH` when `CMAKE_BUILD_RPATH` is non-empty to
allow for such build scenarios.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D93177

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index b86fbdaaa6d8..dc06ea14c584 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -865,10 +865,13 @@ macro(add_llvm_executable name)
 
   if(NOT ARG_NO_INSTALL_RPATH)
     llvm_setup_rpath(${name})
-  elseif (LLVM_LOCAL_RPATH)
-    set_target_properties(${name} PROPERTIES
-                          BUILD_WITH_INSTALL_RPATH On
-                          INSTALL_RPATH "${LLVM_LOCAL_RPATH}")
+  else()
+    # Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set.
+    if(NOT "${CMAKE_BUILD_RPATH}" STREQUAL "")
+      set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
+    endif()
+
+    set_property(TARGET ${name} PROPERTY INSTALL_RPATH "${LLVM_LOCAL_RPATH}")
   endif()
 
   if(DEFINED windows_resource_file)
@@ -2113,8 +2116,12 @@ function(llvm_setup_rpath name)
     return()
   endif()
 
+  # Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set.
+  if(NOT "${CMAKE_BUILD_RPATH}" STREQUAL "")
+    set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
+  endif()
+
   set_target_properties(${name} PROPERTIES
-                        BUILD_WITH_INSTALL_RPATH On
                         INSTALL_RPATH "${_install_rpath}"
                         ${_install_name_dir})
 endfunction()


        


More information about the llvm-branch-commits mailing list