aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-12-30 06:22:48 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-12-31 18:57:57 +0000
commit896537048df70762b5b0051a0e1b065a74e8d0ce (patch)
treebbabbda09e4a84e4c8f5d1c8637f6171a4a8611f
parent255ee643a8c559375a9c9787ef7d121790040818 (diff)
downloadllvm-896537048df70762b5b0051a0e1b065a74e8d0ce.zip
llvm-896537048df70762b5b0051a0e1b065a74e8d0ce.tar.gz
llvm-896537048df70762b5b0051a0e1b065a74e8d0ce.tar.bz2
[lld][CMake] Use `GNUInstallDirs` to support custom installation dirs
Extracted from D99484. My new plan is to start from the outside and work inward. Reviewed By: stephenneuendorffer Differential Revision: https://reviews.llvm.org/D115568
-rw-r--r--lld/CMakeLists.txt14
-rw-r--r--lld/cmake/modules/AddLLD.cmake5
-rw-r--r--lld/cmake/modules/CMakeLists.txt4
-rw-r--r--lld/tools/lld/CMakeLists.txt2
4 files changed, 17 insertions, 8 deletions
diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index fb5cfd5..00f8e1b 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(GNUInstallDirs)
+
# Check if lld is built as a standalone project.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(lld)
@@ -34,8 +36,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include")
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
- file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR)
- file(TO_CMAKE_PATH ${LLVM_CMAKE_DIR} LLVM_CMAKE_DIR)
+ file(TO_CMAKE_PATH "${LLVM_OBJ_ROOT}" LLVM_BINARY_DIR)
+ file(TO_CMAKE_PATH "${LLVM_CMAKE_DIR}" LLVM_CMAKE_DIR)
if(NOT EXISTS "${LLVM_CMAKE_DIR}/LLVMConfig.cmake")
message(FATAL_ERROR "LLVMConfig.cmake not found")
@@ -151,7 +153,11 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
"`CMakeFiles'. Please delete them.")
endif()
-list (APPEND CMAKE_MODULE_PATH "${LLD_SOURCE_DIR}/cmake/modules")
+# Add path for custom modules.
+list(INSERT CMAKE_MODULE_PATH 0
+ "${LLD_SOURCE_DIR}/cmake/modules"
+ "${LLD_SOURCE_DIR}/../cmake/Modules"
+ )
include(AddLLD)
@@ -188,7 +194,7 @@ include_directories(BEFORE
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
- DESTINATION include
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING
PATTERN "*.h"
)
diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake
index 9883475..dd2898c 100644
--- a/lld/cmake/modules/AddLLD.cmake
+++ b/lld/cmake/modules/AddLLD.cmake
@@ -1,3 +1,4 @@
+include(GNUInstallDirs)
include(LLVMDistributionSupport)
macro(add_lld_library name)
@@ -19,7 +20,7 @@ macro(add_lld_library name)
${export_to_lldtargets}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
@@ -46,7 +47,7 @@ macro(add_lld_tool name)
get_target_export_arg(${name} LLD export_to_lldtargets)
install(TARGETS ${name}
${export_to_lldtargets}
- RUNTIME DESTINATION bin
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT ${name})
if(NOT CMAKE_CONFIGURATION_TYPES)
diff --git a/lld/cmake/modules/CMakeLists.txt b/lld/cmake/modules/CMakeLists.txt
index 62d03fa..022824e 100644
--- a/lld/cmake/modules/CMakeLists.txt
+++ b/lld/cmake/modules/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(ExtendPath)
+
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention seems to be ${Project}Targets.cmake.
@@ -40,7 +42,7 @@ endforeach(p)
set(LLD_CONFIG_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLD_INSTALL_PACKAGE_DIR}")
set(LLD_CONFIG_LLVM_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
get_config_exports_includes(LLD LLD_CONFIG_INCLUDE_EXPORTS)
-set(LLD_CONFIG_INCLUDE_DIRS "\${LLD_INSTALL_PREFIX}/include")
+extend_path(LLD_CONFIG_INCLUDE_DIRS "\${LLD_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt
index c5c86c6..df48cc0 100644
--- a/lld/tools/lld/CMakeLists.txt
+++ b/lld/tools/lld/CMakeLists.txt
@@ -20,7 +20,7 @@ target_link_libraries(lld
)
install(TARGETS lld
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(NOT LLD_SYMLINKS_TO_CREATE)
set(LLD_SYMLINKS_TO_CREATE