nixpkgs-23.11-llvm/llvm/16/lld/gnu-install-dirs.patch

47 lines
2.2 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d6225646fe6..9b5d0b15af13 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,10 +33,22 @@ if(LLD_BUILT_STANDALONE)
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
- # Turn into CACHE PATHs for overwriting
- set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
- set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
- set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
+ # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
+ # LLVM_CONFIG.
+ if (NOT LLVM_CONFIG_FOUND)
+ # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config
+ # path is removed.
+ set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
+ set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+ # N.B. this is just a default value, the CACHE PATHs below can be overridden.
+ set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+ else()
+ set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
+ endif()
+
+ set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
+ set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+ set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree")
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
index d3924f7243d4..42a7cd62281c 100644
--- a/cmake/modules/AddLLD.cmake
+++ b/cmake/modules/AddLLD.cmake
@@ -18,8 +18,8 @@ macro(add_lld_library name)
install(TARGETS ${name}
COMPONENT ${name}
${export_to_lldtargets}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)