From 5ad96992ef909e6b99d8c693a285f06c9fc645fe Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 18 Jan 2022 07:03:10 +0000 Subject: [PATCH] [mlir][cmake] Use `GNUInstallDirs` to support custom installation dirs I am breaking apart D99484 so the cause of build failures is easier to understand. Differential Revision: https://reviews.llvm.org/D117540 --- mlir/CMakeLists.txt | 6 ++++-- mlir/cmake/modules/AddMLIR.cmake | 3 ++- mlir/cmake/modules/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index b1b79cf..63f69ed 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -1,5 +1,7 @@ # MLIR project. +include(GNUInstallDirs) + # Check if MLIR is built as a standalone project. if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(mlir) @@ -173,7 +175,7 @@ endif() if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/mlir include/mlir-c - DESTINATION include + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT mlir-headers FILES_MATCHING PATTERN "*.def" @@ -184,7 +186,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) ) install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c - DESTINATION include + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT mlir-headers FILES_MATCHING PATTERN "*.def" diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake index 770d2aa..b45c44e 100644 --- a/mlir/cmake/modules/AddMLIR.cmake +++ b/mlir/cmake/modules/AddMLIR.cmake @@ -1,3 +1,4 @@ +include(GNUInstallDirs) include(LLVMDistributionSupport) function(mlir_tablegen ofn) @@ -371,7 +372,7 @@ function(add_mlir_library_install name) ${export_to_mlirtargets} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} - RUNTIME DESTINATION bin + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" # Note that CMake will create a directory like: # objects-${CMAKE_BUILD_TYPE}/obj.LibName # and put object files there. diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt index 6a8dd42..d670399 100644 --- a/mlir/cmake/modules/CMakeLists.txt +++ b/mlir/cmake/modules/CMakeLists.txt @@ -1,3 +1,4 @@ +include(ExtendPath) include(LLVMDistributionSupport) include(FindPrefixFromConfig) @@ -52,8 +53,9 @@ find_prefix_from_config(MLIR_CONFIG_CODE MLIR_INSTALL_PREFIX "${MLIR_INSTALL_PAC set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}") set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") get_config_exports_includes(MLIR MLIR_CONFIG_INCLUDE_EXPORTS) +extend_path(base_includedir "\${MLIR_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}") set(MLIR_CONFIG_INCLUDE_DIRS - "\${MLIR_INSTALL_PREFIX}/include" + "${base_includedir}" ) # Ensure that we are using the installed mlir-tblgen. This might not be MLIR_TABLEGEN_EXE # if we're building with a host-optimized mlir-tblgen (with LLVM_OPTIMIZED_TABLEGEN). -- 2.7.4