Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 1 | # MLIR project. |
Mark de Wever | cbaa359 | 2023-05-24 16:12:32 | [diff] [blame] | 2 | cmake_minimum_required(VERSION 3.20.0) |
Michał Górny | 9dd01a5 | 2022-10-24 04:31:37 | [diff] [blame] | 3 | |
| 4 | if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) |
| 5 | set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) |
| 6 | endif() |
| 7 | include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake |
| 8 | NO_POLICY_SCOPE) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 9 | |
| 10 | # Check if MLIR is built as a standalone project. |
| 11 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 12 | project(mlir) |
John Ericson | df31ff1 | 2022-01-19 06:45:07 | [diff] [blame] | 13 | set(MLIR_STANDALONE_BUILD TRUE) |
| 14 | endif() |
| 15 | |
| 16 | # Must go below project(..) |
| 17 | include(GNUInstallDirs) |
Mehdi Amini | 0096d17 | 2023-02-07 23:54:27 | [diff] [blame] | 18 | set(CMAKE_CXX_STANDARD 17) |
John Ericson | df31ff1 | 2022-01-19 06:45:07 | [diff] [blame] | 19 | |
| 20 | if(MLIR_STANDALONE_BUILD) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 21 | find_package(LLVM CONFIG REQUIRED) |
| 22 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) |
| 23 | include(HandleLLVMOptions) |
| 24 | include(AddLLVM) |
| 25 | include(TableGen) |
| 26 | |
| 27 | include_directories(${LLVM_INCLUDE_DIRS}) |
| 28 | |
Tom Stellard | a11cd0d | 2022-11-09 16:51:34 | [diff] [blame] | 29 | set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 30 | if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) |
Tom Stellard | a11cd0d | 2022-11-09 16:51:34 | [diff] [blame] | 31 | add_subdirectory(${UNITTEST_DIR} third-party/unittest) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 32 | endif() |
| 33 | |
| 34 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY |
John Ericson | e941b03 | 2022-08-19 02:44:46 | [diff] [blame] | 35 | "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 36 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") |
Michał Górny | f3713a9 | 2022-10-23 17:08:47 | [diff] [blame] | 37 | |
| 38 | set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit") |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 39 | endif() |
| 40 | |
John Ericson | 07b7498 | 2022-06-11 06:11:59 | [diff] [blame] | 41 | set(MLIR_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH |
| 42 | "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") |
| 43 | mark_as_advanced(MLIR_TOOLS_INSTALL_DIR) |
| 44 | |
Ehud Katz | 3e8de2e | 2020-04-12 06:29:07 | [diff] [blame] | 45 | set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) |
| 46 | set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) |
Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 47 | |
Ehud Katz | 3e8de2e | 2020-04-12 06:29:07 | [diff] [blame] | 48 | set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 49 | set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 50 | set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 51 | set(MLIR_TOOLS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 52 | |
John Ericson | 44e3365 | 2022-01-03 02:25:06 | [diff] [blame] | 53 | # Make sure that our source directory is on the current cmake module path so |
| 54 | # that we can include cmake files from this directory. |
| 55 | list(INSERT CMAKE_MODULE_PATH 0 |
| 56 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" |
| 57 | "${LLVM_COMMON_CMAKE_UTILS}/Modules" |
| 58 | ) |
Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 59 | |
Mehdi Amini | 5114d55 | 2020-01-22 00:44:17 | [diff] [blame] | 60 | include(AddMLIR) |
| 61 | |
Mehdi Amini | c3aed0d | 2021-09-25 17:24:55 | [diff] [blame] | 62 | # -BSymbolic is incompatible with TypeID |
| 63 | if("${CMAKE_SHARED_LINKER_FLAGS}" MATCHES "-Bsymbolic[^-]") |
| 64 | message(FATAL_ERROR " MLIR does not support `-Bsymbolic` (see http://llvm.org/pr51420 )," |
| 65 | " try `-Bsymbolic-functions` instead.") |
| 66 | endif() |
| 67 | |
Mehdi Amini | 065047a | 2020-11-04 00:06:28 | [diff] [blame] | 68 | # Forbid implicit function declaration: this may lead to subtle bugs and we |
| 69 | # don't have a reason to support this. |
Fangrui Song | bf14685 | 2020-11-05 02:33:51 | [diff] [blame] | 70 | check_c_compiler_flag("-Werror=implicit-function-declaration" C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION) |
| 71 | append_if(C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION "-Werror=implicit-function-declaration" CMAKE_C_FLAGS) |
Mehdi Amini | 065047a | 2020-11-04 00:06:28 | [diff] [blame] | 72 | |
Ingo Müller | 8406f80 | 2024-03-06 13:15:17 | [diff] [blame] | 73 | # Warn on undefined macros. This is often an indication that an include to |
| 74 | # `mlir-config.h` or similar is missing. |
| 75 | check_c_compiler_flag("-Wundef" C_SUPPORTS_WUNDEF) |
| 76 | append_if(C_SUPPORTS_WUNDEF "-Wundef" CMAKE_C_FLAGS) |
| 77 | append_if(C_SUPPORTS_WUNDEF "-Wundef" CMAKE_CXX_FLAGS) |
| 78 | |
Mehdi Amini | 3bed2a7 | 2021-12-08 05:14:01 | [diff] [blame] | 79 | # Forbid mismatch between declaration and definition for class vs struct. This is |
| 80 | # harmless on Unix systems, but it'll be a ticking bomb for MSVC/Windows systems |
| 81 | # where it creeps into the ABI. |
| 82 | check_c_compiler_flag("-Werror=mismatched-tags" C_SUPPORTS_WERROR_MISMATCHED_TAGS) |
| 83 | append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_C_FLAGS) |
| 84 | append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_CXX_FLAGS) |
| 85 | |
long.chen | 80815df | 2023-10-10 05:20:18 | [diff] [blame] | 86 | # Silence a false positive GCC -Wunused-but-set-parameter warning in constexpr |
| 87 | # cases, by marking SelectedCase as used. See |
| 88 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is |
| 89 | # fixed in GCC 10. |
| 90 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0") |
| 91 | check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER) |
| 92 | append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS) |
| 93 | endif() |
| 94 | |
Stella Laurenzo | 7d82d20 | 2020-01-01 00:32:41 | [diff] [blame] | 95 | # Installing the headers and docs needs to depend on generating any public |
| 96 | # tablegen'd targets. |
Stephen Neuendorffer | 7add6b6 | 2020-04-24 23:42:07 | [diff] [blame] | 97 | # mlir-generic-headers are dialect-independent. |
| 98 | add_custom_target(mlir-generic-headers) |
| 99 | set_target_properties(mlir-generic-headers PROPERTIES FOLDER "Misc") |
| 100 | # mlir-headers may be dialect-dependent. |
Stella Laurenzo | 7d82d20 | 2020-01-01 00:32:41 | [diff] [blame] | 101 | add_custom_target(mlir-headers) |
| 102 | set_target_properties(mlir-headers PROPERTIES FOLDER "Misc") |
Stephen Neuendorffer | 7add6b6 | 2020-04-24 23:42:07 | [diff] [blame] | 103 | add_dependencies(mlir-headers mlir-generic-headers) |
Mehdi Amini | 5e67950 | 2019-12-02 17:17:51 | [diff] [blame] | 104 | add_custom_target(mlir-doc) |
| 105 | |
Nikita Popov | 57a9bcc | 2022-08-03 13:28:49 | [diff] [blame] | 106 | # Only enable execution engine if the native target is available. |
| 107 | if(${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) |
| 108 | set(MLIR_ENABLE_EXECUTION_ENGINE 1) |
| 109 | else() |
| 110 | set(MLIR_ENABLE_EXECUTION_ENGINE 0) |
| 111 | endif() |
| 112 | |
Stephan Herhut | c72c6c3 | 2019-06-26 12:16:11 | [diff] [blame] | 113 | # Build the CUDA conversions and run according tests if the NVPTX backend |
| 114 | # is available |
Fabian Mora | 211c975 | 2023-08-08 19:15:22 | [diff] [blame] | 115 | if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD) |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 116 | set(MLIR_ENABLE_CUDA_CONVERSIONS 1) |
Stephan Herhut | c72c6c3 | 2019-06-26 12:16:11 | [diff] [blame] | 117 | else() |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 118 | set(MLIR_ENABLE_CUDA_CONVERSIONS 0) |
Stephan Herhut | c72c6c3 | 2019-06-26 12:16:11 | [diff] [blame] | 119 | endif() |
Stephan Herhut | c72c6c3 | 2019-06-26 12:16:11 | [diff] [blame] | 120 | |
Wen-Heng (Jack) Chung | 061fb8e | 2020-05-22 21:25:00 | [diff] [blame] | 121 | # Build the ROCm conversions and run according tests if the AMDGPU backend |
Nikita Popov | 57a9bcc | 2022-08-03 13:28:49 | [diff] [blame] | 122 | # is available. |
Krzysztof Drewniak | 6dc2ab9 | 2023-07-13 18:56:35 | [diff] [blame] | 123 | if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD) |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 124 | set(MLIR_ENABLE_ROCM_CONVERSIONS 1) |
Wen-Heng (Jack) Chung | 061fb8e | 2020-05-22 21:25:00 | [diff] [blame] | 125 | else() |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 126 | set(MLIR_ENABLE_ROCM_CONVERSIONS 0) |
Wen-Heng (Jack) Chung | 061fb8e | 2020-05-22 21:25:00 | [diff] [blame] | 127 | endif() |
Wen-Heng (Jack) Chung | 061fb8e | 2020-05-22 21:25:00 | [diff] [blame] | 128 | |
Uday Bondhugula | 587408c | 2021-05-24 03:20:17 | [diff] [blame] | 129 | set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA runner") |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 130 | set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm runner") |
Nishant Patel | 7fa19e6 | 2023-10-26 17:41:09 | [diff] [blame] | 131 | set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl runner") |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 132 | set(MLIR_ENABLE_SPIRV_CPU_RUNNER 0 CACHE BOOL "Enable building the mlir SPIR-V cpu runner") |
| 133 | set(MLIR_ENABLE_VULKAN_RUNNER 0 CACHE BOOL "Enable building the mlir Vulkan runner") |
Fabian Mora | 211c975 | 2023-08-08 19:15:22 | [diff] [blame] | 134 | set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL |
| 135 | "Statically link the nvptxlibrary instead of calling ptxas as a subprocess \ |
| 136 | for compiling PTX to cubin") |
Stephan Herhut | e8b21a7 | 2019-07-04 14:49:52 | [diff] [blame] | 137 | |
Jacques Pienaar | 6ae7f66 | 2024-01-04 04:37:19 | [diff] [blame] | 138 | set(MLIR_ENABLE_PDL_IN_PATTERNMATCH 1 CACHE BOOL "Enable PDL in PatternMatch") |
| 139 | |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 140 | option(MLIR_INCLUDE_TESTS |
| 141 | "Generate build targets for the MLIR unit tests." |
| 142 | ${LLVM_INCLUDE_TESTS}) |
| 143 | |
| 144 | option(MLIR_INCLUDE_INTEGRATION_TESTS |
| 145 | "Generate build targets for the MLIR integration tests.") |
| 146 | |
Stella Laurenzo | a897590 | 2021-10-19 19:22:56 | [diff] [blame] | 147 | set(MLIR_INSTALL_AGGREGATE_OBJECTS 1 CACHE BOOL |
| 148 | "Installs object files needed for add_mlir_aggregate to work out of \ |
| 149 | tree. Package maintainers can disable this to exclude these assets if \ |
| 150 | not desired. Enabling this will result in object files being written \ |
| 151 | under lib/objects-{CMAKE_BUILD_TYPE}.") |
| 152 | |
Stella Laurenzo | c265170 | 2021-11-12 05:18:16 | [diff] [blame] | 153 | set(MLIR_BUILD_MLIR_C_DYLIB 0 CACHE BOOL "Builds libMLIR-C shared library.") |
| 154 | |
Matthias Springer | e6d90a0 | 2023-05-24 14:14:47 | [diff] [blame] | 155 | configure_file( |
| 156 | ${MLIR_MAIN_INCLUDE_DIR}/mlir/Config/mlir-config.h.cmake |
| 157 | ${MLIR_INCLUDE_DIR}/mlir/Config/mlir-config.h) |
| 158 | |
Stella Laurenzo | 722475a | 2020-07-07 06:05:46 | [diff] [blame] | 159 | #------------------------------------------------------------------------------- |
| 160 | # Python Bindings Configuration |
| 161 | # Requires: |
| 162 | # The pybind11 library can be found (set with -DPYBIND_DIR=...) |
Stella Laurenzo | 15481bb | 2020-11-24 17:50:18 | [diff] [blame] | 163 | # The python executable is correct (set with -DPython3_EXECUTABLE=...) |
Stella Laurenzo | 722475a | 2020-07-07 06:05:46 | [diff] [blame] | 164 | #------------------------------------------------------------------------------- |
| 165 | |
Uday Bondhugula | 587408c | 2021-05-24 03:20:17 | [diff] [blame] | 166 | set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL |
Stella Laurenzo | 722475a | 2020-07-07 06:05:46 | [diff] [blame] | 167 | "Enables building of Python bindings.") |
rkayaith | d75ac58 | 2022-03-01 22:51:25 | [diff] [blame] | 168 | set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL |
| 169 | "Prime the python detection by searching for a full 'Development' \ |
| 170 | component first (temporary while diagnosing environment specific Python \ |
| 171 | detection issues)") |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 172 | if(MLIR_ENABLE_BINDINGS_PYTHON) |
Stella Laurenzo | f4f8a67 | 2020-11-21 01:57:46 | [diff] [blame] | 173 | include(MLIRDetectPythonEnv) |
Stella Laurenzo | 3d92722 | 2021-10-13 02:32:48 | [diff] [blame] | 174 | mlir_configure_python_dev_packages() |
Stella Laurenzo | 722475a | 2020-07-07 06:05:46 | [diff] [blame] | 175 | endif() |
| 176 | |
Will Dietz | 02db3cf | 2022-03-19 21:53:59 | [diff] [blame] | 177 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 178 | |
Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 179 | include_directories( "include") |
| 180 | include_directories( ${MLIR_INCLUDE_DIR}) |
| 181 | |
Isuru Fernando | 103678d | 2020-03-14 18:41:12 | [diff] [blame] | 182 | # Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like |
| 183 | # MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included |
| 184 | # from another directory like tools |
Vladislav Vinogradov | aca240b | 2021-01-18 10:54:06 | [diff] [blame] | 185 | add_subdirectory(tools/mlir-linalg-ods-gen) |
River Riddle | 597fde5 | 2022-04-20 05:46:34 | [diff] [blame] | 186 | add_subdirectory(tools/mlir-pdll) |
Jacques Pienaar | 6ae7f66 | 2024-01-04 04:37:19 | [diff] [blame] | 187 | add_subdirectory(tools/mlir-tblgen) |
Martin Storsjö | 112499f | 2022-07-15 21:11:00 | [diff] [blame] | 188 | set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "") |
| 189 | set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "") |
Marius Brehler | 91b6f76 | 2022-08-10 17:19:23 | [diff] [blame] | 190 | set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "") |
| 191 | set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL "") |
Martin Storsjö | 112499f | 2022-07-15 21:11:00 | [diff] [blame] | 192 | |
Jacques Pienaar | 1273af2 | 2019-03-30 05:10:12 | [diff] [blame] | 193 | add_subdirectory(include/mlir) |
| 194 | add_subdirectory(lib) |
Alex Zinenko | 75f239e | 2020-08-05 12:36:16 | [diff] [blame] | 195 | # C API needs all dialects for registration, but should be built before tests. |
| 196 | add_subdirectory(lib/CAPI) |
Alex Zinenko | 14c9207 | 2021-10-14 15:18:28 | [diff] [blame] | 197 | |
Alexandre Rames | 23dc948 | 2020-05-18 16:44:26 | [diff] [blame] | 198 | if (MLIR_INCLUDE_TESTS) |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 199 | add_definitions(-DMLIR_INCLUDE_TESTS) |
Mehdi Amini | 09cfec6 | 2021-02-11 01:17:24 | [diff] [blame] | 200 | add_custom_target(MLIRUnitTests) |
Tom Stellard | a11cd0d | 2022-11-09 16:51:34 | [diff] [blame] | 201 | if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h) |
Michał Górny | 2aa1af9 | 2021-02-02 19:09:45 | [diff] [blame] | 202 | add_subdirectory(unittests) |
| 203 | else() |
| 204 | message(WARNING "gtest not found, unittests will not be available") |
| 205 | endif() |
Alexandre Rames | 23dc948 | 2020-05-18 16:44:26 | [diff] [blame] | 206 | add_subdirectory(test) |
| 207 | endif() |
Valentin Churavy | 7c64f6b | 2020-02-09 03:27:54 | [diff] [blame] | 208 | # Tools needs to come late to ensure that MLIR_ALL_LIBS is populated. |
| 209 | # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so. |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 210 | add_subdirectory(tools) |
Mehdi Amini | 38b71d6 | 2019-04-02 17:02:07 | [diff] [blame] | 211 | |
Uday Bondhugula | 9c21ddb | 2021-05-22 14:25:38 | [diff] [blame] | 212 | if(MLIR_ENABLE_BINDINGS_PYTHON) |
Stella Laurenzo | 9f3f6d7 | 2021-04-28 20:04:17 | [diff] [blame] | 213 | # Python sources: built extensions come in via lib/Bindings/Python |
| 214 | add_subdirectory(python) |
| 215 | endif() |
| 216 | |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 217 | if( LLVM_INCLUDE_EXAMPLES ) |
Mehdi Amini | 38b71d6 | 2019-04-02 17:02:07 | [diff] [blame] | 218 | add_subdirectory(examples) |
| 219 | endif() |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 220 | |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 221 | option(MLIR_INCLUDE_DOCS "Generate build targets for the MLIR docs." |
| 222 | ${LLVM_INCLUDE_DOCS}) |
Jacques Pienaar | e298e21 | 2020-01-25 17:17:31 | [diff] [blame] | 223 | if (MLIR_INCLUDE_DOCS) |
| 224 | add_subdirectory(docs) |
| 225 | endif() |
| 226 | |
Stephen Neuendorffer | b0dce6b | 2020-10-04 22:17:34 | [diff] [blame] | 227 | if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 228 | install(DIRECTORY include/mlir include/mlir-c |
John Ericson | 5ad9699 | 2022-01-18 07:03:10 | [diff] [blame] | 229 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 230 | COMPONENT mlir-headers |
| 231 | FILES_MATCHING |
Kern Handa | aab72f8 | 2020-01-06 09:01:59 | [diff] [blame] | 232 | PATTERN "*.def" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 233 | PATTERN "*.h" |
| 234 | PATTERN "*.inc" |
Kern Handa | cde071c4 | 2019-12-29 17:04:09 | [diff] [blame] | 235 | PATTERN "*.td" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 236 | PATTERN "LICENSE.TXT" |
| 237 | ) |
| 238 | |
| 239 | install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c |
John Ericson | 5ad9699 | 2022-01-18 07:03:10 | [diff] [blame] | 240 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 241 | COMPONENT mlir-headers |
| 242 | FILES_MATCHING |
Mehdi Amini | 5114d55 | 2020-01-22 00:44:17 | [diff] [blame] | 243 | PATTERN "*.def" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 244 | PATTERN "*.h" |
| 245 | PATTERN "*.gen" |
| 246 | PATTERN "*.inc" |
Mehdi Amini | 5114d55 | 2020-01-22 00:44:17 | [diff] [blame] | 247 | PATTERN "*.td" |
Eric Schweitz | 88368a1 | 2019-11-20 05:04:45 | [diff] [blame] | 248 | PATTERN "CMakeFiles" EXCLUDE |
| 249 | PATTERN "config.h" EXCLUDE |
| 250 | ) |
| 251 | |
| 252 | if (NOT LLVM_ENABLE_IDE) |
| 253 | add_llvm_install_targets(install-mlir-headers |
| 254 | DEPENDS mlir-headers |
| 255 | COMPONENT mlir-headers) |
| 256 | endif() |
| 257 | endif() |
Mehdi Amini | 5114d55 | 2020-01-22 00:44:17 | [diff] [blame] | 258 | |
Nathan Lanza | f46ce03 | 2022-06-08 02:55:05 | [diff] [blame] | 259 | # Custom target to install all mlir libraries |
| 260 | add_custom_target(mlir-libraries) |
| 261 | set_target_properties(mlir-libraries PROPERTIES FOLDER "Misc") |
| 262 | |
| 263 | if (NOT LLVM_ENABLE_IDE) |
| 264 | add_llvm_install_targets(install-mlir-libraries |
| 265 | DEPENDS mlir-libraries |
| 266 | COMPONENT mlir-libraries) |
| 267 | endif() |
| 268 | |
| 269 | get_property(MLIR_LIBS GLOBAL PROPERTY MLIR_ALL_LIBS) |
| 270 | if(MLIR_LIBS) |
| 271 | list(REMOVE_DUPLICATES MLIR_LIBS) |
| 272 | foreach(lib ${MLIR_LIBS}) |
| 273 | add_dependencies(mlir-libraries ${lib}) |
| 274 | if(NOT LLVM_ENABLE_IDE) |
| 275 | add_dependencies(install-mlir-libraries install-${lib}) |
| 276 | add_dependencies(install-mlir-libraries-stripped install-${lib}-stripped) |
| 277 | endif() |
| 278 | endforeach() |
| 279 | endif() |
| 280 | |
Mehdi Amini | 5114d55 | 2020-01-22 00:44:17 | [diff] [blame] | 281 | add_subdirectory(cmake/modules) |
Saurabh Jha | fa90c9d | 2022-01-27 21:35:34 | [diff] [blame] | 282 | |
| 283 | if (MLIR_ENABLE_PYTHON_BENCHMARKS) |
| 284 | add_subdirectory(utils/mbr) |
| 285 | endif() |
Michał Górny | 14d9ef2 | 2022-10-19 17:14:59 | [diff] [blame] | 286 | |
| 287 | if(MLIR_STANDALONE_BUILD) |
| 288 | llvm_distribution_add_targets() |
| 289 | endif() |