Skip to content

Commit 0ebc1fb

Browse files
committed
[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
1 parent ae25a39 commit 0ebc1fb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,13 @@ macro(add_llvm_executable name)
865865

866866
if(NOT ARG_NO_INSTALL_RPATH)
867867
llvm_setup_rpath(${name})
868-
elseif (LLVM_LOCAL_RPATH)
869-
set_target_properties(${name} PROPERTIES
870-
BUILD_WITH_INSTALL_RPATH On
871-
INSTALL_RPATH "${LLVM_LOCAL_RPATH}")
868+
else()
869+
# Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set.
870+
if(NOT "${CMAKE_BUILD_RPATH}" STREQUAL "")
871+
set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
872+
endif()
873+
874+
set_property(TARGET ${name} PROPERTY INSTALL_RPATH "${LLVM_LOCAL_RPATH}")
872875
endif()
873876

874877
if(DEFINED windows_resource_file)
@@ -2113,8 +2116,12 @@ function(llvm_setup_rpath name)
21132116
return()
21142117
endif()
21152118

2119+
# Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set.
2120+
if(NOT "${CMAKE_BUILD_RPATH}" STREQUAL "")
2121+
set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
2122+
endif()
2123+
21162124
set_target_properties(${name} PROPERTIES
2117-
BUILD_WITH_INSTALL_RPATH On
21182125
INSTALL_RPATH "${_install_rpath}"
21192126
${_install_name_dir})
21202127
endfunction()

0 commit comments

Comments
 (0)