diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eee8e6148f7..63efc7d2fdd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.4.3) if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) project(Clang) + include(GNUInstallDirs) + # Rely on llvm-config. set(CONFIG_OUTPUT) find_program(LLVM_CONFIG "llvm-config") @@ -365,7 +367,7 @@ include_directories(BEFORE if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/clang include/clang-c - DESTINATION include + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.def" PATTERN "*.h" @@ -374,7 +376,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) ) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang - DESTINATION include + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "CMakeFiles" EXCLUDE PATTERN "*.inc" @@ -382,7 +384,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) ) install(PROGRAMS utils/bash-autocomplete.sh - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang ) endif() diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake index c09a8423f9f6..39f37e0097eb 100644 --- a/cmake/modules/AddClang.cmake +++ b/cmake/modules/AddClang.cmake @@ -99,9 +99,9 @@ macro(add_clang_library name) install(TARGETS ${name} COMPONENT ${name} ${export_to_clangtargets} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} - RUNTIME DESTINATION bin) + 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) add_llvm_install_targets(install-${name} @@ -141,7 +141,7 @@ macro(add_clang_tool name) install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${name}) if(NOT CMAKE_CONFIGURATION_TYPES) @@ -156,5 +156,5 @@ endmacro() macro(add_clang_symlink name dest) add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) # Always generate install targets - llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) + llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) endmacro() diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt index 97ba3edea1c5..9d2bc5714af5 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt @@ -142,13 +142,13 @@ install( FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h COMPONENT clang-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) + DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) install( FILES ${cuda_wrapper_files} COMPONENT clang-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers) + DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers) if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's. add_llvm_install_targets(install-clang-headers diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt index d38c7bb28709..c9b5499cb756 100644 --- a/tools/c-index-test/CMakeLists.txt +++ b/tools/c-index-test/CMakeLists.txt @@ -50,7 +50,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH "@executable_path/../../lib") else() - set(INSTALL_DESTINATION bin) + set(INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() install(TARGETS c-index-test diff --git a/tools/clang-check/CMakeLists.txt b/tools/clang-check/CMakeLists.txt index c5ace26c2914..97bdfca7d896 100644 --- a/tools/clang-check/CMakeLists.txt +++ b/tools/clang-check/CMakeLists.txt @@ -20,4 +20,4 @@ target_link_libraries(clang-check ) install(TARGETS clang-check - RUNTIME DESTINATION bin) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/clang-format/CMakeLists.txt b/tools/clang-format/CMakeLists.txt index a295e8cd0b2a..1973ff82c7f6 100644 --- a/tools/clang-format/CMakeLists.txt +++ b/tools/clang-format/CMakeLists.txt @@ -21,20 +21,20 @@ if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) endif() install(PROGRAMS clang-format-bbedit.applescript - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-format) install(PROGRAMS clang-format-diff.py - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-format) install(PROGRAMS clang-format-sublime.py - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-format) install(PROGRAMS clang-format.el - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-format) install(PROGRAMS clang-format.py - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-format) install(PROGRAMS git-clang-format - DESTINATION bin + DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clang-format) diff --git a/tools/clang-func-mapping/CMakeLists.txt b/tools/clang-func-mapping/CMakeLists.txt index ae28e28d532d..8ecb2e37a8f7 100644 --- a/tools/clang-func-mapping/CMakeLists.txt +++ b/tools/clang-func-mapping/CMakeLists.txt @@ -20,4 +20,4 @@ target_link_libraries(clang-func-mapping ) install(TARGETS clang-func-mapping - RUNTIME DESTINATION bin) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/clang-offload-bundler/CMakeLists.txt b/tools/clang-offload-bundler/CMakeLists.txt index 8718015be76a..7a038f39622e 100644 --- a/tools/clang-offload-bundler/CMakeLists.txt +++ b/tools/clang-offload-bundler/CMakeLists.txt @@ -22,4 +22,4 @@ target_link_libraries(clang-offload-bundler ${CLANG_OFFLOAD_BUNDLER_LIB_DEPS} ) -install(TARGETS clang-offload-bundler RUNTIME DESTINATION bin) +install(TARGETS clang-offload-bundler RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/clang-refactor/CMakeLists.txt b/tools/clang-refactor/CMakeLists.txt index d2029066b9b7..9bc152a675af 100644 --- a/tools/clang-refactor/CMakeLists.txt +++ b/tools/clang-refactor/CMakeLists.txt @@ -21,4 +21,4 @@ target_link_libraries(clang-refactor clangToolingRefactor ) -install(TARGETS clang-refactor RUNTIME DESTINATION bin) +install(TARGETS clang-refactor RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/clang-rename/CMakeLists.txt b/tools/clang-rename/CMakeLists.txt index 9689e1c6804d..6087716510a9 100644 --- a/tools/clang-rename/CMakeLists.txt +++ b/tools/clang-rename/CMakeLists.txt @@ -16,8 +16,8 @@ target_link_libraries(clang-rename ) install(PROGRAMS clang-rename.py - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-rename) install(PROGRAMS clang-rename.el - DESTINATION share/clang + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-rename) diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt index 44406378207b..3b64b18ad4a5 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt @@ -130,7 +130,7 @@ endif() if(INTERNAL_INSTALL_PREFIX) set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include") else() - set(LIBCLANG_HEADERS_INSTALL_DESTINATION include) + set(LIBCLANG_HEADERS_INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() install(DIRECTORY ../../include/clang-c diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt index 380379300b09..adfd58ed5f7d 100644 --- a/tools/scan-build/CMakeLists.txt +++ b/tools/scan-build/CMakeLists.txt @@ -41,7 +41,7 @@ if(CLANG_INSTALL_SCANBUILD) ${CMAKE_BINARY_DIR}/bin/ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) - install(PROGRAMS bin/${BinFile} DESTINATION bin) + install(PROGRAMS bin/${BinFile} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach() foreach(LibexecFile ${LibexecFiles}) @@ -53,7 +53,7 @@ if(CLANG_INSTALL_SCANBUILD) ${CMAKE_BINARY_DIR}/libexec/ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}) - install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec) + install(PROGRAMS libexec/${LibexecFile} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) endforeach() foreach(ManPage ${ManPages}) @@ -77,7 +77,7 @@ if(CLANG_INSTALL_SCANBUILD) ${CMAKE_BINARY_DIR}/share/scan-build/ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}) - install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build) + install(FILES share/scan-build/${ShareFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-build) endforeach() add_custom_target(scan-build ALL DEPENDS ${Depends}) diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt index b305ca562a72..554bcb379061 100644 --- a/tools/scan-view/CMakeLists.txt +++ b/tools/scan-view/CMakeLists.txt @@ -21,7 +21,7 @@ if(CLANG_INSTALL_SCANVIEW) ${CMAKE_BINARY_DIR}/bin/ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) - install(PROGRAMS bin/${BinFile} DESTINATION bin) + install(PROGRAMS bin/${BinFile} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach() foreach(ShareFile ${ShareFiles}) @@ -33,7 +33,7 @@ if(CLANG_INSTALL_SCANVIEW) ${CMAKE_BINARY_DIR}/share/scan-view/ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile}) - install(FILES share/${ShareFile} DESTINATION share/scan-view) + install(FILES share/${ShareFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/scan-view) endforeach() add_custom_target(scan-view ALL DEPENDS ${Depends})