diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt --- 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) @@ -188,7 +190,7 @@ 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 --- 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 @@ ${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 @@ 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 --- a/lld/cmake/modules/CMakeLists.txt +++ b/lld/cmake/modules/CMakeLists.txt @@ -26,6 +26,18 @@ set(LLD_CONFIG_CMAKE_DIR) set(LLD_CONFIG_LLVM_CMAKE_DIR) +function(extend_delayed_install_path joined_path current_segment) + if("${current_segment}" STREQUAL "") + set(temp_path "\${LLD_INSTALL_PREFIX}") + elseif(IS_ABSOLUTE "${current_segment}") + message(WARNING "Since \"${current_segment}\" is absolute, it overrides LLD_INSTALL_PREFIX") + set(temp_path "${current_segment}") + else() + set(temp_path "\${LLD_INSTALL_PREFIX}/${current_segment}") + endif() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction() + # Generate LLDConfig.cmake for the install tree. set(LLD_CONFIG_CODE " # Compute the installation prefix from this LLVMConfig.cmake file location. @@ -40,7 +52,7 @@ 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_delayed_install_path(LLD_CONFIG_INCLUDE_DIRS "${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 --- a/lld/tools/lld/CMakeLists.txt +++ b/lld/tools/lld/CMakeLists.txt @@ -20,7 +20,7 @@ ) install(TARGETS lld - RUNTIME DESTINATION bin) + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") if(NOT LLD_SYMLINKS_TO_CREATE) set(LLD_SYMLINKS_TO_CREATE