Skip to content

Commit c1ce21b

Browse files
authored
cmake: allow disabling building with the install name directory
When custom install names and rpaths setups are used they may not work in the build tree as-is (namely when using absolute paths for install names in order to avoid rpath juggling in downstream projects). Add a flag for opting out of this behaviour. See: https://reviews.llvm.org/D42463
1 parent 0b0ed8f commit c1ce21b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

llvm/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
66
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
77
NO_POLICY_SCOPE)
88

9-
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
9+
# Builds with custom install names and installation rpath setups may not work
10+
# in the build tree. Allow these cases to use CMake's default build tree
11+
# behavior by setting `LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE` to do this.
12+
option(LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE "If set, use CMake's default build tree install name directory logic (Darwin only)" OFF)
13+
mark_as_advanced(LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE)
14+
if(NOT LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE)
15+
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
16+
endif()
1017

1118
if(NOT DEFINED LLVM_VERSION_MAJOR)
1219
set(LLVM_VERSION_MAJOR 18)

llvm/docs/CMake.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,13 @@ enabled sub-projects. Nearly all of these variable names begin with
733733
directory contains executables with the expected names, no separate
734734
native versions of those executables will be built.
735735

736+
**LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE**:BOOL
737+
Defaults to ``OFF``. If set to ``ON``, CMake's default logic for library IDs
738+
on Darwin in the build tree will be used. Otherwise the install-time library
739+
IDs will be used in the build tree as well. Mainly useful when other CMake
740+
library ID control variables (e.g., ``CMAKE_INSTALL_NAME_DIR``) are being
741+
set to non-standard values.
742+
736743
**LLVM_OPTIMIZED_TABLEGEN**:BOOL
737744
If enabled and building a debug or asserts build the CMake build system will
738745
generate a Release build tree to build a fully optimized tablegen for use

0 commit comments

Comments
 (0)