[llvm] cmake: do not force building with the install name dir (PR #65656)
Ben Boeckel via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 30 07:25:13 PDT 2023
https://github.com/mathstuf updated https://github.com/llvm/llvm-project/pull/65656
>From a52e3780dca0705d408505b029930aaaf9479613 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel at kitware.com>
Date: Thu, 7 Sep 2023 14:49:58 -0400
Subject: [PATCH] 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
---
llvm/CMakeLists.txt | 9 ++++++++-
llvm/docs/CMake.rst | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index fa39c7554de1f61..ca98db33c22a7c9 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -6,7 +6,14 @@ set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
NO_POLICY_SCOPE)
-set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+# Builds with custom install names and installation rpath setups may not work
+# in the build tree. Allow these cases to use CMake's default build tree
+# behavior by setting `LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE` to do this.
+option(LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE "If set, use CMake's default build tree install name directory logic (Darwin only)" OFF)
+mark_as_advanced(LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE)
+if(NOT LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE)
+ set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
+endif()
if(NOT DEFINED LLVM_VERSION_MAJOR)
set(LLVM_VERSION_MAJOR 18)
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 4d894212fb11d47..c001677cd7845b2 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -724,6 +724,13 @@ enabled sub-projects. Nearly all of these variable names begin with
directory contains executables with the expected names, no separate
native versions of those executables will be built.
+**LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE**:BOOL
+ Defaults to ``OFF``. If set to ``ON``, CMake's default logic for library IDs
+ on Darwin in the build tree will be used. Otherwise the install-time library
+ IDs will be used in the build tree as well. Mainly useful when other CMake
+ library ID control variables (e.g., ``CMAKE_INSTALL_NAME_DIR``) are being
+ set to non-standard values.
+
**LLVM_OPTIMIZED_TABLEGEN**:BOOL
If enabled and building a debug or asserts build the CMake build system will
generate a Release build tree to build a fully optimized tablegen for use
More information about the llvm-commits
mailing list