Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 1 | # Copyright 2019 Google LLC |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Scott Todd | ee30e1b | 2020-02-03 16:44:15 -0800 | [diff] [blame] | 15 | cmake_minimum_required(VERSION 3.13) |
Geoffrey Martin-Noble | 98bbd96 | 2019-11-21 07:27:39 -0800 | [diff] [blame] | 16 | if(POLICY CMP0077) |
| 17 | cmake_policy(SET CMP0077 NEW) |
| 18 | endif() |
Scott Todd | ee30e1b | 2020-02-03 16:44:15 -0800 | [diff] [blame] | 19 | # Allow target_link_libraries() from other directories (since 3.13): |
| 20 | # https://cmake.org/cmake/help/v3.13/policy/CMP0079.html |
| 21 | if(POLICY CMP0079) |
| 22 | cmake_policy(SET CMP0079 NEW) |
| 23 | endif() |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 24 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 25 | |
Marius Brehler | 178c82a | 2019-12-27 15:00:04 -0800 | [diff] [blame] | 26 | project(iree CXX C) |
Lei Zhang | 6c5907b | 2020-06-02 09:06:08 -0700 | [diff] [blame] | 27 | set(CMAKE_C_STANDARD 11) |
| 28 | set(CMAKE_CXX_STANDARD 14) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 29 | set(IREE_IDE_FOLDER IREE) |
| 30 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 31 | |
Lei Zhang | 7e253da | 2020-06-10 07:51:19 -0700 | [diff] [blame] | 32 | #------------------------------------------------------------------------------- |
| 33 | # Project component configuration |
| 34 | #------------------------------------------------------------------------------- |
| 35 | |
Lei Zhang | e996799 | 2020-06-03 11:13:00 -0400 | [diff] [blame] | 36 | # LINT.IfChange(iree_options) |
Ben Vanik | 56d44bf | 2020-05-15 13:20:50 -0700 | [diff] [blame] | 37 | option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 38 | option(IREE_ENABLE_MLIR "Enables MLIR/LLVM dependencies." ON) |
Marius Brehler | 4e45a77 | 2020-06-02 14:04:18 -0700 | [diff] [blame] | 39 | option(IREE_ENABLE_EMITC "Enables MLIR EmitC dependencies." OFF) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 40 | |
Marius Brehler | edfc57f | 2019-12-18 11:19:38 -0800 | [diff] [blame] | 41 | option(IREE_BUILD_COMPILER "Builds the IREE compiler." ON) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 42 | option(IREE_BUILD_TESTS "Builds IREE unit tests." ON) |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 43 | option(IREE_BUILD_DOCS "Builds IREE docs." OFF) |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 44 | option(IREE_BUILD_SAMPLES "Builds IREE sample projects." ON) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 45 | option(IREE_BUILD_DEBUGGER "Builds the IREE debugger app." OFF) |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 46 | option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" OFF) |
Jenni Kilduff | 0d09cf3 | 2020-10-19 10:23:34 -0700 | [diff] [blame] | 47 | option(IREE_BUILD_JAVA_BINDINGS "Builds the IREE java bindings." OFF) |
Ben Vanik | b64e918 | 2020-01-30 15:19:37 -0800 | [diff] [blame] | 48 | option(IREE_BUILD_EXPERIMENTAL "Builds experimental projects." OFF) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 49 | |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 50 | set(IREE_HAL_DRIVERS_TO_BUILD "all" |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 51 | CACHE STRING "Semicolon-separated list of HAL drivers to build, or \"all\".") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 52 | set(IREE_TARGET_BACKENDS_TO_BUILD "all" |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 53 | CACHE STRING "Semicolon-separated list of target backends to build, or \"all\".") |
Lei Zhang | e71d973 | 2020-06-23 10:21:09 -0400 | [diff] [blame] | 54 | # LINT.ThenChange( |
Scott Todd | 4e5167d | 2020-06-29 09:30:35 -0700 | [diff] [blame] | 55 | # https://github.com/google/iree/tree/main/build_tools/cmake/iree_cross_compile.cmake:iree_cross_compile_options, |
| 56 | # https://github.com/google/iree/tree/main/build_tools/cmake/iree_cross_compile.cmake:iree_cross_compile_invoke |
Lei Zhang | e71d973 | 2020-06-23 10:21:09 -0400 | [diff] [blame] | 57 | # ) |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 58 | |
Ben Vanik | b64e918 | 2020-01-30 15:19:37 -0800 | [diff] [blame] | 59 | if(${IREE_BUILD_SAMPLES} OR ${IREE_BUILD_EXPERIMENTAL}) |
Marius Brehler | edfc57f | 2019-12-18 11:19:38 -0800 | [diff] [blame] | 60 | set(IREE_BUILD_COMPILER ON CACHE BOOL "Build the IREE compiler for sample projects." FORCE) |
| 61 | endif() |
| 62 | |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 63 | if(${IREE_BUILD_COMPILER}) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 64 | set(IREE_ENABLE_MLIR ON CACHE BOOL "Enable LLVM dependencies if the IREE compiler is build." FORCE) |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 65 | endif() |
| 66 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 67 | if (${IREE_ENABLE_MLIR}) |
| 68 | set(IREE_MLIR_DEP_MODE "BUNDLED" CACHE STRING "One of BUNDLED (default), DISABLED, INSTALLED") |
Marius Brehler | 4e45a77 | 2020-06-02 14:04:18 -0700 | [diff] [blame] | 69 | endif() |
| 70 | |
Marius Brehler | fd8be7f | 2020-06-18 15:59:28 -0700 | [diff] [blame] | 71 | if(${IREE_ENABLE_EMITC}) |
| 72 | if(NOT ${IREE_ENABLE_MLIR}) |
| 73 | message(FATAL_ERROR "Enabling EmitC requires setting IREE_ENABLE_MLIR to ON.") |
| 74 | endif() |
| 75 | |
| 76 | string(TOUPPER "${IREE_MLIR_DEP_MODE}" uppercase_IREE_MLIR_DEP_MODE) |
| 77 | if(NOT uppercase_IREE_MLIR_DEP_MODE MATCHES "^(BUNDLED|INSTALLED)$") |
| 78 | message(FATAL_ERROR "Enabling EmitC requires IREE_MLIR_DEP_MODE set to BUNDELED or INSTALLED.") |
| 79 | endif() |
| 80 | endif() |
| 81 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 82 | #------------------------------------------------------------------------------- |
Lei Zhang | 8bea2e8 | 2020-06-04 10:17:56 -0400 | [diff] [blame] | 83 | # Target and backend configuration |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 84 | #------------------------------------------------------------------------------- |
| 85 | |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 86 | # List of all HAL drivers to be built by default: |
| 87 | set(IREE_ALL_HAL_DRIVERS |
Scott Todd | 217904d | 2020-06-04 13:38:32 -0700 | [diff] [blame] | 88 | DyLib |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 89 | LLVM |
Lei Zhang | 6171a98 | 2020-09-08 12:48:25 -0400 | [diff] [blame] | 90 | Metal |
Geoffrey Martin-Noble | dfb7633 | 2020-08-07 11:22:39 -0700 | [diff] [blame] | 91 | VMLA |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 92 | Vulkan |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 93 | ) |
| 94 | |
| 95 | if( IREE_HAL_DRIVERS_TO_BUILD STREQUAL "all" ) |
| 96 | set( IREE_HAL_DRIVERS_TO_BUILD ${IREE_ALL_HAL_DRIVERS} ) |
Lei Zhang | 7d90e0e | 2020-07-23 16:01:13 -0400 | [diff] [blame] | 97 | # For cross compilation towords Android, we don't want LLVM JIT HAL driver. |
| 98 | if(ANDROID) |
Han-Chung Wang | 8cc22a3 | 2020-10-20 08:45:33 -0700 | [diff] [blame] | 99 | list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD LLVM) |
Lei Zhang | 7d90e0e | 2020-07-23 16:01:13 -0400 | [diff] [blame] | 100 | endif() |
Lei Zhang | 6171a98 | 2020-09-08 12:48:25 -0400 | [diff] [blame] | 101 | |
| 102 | # For Apple platforms we need to use Metal instead of Vulkan. |
| 103 | if(APPLE) |
| 104 | list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Vulkan) |
| 105 | else() |
| 106 | # And Metal isn't available on non-Apple platforms for sure. |
| 107 | list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Metal) |
| 108 | endif() |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 109 | endif() |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 110 | message(STATUS "Building HAL drivers: ${IREE_HAL_DRIVERS_TO_BUILD}") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 111 | |
| 112 | # Default every IREE_HAL_DRIVER_* to OFF |
| 113 | foreach(_backend ${IREE_ALL_HAL_DRIVERS}) |
| 114 | string(TOUPPER "${_backend}" uppercase_backend) |
| 115 | set(IREE_HAL_DRIVER_${uppercase_backend} OFF CACHE BOOL "" FORCE) |
| 116 | endforeach() |
| 117 | |
| 118 | # Set IREE_HAL_DRIVER_* based on configuration |
| 119 | foreach(_backend ${IREE_HAL_DRIVERS_TO_BUILD}) |
| 120 | string(TOUPPER "${_backend}" uppercase_backend) |
| 121 | set(IREE_HAL_DRIVER_${uppercase_backend} ON CACHE BOOL "" FORCE) |
| 122 | endforeach() |
| 123 | |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 124 | # Enable HAL driver modules based on options. |
| 125 | set (IREE_HAL_DRIVER_MODULES "") |
| 126 | if(${IREE_HAL_DRIVER_DYLIB}) |
| 127 | list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::dylib::dylib_driver_module) |
| 128 | endif() |
| 129 | if(${IREE_HAL_DRIVER_LLVM}) |
| 130 | list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::llvmjit::llvmjit_driver_module) |
| 131 | endif() |
Lei Zhang | 6171a98 | 2020-09-08 12:48:25 -0400 | [diff] [blame] | 132 | if(${IREE_HAL_DRIVER_METAL}) |
| 133 | list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::metal::metal_driver_module) |
| 134 | endif() |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 135 | if(${IREE_HAL_DRIVER_VMLA}) |
| 136 | list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::vmla::vmla_driver_module) |
| 137 | endif() |
| 138 | if(${IREE_HAL_DRIVER_VULKAN}) |
| 139 | list(APPEND IREE_HAL_DRIVER_MODULES iree::hal::vulkan::vulkan_driver_module) |
| 140 | endif() |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 141 | |
| 142 | # List of all target backends to be built by default: |
| 143 | set(IREE_ALL_TARGET_BACKENDS |
Geoffrey Martin-Noble | e7f90b6 | 2020-07-29 14:32:26 -0700 | [diff] [blame] | 144 | # TODO(#2645): Add DYLIB-LLVM-AOT when it doesn't require an env var |
Lei Zhang | 7d90e0e | 2020-07-23 16:01:13 -0400 | [diff] [blame] | 145 | LLVM-IR |
Lei Zhang | 3cbb28e | 2020-09-22 15:30:27 -0400 | [diff] [blame] | 146 | Metal-SPIRV |
Lei Zhang | 7d90e0e | 2020-07-23 16:01:13 -0400 | [diff] [blame] | 147 | Vulkan-SPIRV |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 148 | VMLA |
| 149 | ) |
| 150 | |
| 151 | if( IREE_TARGET_BACKENDS_TO_BUILD STREQUAL "all" ) |
| 152 | set( IREE_TARGET_BACKENDS_TO_BUILD ${IREE_ALL_TARGET_BACKENDS} ) |
| 153 | endif() |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 154 | message(STATUS "Building target backends: ${IREE_TARGET_BACKENDS_TO_BUILD}") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 155 | |
| 156 | # Default every IREE_TARGET_BACKEND_* to OFF |
| 157 | foreach(_backend ${IREE_ALL_TARGET_BACKENDS}) |
| 158 | string(TOUPPER "${_backend}" uppercase_backend) |
| 159 | set(IREE_TARGET_BACKEND_${uppercase_backend} OFF CACHE BOOL "" FORCE) |
| 160 | endforeach() |
| 161 | |
| 162 | # Set IREE_TARGET_BACKEND_* based on configuration |
| 163 | foreach(_backend ${IREE_TARGET_BACKENDS_TO_BUILD}) |
| 164 | string(TOUPPER "${_backend}" uppercase_backend) |
| 165 | set(IREE_TARGET_BACKEND_${uppercase_backend} ON CACHE BOOL "" FORCE) |
| 166 | endforeach() |
| 167 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 168 | list(APPEND CMAKE_MODULE_PATH |
| 169 | ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 170 | ${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/ |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 171 | ${CMAKE_CURRENT_LIST_DIR}/third_party/abseil-cpp/absl/copts/ |
| 172 | ) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 173 | |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 174 | #------------------------------------------------------------------------------- |
| 175 | # Cross compiling configuration |
| 176 | #------------------------------------------------------------------------------- |
| 177 | |
| 178 | if(CMAKE_CROSSCOMPILING) |
Lei Zhang | 45695f9 | 2020-06-16 19:36:41 -0400 | [diff] [blame] | 179 | message(STATUS "Detected cross compilation mode; configuring IREE on host...") |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 180 | |
| 181 | # C/C++ compilers for host compilation. |
| 182 | # Note: we need to explicitly set this because IREE does not work well with |
| 183 | # GCC at the moment: https://github.com/google/iree/issues/1269 |
| 184 | set(IREE_HOST_C_COMPILER "$ENV{IREE_HOST_C_COMPILER}" CACHE FILEPATH "C compiler for host compilation") |
| 185 | set(IREE_HOST_CXX_COMPILER "$ENV{IREE_HOST_CXX_COMPILER}" CACHE FILEPATH "C++ compiler for host compilation") |
| 186 | |
| 187 | # Master configuration for the binary directory containing all artifacts |
| 188 | # compiled for host. |
Lei Zhang | e71d973 | 2020-06-23 10:21:09 -0400 | [diff] [blame] | 189 | if(NOT IREE_HOST_BINARY_ROOT) |
| 190 | set(IREE_HOST_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}/host" CACHE FILEPATH "directory containing host artifacts") |
| 191 | endif() |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 192 | |
| 193 | set(IREE_HOST_BUILD_COMPILER ON) # For iree-translate |
| 194 | set(IREE_HOST_ENABLE_LLVM ON) # For iree-tblgen |
| 195 | |
| 196 | # Set the host build directory for LLVM to our directory. Otherwise it will |
| 197 | # follow its own convention. |
Lei Zhang | 7f6dfbf | 2020-06-30 14:31:35 -0400 | [diff] [blame] | 198 | set(LLVM_NATIVE_BUILD |
| 199 | "${IREE_HOST_BINARY_ROOT}/third_party/llvm-project/llvm" |
| 200 | CACHE FILEPATH "directory containing host artifacts for LLVM" |
| 201 | ) |
| 202 | |
| 203 | # And set host C/C++ compiler for LLVM. This makes cross compilation using |
| 204 | # Windows as the host platform nicer. Because we have various development |
| 205 | # evnironments on Windows (CMD, Cygwin, MSYS, etc.), LLVM can have problems |
| 206 | # figuring out the host triple and toolchain. We are passing in the host |
| 207 | # C/C++ compiler toolchain for IREE anyway; so we can give LLVM side some |
| 208 | # help here. This hides some complexity and ugliness from the users. |
| 209 | set(CROSS_TOOLCHAIN_FLAGS_NATIVE |
| 210 | "-DCMAKE_C_COMPILER=\"${IREE_HOST_C_COMPILER}\";-DCMAKE_CXX_COMPILER=\"${IREE_HOST_CXX_COMPILER}\"" |
| 211 | CACHE FILEPATH "LLVM toolchain configuration for host build" |
| 212 | ) |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 213 | |
| 214 | include(iree_cross_compile) |
| 215 | |
| 216 | # Use another CMake invocation to configure a build for host. |
| 217 | iree_create_configuration(HOST) |
Lei Zhang | 1e6a7a7 | 2020-06-04 13:12:01 -0400 | [diff] [blame] | 218 | |
Lei Zhang | 45695f9 | 2020-06-16 19:36:41 -0400 | [diff] [blame] | 219 | message(STATUS "Done configuring IREE on host in ${IREE_HOST_BINARY_ROOT}") |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 220 | endif() |
| 221 | |
| 222 | #------------------------------------------------------------------------------- |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 223 | # IREE compilation toolchain configuration |
| 224 | #------------------------------------------------------------------------------- |
| 225 | |
| 226 | # Enable using lld as the linker for C/C++ targets. This affects IREE and all |
| 227 | # dependency projects. |
| 228 | option(IREE_ENABLE_LLD "Use lld when linking" OFF) |
| 229 | option(IREE_ENABLE_ASAN "Enable address sanitizer" OFF) |
| 230 | option(IREE_ENABLE_MSAN "Enable memory sanitizer" OFF) |
| 231 | option(IREE_ENABLE_TSAN "Enable thread sanitizer" OFF) |
| 232 | |
| 233 | #------------------------------------------------------------------------------- |
Lei Zhang | 7e253da | 2020-06-10 07:51:19 -0700 | [diff] [blame] | 234 | # IREE utility definitions |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 235 | #------------------------------------------------------------------------------- |
| 236 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 237 | include(iree_macros) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 238 | include(iree_copts) |
Lei Zhang | 54771d4 | 2020-09-09 16:56:24 -0400 | [diff] [blame] | 239 | include(iree_whole_archive_link) |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 240 | include(iree_cc_binary) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 241 | include(iree_cc_library) |
| 242 | include(iree_cc_test) |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 243 | include(iree_tablegen_library) |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 244 | include(iree_tablegen_doc) |
Scott Todd | 11adcab | 2019-12-18 14:10:44 -0800 | [diff] [blame] | 245 | include(iree_cc_embed_data) |
| 246 | include(iree_bytecode_module) |
Stella Laurenzo | 66578b0 | 2020-07-20 17:34:44 -0700 | [diff] [blame] | 247 | include(iree_multipy) |
Geoffrey Martin-Noble | f0eaf37 | 2020-01-28 10:03:14 -0800 | [diff] [blame] | 248 | include(iree_lit_test) |
Geoffrey Martin-Noble | 4526dcc | 2020-03-09 11:59:52 -0700 | [diff] [blame] | 249 | include(iree_add_all_subdirs) |
Geoffrey Martin-Noble | e5fd5b5 | 2020-03-31 11:31:30 -0700 | [diff] [blame] | 250 | include(iree_check_test) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 251 | |
Marius Brehler | c4b6b91 | 2020-01-15 08:44:23 -0800 | [diff] [blame] | 252 | set(DEFAULT_CMAKE_BUILD_TYPE "Release") |
| 253 | if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
| 254 | message(STATUS "No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}") |
| 255 | set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE) |
| 256 | endif() |
| 257 | |
Marius Brehler | 06ac36e | 2020-01-10 14:44:11 -0800 | [diff] [blame] | 258 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 259 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 260 | #------------------------------------------------------------------------------- |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 261 | # IREE compilation flags |
Scott Todd | 29d654e | 2020-06-11 15:24:17 -0700 | [diff] [blame] | 262 | #------------------------------------------------------------------------------- |
| 263 | |
Lei Zhang | dd21f32 | 2020-09-10 10:47:33 -0400 | [diff] [blame] | 264 | iree_append_list_to_string(CMAKE_CXX_FLAGS ${IREE_DEFAULT_COPTS}) |
| 265 | iree_append_list_to_string(CMAKE_C_FLAGS_DEBUG ${IREE_C_FLAGS_DEBUG_LIST}) |
| 266 | iree_append_list_to_string(CMAKE_CXX_FLAGS_DEBUG ${IREE_CXX_FLAGS_DEBUG_LIST}) |
Scott Todd | 29d654e | 2020-06-11 15:24:17 -0700 | [diff] [blame] | 267 | |
| 268 | set(CMAKE_CXX_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C++ compiler during fast builds." FORCE) |
| 269 | set(CMAKE_C_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C compiler during fast builds." FORCE) |
| 270 | set(CMAKE_EXE_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used for linking binaries during fast builds." FORCE) |
| 271 | set(CMAKE_SHARED_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used by the shared libraries linker binaries during fast builds." FORCE) |
| 272 | mark_as_advanced( |
| 273 | CMAKE_CXX_FLAGS_FASTBUILD |
| 274 | CMAKE_C_FLAGS_FASTBUILD |
| 275 | CMAKE_EXE_LINKER_FLAGS_FASTBUILD |
| 276 | CMAKE_SHARED_LINKER_FLAGS_FASTBUILD |
| 277 | ) |
| 278 | |
| 279 | include(iree_setup_toolchain) |
| 280 | |
| 281 | #------------------------------------------------------------------------------- |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 282 | # MLIR/LLVM Dependency |
| 283 | # We treat the LLVM dependency specially because we support several different |
| 284 | # ways to use it: |
scotttodd | 354b691 | 2020-06-24 16:29:35 -0700 | [diff] [blame] | 285 | # - Bundled (default): a source dependency directly on the |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 286 | # third_party/llvm-project submodule. |
| 287 | # - External: An external (source or installed) dependency on LLVM. |
| 288 | # - Provided: When IREE is used as a sub-project, it is assumed that the LLVM |
| 289 | # dependency is added prior to including this configuration. |
| 290 | #------------------------------------------------------------------------------- |
| 291 | |
Ben Vanik | afd7abe | 2020-10-07 09:01:53 -0700 | [diff] [blame] | 292 | # Disable LLVM's warnings. |
Ben Vanik | 89a77fa | 2020-10-07 17:19:31 -0700 | [diff] [blame] | 293 | set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "don't use global flags /facepalm") |
| 294 | set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "don't use global flags /facepalm") |
Ben Vanik | afd7abe | 2020-10-07 09:01:53 -0700 | [diff] [blame] | 295 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 296 | # Adds bundled projects that must be included after the LLVM directory has |
scotttodd | 354b691 | 2020-06-24 16:29:35 -0700 | [diff] [blame] | 297 | # been added and within the scope of its settings (i.e. build type override, |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 298 | # etc). |
| 299 | function(add_bundled_mlir_dependent_projects) |
| 300 | if(${IREE_ENABLE_EMITC}) |
| 301 | add_subdirectory(third_party/mlir-emitc EXCLUDE_FROM_ALL) |
| 302 | endif() |
| 303 | endfunction() |
| 304 | |
| 305 | function(add_iree_mlir_src_dep llvm_monorepo_path) |
Ben Vanik | 89a77fa | 2020-10-07 17:19:31 -0700 | [diff] [blame] | 306 | # Stash cmake build type in case LLVM messes with it. |
| 307 | set(_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}") |
| 308 | |
Thomas Raoux | 3b6a42a | 2020-06-26 18:18:48 -0700 | [diff] [blame] | 309 | # experimental model builder uses vulkan runner. |
| 310 | if(${IREE_BUILD_EXPERIMENTAL}) |
| 311 | set(MLIR_VULKAN_RUNNER_ENABLED ON) |
| 312 | endif() |
| 313 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 314 | add_subdirectory("${llvm_monorepo_path}/llvm" "third_party/llvm-project/llvm" EXCLUDE_FROM_ALL) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 315 | |
Ben Vanik | 89a77fa | 2020-10-07 17:19:31 -0700 | [diff] [blame] | 316 | # Reset CMAKE_BUILD_TYPE to its previous setting. |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 317 | set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE) |
| 318 | endfunction() |
| 319 | |
| 320 | if(${IREE_ENABLE_MLIR}) |
| 321 | if(${IREE_MLIR_DEP_MODE} STREQUAL "DISABLED") |
| 322 | message(STATUS "Not adding MLIR/LLVM dep due to IREE_MLIR_DEP_MODE=DISABLED") |
| 323 | elseif(${IREE_MLIR_DEP_MODE} STREQUAL "BUNDLED") |
Stella Laurenzo | 03e48db | 2020-06-11 18:35:13 -0700 | [diff] [blame] | 324 | # TODO: See iree_copts.cmake where it sets include directories for this |
| 325 | # case. This should be cleaned up to be all in one place or the other for |
| 326 | # all modes. |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 327 | message(STATUS "Adding bundled LLVM source dependency") |
| 328 | add_iree_mlir_src_dep("third_party/llvm-project") |
| 329 | elseif(${IREE_MLIR_DEP_MODE} STREQUAL "INSTALLED") |
Stella Laurenzo | a1914e7 | 2020-07-25 00:06:47 -0700 | [diff] [blame] | 330 | # Deps of installed MLIR/LLVM packages. |
| 331 | find_package(ZLIB) # See: https://reviews.llvm.org/D79219 |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 332 | message(STATUS "Looking for installed MLIR/LLVM packages (configure with MLIR_DIR variable)") |
| 333 | find_package(MLIR REQUIRED CONFIG) |
| 334 | message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}") |
| 335 | message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") |
| 336 | list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") |
| 337 | list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") |
| 338 | include(TableGen) |
| 339 | include(AddLLVM) |
| 340 | include(AddMLIR) |
| 341 | include(HandleLLVMOptions) |
| 342 | |
| 343 | # Add include/link directories |
Ben Vanik | afd7abe | 2020-10-07 09:01:53 -0700 | [diff] [blame] | 344 | include_directories(SYSTEM ${LLVM_INCLUDE_DIRS}) |
| 345 | include_directories(SYSTEM ${MLIR_INCLUDE_DIRS}) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 346 | link_directories(${LLVM_BUILD_LIBRARY_DIR}) |
| 347 | add_definitions(${LLVM_DEFINITIONS}) |
| 348 | else() |
| 349 | message(FATAL "Unsupported IREE_MLIR_DEP_MODE=${IREE_MLIR_DEP_MODE}") |
| 350 | endif() |
| 351 | |
| 352 | include(external_tablegen_library) |
| 353 | add_bundled_mlir_dependent_projects() |
| 354 | endif() |
| 355 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 356 | #------------------------------------------------------------------------------- |
| 357 | # Non-LLVM Dependencies |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 358 | #------------------------------------------------------------------------------- |
| 359 | |
Lei Zhang | 8478778 | 2020-06-02 08:42:25 -0700 | [diff] [blame] | 360 | # Use the (deprecated) FindPythonInterp/FindPythonLibs functions before |
| 361 | # any of our dependencies do. See |
| 362 | # https://pybind11.readthedocs.io/en/stable/faq.html#inconsistent-detection-of-python-version-in-cmake-and-pybind11 |
| 363 | # If one dependency finds Python 2 (the default), |
| 364 | # any others that try to find Python 3 will fail. |
| 365 | # (Also come on, it's $CURRENT_YEAR - please just use Python 3 already.) |
Marius Brehler | db76329 | 2020-02-06 13:03:33 -0800 | [diff] [blame] | 366 | if(${IREE_BUILD_COMPILER} OR ${IREE_BUILD_PYTHON_BINDINGS}) |
Scott Todd | 702743d | 2020-02-06 20:49:06 -0800 | [diff] [blame] | 367 | find_package(PythonInterp 3 REQUIRED) |
Lei Zhang | 8478778 | 2020-06-02 08:42:25 -0700 | [diff] [blame] | 368 | endif() |
| 369 | if(${IREE_BUILD_PYTHON_BINDINGS}) |
Stella Laurenzo | c8f906c | 2020-07-21 13:55:50 -0700 | [diff] [blame] | 370 | # Note: Optional because python libs can be manually specified. |
| 371 | find_package(PythonLibs 3) |
Scott Todd | 4af17b6 | 2019-12-17 16:47:00 -0800 | [diff] [blame] | 372 | endif() |
| 373 | |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 374 | list(APPEND CMAKE_MODULE_PATH |
| 375 | ${CMAKE_CURRENT_LIST_DIR}/third_party/flatbuffers/CMake/ |
| 376 | ) |
| 377 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 378 | include(external_cc_library) |
Ben Vanik | 2d1808b | 2020-07-17 19:02:16 -0700 | [diff] [blame] | 379 | include(flatbuffer_c_library) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 380 | include(flatbuffer_cc_library) |
| 381 | |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 382 | add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL) |
| 383 | add_subdirectory(build_tools/third_party/renderdoc_api EXCLUDE_FROM_ALL) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 384 | add_subdirectory(build_tools/third_party/ruy EXCLUDE_FROM_ALL) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 385 | |
Ben Vanik | da79d9b | 2020-10-01 09:52:54 -0700 | [diff] [blame] | 386 | add_subdirectory(third_party/cpuinfo EXCLUDE_FROM_ALL) |
Marius Brehler | f5022e8 | 2019-12-13 15:20:25 -0800 | [diff] [blame] | 387 | add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 388 | add_subdirectory(third_party/abseil-cpp EXCLUDE_FROM_ALL) |
| 389 | add_subdirectory(third_party/flatbuffers EXCLUDE_FROM_ALL) |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 390 | add_subdirectory(third_party/flatcc EXCLUDE_FROM_ALL) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 391 | add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 392 | |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 393 | if(CMAKE_CROSSCOMPILING) |
Lei Zhang | 1e6a7a7 | 2020-06-04 13:12:01 -0400 | [diff] [blame] | 394 | # We need flatc to generate some source code. When cross-compiling, we need |
| 395 | # to make sure the flatc binary is configured under host environment. |
Scott Todd | 7f4c2d2 | 2020-10-14 14:10:22 -0700 | [diff] [blame] | 396 | iree_declare_host_excutable(flatc "flatc" BUILDONLY) |
| 397 | iree_declare_host_excutable(flatcc_cli "flatcc_cli" BUILDONLY) |
Lei Zhang | 1e6a7a7 | 2020-06-04 13:12:01 -0400 | [diff] [blame] | 398 | |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 399 | # Set the FLATBUFFERS_FLATC_EXECUTABLE. It controls where to find the flatc |
| 400 | # binary in BuildFlatBuffers(). |
Lei Zhang | 486e707 | 2020-06-16 11:42:49 -0400 | [diff] [blame] | 401 | iree_get_executable_path(FLATBUFFERS_FLATC_EXECUTABLE flatc) |
Lei Zhang | 1e6a7a7 | 2020-06-04 13:12:01 -0400 | [diff] [blame] | 402 | |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 403 | # Add a custom target to copy the flatc to the binary directory. |
| 404 | add_custom_target(iree_host_flatc |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 405 | COMMAND |
| 406 | "${CMAKE_COMMAND}" -E copy_if_different |
| 407 | "${IREE_HOST_BINARY_ROOT}/third_party/flatbuffers/flatc${IREE_HOST_EXECUTABLE_SUFFIX}" |
| 408 | "${IREE_HOST_BINARY_ROOT}/bin" |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 409 | DEPENDS iree_host_build_flatc |
Lei Zhang | 1ff7061 | 2020-06-04 10:12:41 -0400 | [diff] [blame] | 410 | COMMENT "Installing host flatc..." |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 411 | ) |
Ben Vanik | eb53de3 | 2020-07-17 19:05:27 -0700 | [diff] [blame] | 412 | add_custom_target(iree_host_flatcc_cli |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 413 | COMMAND |
| 414 | "${CMAKE_COMMAND}" -E copy_if_different |
Ben Vanik | 1425737 | 2020-07-21 08:05:18 -0700 | [diff] [blame] | 415 | "${PROJECT_SOURCE_DIR}/third_party/flatcc/bin/flatcc${IREE_HOST_EXECUTABLE_SUFFIX}" |
Scott Todd | 7f4c2d2 | 2020-10-14 14:10:22 -0700 | [diff] [blame] | 416 | "${IREE_HOST_BINARY_ROOT}/bin/flatcc_cli${IREE_HOST_EXECUTABLE_SUFFIX}" |
Ben Vanik | eb53de3 | 2020-07-17 19:05:27 -0700 | [diff] [blame] | 417 | DEPENDS iree_host_build_flatcc_cli |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 418 | COMMENT "Installing host flatcc..." |
| 419 | ) |
Ben Vanik | 1425737 | 2020-07-21 08:05:18 -0700 | [diff] [blame] | 420 | else() |
| 421 | # TODO: unify flatc and flatcc handling to the same mechanism. |
| 422 | add_executable(iree_host_flatcc_cli ALIAS flatcc_cli) |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 423 | endif() |
| 424 | |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 425 | if(${IREE_BUILD_COMPILER}) |
Marius Brehler | 87eaa3c | 2020-07-02 17:39:49 +0200 | [diff] [blame] | 426 | add_subdirectory(build_tools/third_party/tensorflow/tensorflow/compiler/mlir/hlo EXCLUDE_FROM_ALL) |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 427 | endif() |
| 428 | |
Scott Todd | f700355 | 2019-11-11 09:14:19 -0800 | [diff] [blame] | 429 | if(${IREE_BUILD_DEBUGGER} OR ${IREE_BUILD_SAMPLES}) |
Scott Todd | 5e1f44e | 2020-03-30 16:21:44 -0700 | [diff] [blame] | 430 | # sdl2 logs are spammy - change log level while adding |
| 431 | function(include_sdl2) |
| 432 | set(CMAKE_MESSAGE_LOG_LEVEL "WARNING") |
| 433 | add_subdirectory(third_party/sdl2 EXCLUDE_FROM_ALL) |
| 434 | endfunction() |
| 435 | include_sdl2() |
| 436 | |
Scott Todd | 0d41620 | 2019-11-12 16:22:05 -0800 | [diff] [blame] | 437 | add_subdirectory(build_tools/third_party/dear_imgui EXCLUDE_FROM_ALL) |
Scott Todd | f700355 | 2019-11-11 09:14:19 -0800 | [diff] [blame] | 438 | endif() |
| 439 | |
Marius Brehler | 2967650 | 2019-12-27 17:07:10 -0800 | [diff] [blame] | 440 | if(${IREE_BUILD_TESTS}) |
| 441 | add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL) |
Marius Brehler | 575b63a | 2020-01-07 09:39:24 -0800 | [diff] [blame] | 442 | enable_testing(iree) |
Marius Brehler | 2967650 | 2019-12-27 17:07:10 -0800 | [diff] [blame] | 443 | endif() |
| 444 | |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 445 | if(${IREE_BUILD_PYTHON_BINDINGS}) |
Stella Laurenzo | 66578b0 | 2020-07-20 17:34:44 -0700 | [diff] [blame] | 446 | # NOTE: The multipy defaults come from pybind's configuration and must come |
| 447 | # after. This should be pulled in locally at some point. |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 448 | add_subdirectory(third_party/pybind11 EXCLUDE_FROM_ALL) |
Stella Laurenzo | 66578b0 | 2020-07-20 17:34:44 -0700 | [diff] [blame] | 449 | iree_multipy_configure() |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 450 | endif() |
| 451 | |
Lei Zhang | 3cbb28e | 2020-09-22 15:30:27 -0400 | [diff] [blame] | 452 | if(${IREE_TARGET_BACKEND_METAL-SPIRV}) |
| 453 | # SPIRV-Cross is needed to cross compile SPIR-V into MSL source code. |
| 454 | add_subdirectory(third_party/spirv_cross EXCLUDE_FROM_ALL) |
| 455 | endif() |
| 456 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 457 | #------------------------------------------------------------------------------- |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 458 | # IREE top-level targets |
| 459 | #------------------------------------------------------------------------------- |
| 460 | |
| 461 | if(${IREE_BUILD_DOCS}) |
| 462 | # Add a top-level custom target to drive generating all documentation. |
| 463 | # Register it to the default target given that IREE_BUILD_DOCS is explicitly |
| 464 | # requested. |
| 465 | add_custom_target(iree-doc ALL) |
| 466 | endif() |
| 467 | |
| 468 | #------------------------------------------------------------------------------- |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 469 | # IREE top-level libraries |
| 470 | #------------------------------------------------------------------------------- |
| 471 | |
Marius Brehler | f5022e8 | 2019-12-13 15:20:25 -0800 | [diff] [blame] | 472 | add_subdirectory(build_tools/embed_data/) |
| 473 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 474 | add_subdirectory(iree/base) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 475 | add_subdirectory(iree/hal) |
Marius Brehler | 9317d1f | 2020-01-08 10:34:11 -0800 | [diff] [blame] | 476 | add_subdirectory(iree/modules) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 477 | add_subdirectory(iree/schemas) |
Marius Brehler | 2967650 | 2019-12-27 17:07:10 -0800 | [diff] [blame] | 478 | add_subdirectory(iree/testing) |
Marius Brehler | 476031a | 2020-03-24 16:14:30 -0700 | [diff] [blame] | 479 | add_subdirectory(iree/test) |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 480 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 481 | if(${IREE_ENABLE_MLIR}) |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 482 | # The VM requires LLVM to build its op definitions. |
| 483 | add_subdirectory(iree/vm) |
| 484 | endif() |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 485 | |
| 486 | if(${IREE_BUILD_COMPILER}) |
| 487 | add_subdirectory(iree/compiler) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 488 | elseif(${IREE_ENABLE_MLIR}) |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 489 | # If not building the compiler, tablegen is still needed |
| 490 | # to generate vm ops so deep include it only. |
Marius Brehler | c61240a | 2020-04-20 11:22:59 -0700 | [diff] [blame] | 491 | add_subdirectory(iree/compiler/Dialect/IREE/Tools) |
Stella Laurenzo | 0603415 | 2020-01-03 11:26:31 -0800 | [diff] [blame] | 492 | add_subdirectory(iree/compiler/Dialect/VM/Tools) |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 493 | endif() |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 494 | |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 495 | if(${IREE_BUILD_PYTHON_BINDINGS}) |
| 496 | add_subdirectory(bindings/python) |
| 497 | endif() |
| 498 | |
Jenni Kilduff | 0d09cf3 | 2020-10-19 10:23:34 -0700 | [diff] [blame] | 499 | if(${IREE_BUILD_JAVA_BINDINGS}) |
| 500 | add_subdirectory(bindings/java) |
| 501 | add_subdirectory(bindings/javatests) |
| 502 | endif() |
| 503 | |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 504 | add_subdirectory(iree/tools) |
| 505 | |
| 506 | if(${IREE_BUILD_SAMPLES}) |
| 507 | add_subdirectory(iree/samples) |
| 508 | endif() |
Ben Vanik | b64e918 | 2020-01-30 15:19:37 -0800 | [diff] [blame] | 509 | |
| 510 | if(${IREE_BUILD_EXPERIMENTAL}) |
| 511 | add_subdirectory(experimental) |
| 512 | endif() |
Scott Todd | ee30e1b | 2020-02-03 16:44:15 -0800 | [diff] [blame] | 513 | |
| 514 | # Note: this must be called after all libraries have been declared. |
| 515 | iree_complete_binary_link_options() |
Marius Brehler | 42cc5e6 | 2020-02-18 11:17:12 -0800 | [diff] [blame] | 516 | if(${IREE_BUILD_PYTHON_BINDINGS}) |
| 517 | iree_complete_py_extension_link_options() |
| 518 | endif() |
Stella Laurenzo | 03e48db | 2020-06-11 18:35:13 -0700 | [diff] [blame] | 519 | |
| 520 | set(IREE_PUBLIC_INCLUDE_DIRS "${IREE_COMMON_INCLUDE_DIRS}" |
| 521 | CACHE INTERNAL "IREE: Include Directories" FORCE) |