Geoffrey Martin-Noble | 552d3f8 | 2021-05-25 17:56:09 -0700 | [diff] [blame] | 1 | # Copyright 2019 The IREE Authors |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 2 | # |
Geoffrey Martin-Noble | 552d3f8 | 2021-05-25 17:56:09 -0700 | [diff] [blame] | 3 | # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | # See https://llvm.org/LICENSE.txt for license information. |
| 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 6 | |
Marius Brehler | 59dcd0d | 2021-02-09 20:44:44 +0100 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.13.4) |
Ben Vanik | 552c5f4 | 2021-06-21 17:39:14 -0700 | [diff] [blame] | 8 | |
Scott Todd | 9fa14f9 | 2021-03-09 10:43:38 -0800 | [diff] [blame] | 9 | # Do not set MSVC warning flags like /W3 by default (since 3.15): |
| 10 | # https://cmake.org/cmake/help/v3.15/policy/CMP0092.html |
| 11 | if(POLICY CMP0092) |
| 12 | cmake_policy(SET CMP0092 NEW) |
| 13 | endif() |
Ben Vanik | 552c5f4 | 2021-06-21 17:39:14 -0700 | [diff] [blame] | 14 | |
| 15 | # LLVM requires CMP0116 for tblgen: https://reviews.llvm.org/D101083 |
| 16 | # CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()` |
| 17 | # New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html |
| 18 | set(CMAKE_POLICY_DEFAULT_CMP0116 OLD) |
| 19 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 20 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 21 | |
Ben Vanik | 96fd277 | 2021-04-19 20:30:56 -0700 | [diff] [blame] | 22 | project(iree ASM C CXX) |
Lei Zhang | 6c5907b | 2020-06-02 09:06:08 -0700 | [diff] [blame] | 23 | set(CMAKE_C_STANDARD 11) |
| 24 | set(CMAKE_CXX_STANDARD 14) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 25 | set(IREE_IDE_FOLDER IREE) |
| 26 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 27 | |
Ben Vanik | 96fd277 | 2021-04-19 20:30:56 -0700 | [diff] [blame] | 28 | if(${MSVC}) |
| 29 | enable_language(ASM_MASM) |
| 30 | else() |
| 31 | enable_language(ASM) |
| 32 | endif() |
| 33 | |
Lei Zhang | 7e253da | 2020-06-10 07:51:19 -0700 | [diff] [blame] | 34 | #------------------------------------------------------------------------------- |
| 35 | # Project component configuration |
| 36 | #------------------------------------------------------------------------------- |
| 37 | |
Ben Vanik | 56d44bf | 2020-05-15 13:20:50 -0700 | [diff] [blame] | 38 | option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF) |
Scott Todd | 1cd9f0a | 2021-07-29 10:05:44 -0700 | [diff] [blame] | 39 | option(IREE_ENABLE_COMPILER_TRACING "Enables instrumented compiler tracing." 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 | fe4403e | 2021-06-01 15:09:43 -0400 | [diff] [blame] | 43 | option(IREE_BUILD_BENCHMARKS "Builds IREE benchmark suites." OFF) |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 44 | option(IREE_BUILD_DOCS "Builds IREE docs." OFF) |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 45 | option(IREE_BUILD_SAMPLES "Builds IREE sample projects." ON) |
Ben Vanik | cd1132f | 2021-01-29 15:58:17 -0800 | [diff] [blame] | 46 | |
Stella Laurenzo | 6a0313b | 2021-05-04 22:45:59 +0000 | [diff] [blame] | 47 | option(IREE_BUILD_TENSORFLOW_ALL "Builds all TensorFlow compiler frontends." OFF) |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 48 | option(IREE_BUILD_TENSORFLOW_COMPILER "Builds TensorFlow compiler frontend." OFF) |
Stella Laurenzo | 55fcfab | 2020-12-10 13:17:25 -0800 | [diff] [blame] | 49 | option(IREE_BUILD_TFLITE_COMPILER "Builds the TFLite compiler frontend." OFF) |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 50 | option(IREE_BUILD_XLA_COMPILER "Builds TensorFlow XLA compiler frontend." OFF) |
Cindy Liu | 331946c | 2021-06-01 12:20:30 -0700 | [diff] [blame] | 51 | option(IREE_ENABLE_THREADING "Builds IREE in with thread library support." ON) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 52 | |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 53 | set(IREE_HAL_DRIVERS_TO_BUILD "all" |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 54 | CACHE STRING "Semicolon-separated list of HAL drivers to build, or \"all\".") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 55 | set(IREE_TARGET_BACKENDS_TO_BUILD "all" |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 56 | CACHE STRING "Semicolon-separated list of target backends to build, or \"all\".") |
Stella Laurenzo | 04b7c37 | 2020-12-10 00:05:31 +0000 | [diff] [blame] | 57 | |
Stella Laurenzo | bb1de96 | 2021-01-05 08:18:33 -0800 | [diff] [blame] | 58 | # Properties controlling version and naming of release artifacts. |
| 59 | set(IREE_RELEASE_PACKAGE_SUFFIX "-dev" CACHE STRING "Suffix to append to distributed package names") |
| 60 | set(IREE_RELEASE_VERSION "0.1a1" CACHE STRING "Version to embed in distributed packages") |
| 61 | set(IREE_RELEASE_REVISION "HEAD" CACHE STRING "Version control revision information to embed in distributed packages") |
| 62 | |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 63 | # Master enable for tensorflow build support. |
| 64 | # Note that this is a normal CMake variable used to gate build features (not |
| 65 | # a cache variable that is user-settable). |
| 66 | set(IREE_ENABLE_TENSORFLOW OFF) |
Stella Laurenzo | 6a0313b | 2021-05-04 22:45:59 +0000 | [diff] [blame] | 67 | if(${IREE_BUILD_TENSORFLOW_ALL} OR |
| 68 | ${IREE_BUILD_TENSORFLOW_COMPILER} OR |
Stella Laurenzo | 55fcfab | 2020-12-10 13:17:25 -0800 | [diff] [blame] | 69 | ${IREE_BUILD_TFLITE_COMPILER} OR |
| 70 | ${IREE_BUILD_XLA_COMPILER}) |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 71 | set(IREE_ENABLE_TENSORFLOW ON) |
| 72 | endif() |
| 73 | |
Ben Vanik | cd1132f | 2021-01-29 15:58:17 -0800 | [diff] [blame] | 74 | option(IREE_BUILD_BINDINGS_TFLITE "Builds the IREE TFLite C API compatibility shim" ON) |
Kojo Acquah | 5bf3994 | 2021-04-22 16:01:28 -0700 | [diff] [blame] | 75 | option(IREE_BUILD_BINDINGS_TFLITE_JAVA "Builds the IREE TFLite Java bindings with the C API compatibility shim" ON) |
Ben Vanik | cd1132f | 2021-01-29 15:58:17 -0800 | [diff] [blame] | 76 | |
Stella Laurenzo | 04b7c37 | 2020-12-10 00:05:31 +0000 | [diff] [blame] | 77 | # Default python bindings to enabled for some features. |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 78 | if(${IREE_ENABLE_TENSORFLOW}) |
Stella Laurenzo | 04b7c37 | 2020-12-10 00:05:31 +0000 | [diff] [blame] | 79 | option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" ON) |
| 80 | else() |
| 81 | option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" OFF) |
| 82 | endif() |
| 83 | |
Stella Laurenzo | 0f005e5 | 2020-12-27 11:54:33 -0800 | [diff] [blame] | 84 | #------------------------------------------------------------------------------- |
| 85 | # Experimental project flags |
| 86 | #------------------------------------------------------------------------------- |
| 87 | |
Stella Laurenzo | 0f005e5 | 2020-12-27 11:54:33 -0800 | [diff] [blame] | 88 | option(IREE_BUILD_EXPERIMENTAL_REMOTING "Builds experimental remoting support." OFF) |
not-jenni | 603e9f1 | 2021-01-26 16:49:18 -0800 | [diff] [blame] | 89 | option(IREE_BUILD_EXPERIMENTAL_JAVA_BINDINGS "Builds the experimental java bindings." OFF) |
raikonenfnu | 4b31bd9 | 2021-05-18 18:20:25 -0700 | [diff] [blame] | 90 | option(IREE_BUILD_EXPERIMENTAL_ROCM "Builds the experimental ROCM Backend." OFF) |
Stella Laurenzo | 0a8a944 | 2021-06-14 22:42:37 -0700 | [diff] [blame] | 91 | option(IREE_ENABLE_NEW_INTEGRATION_TESTS "Enables new integration tests and disables old." OFF) |
Stella Laurenzo | 0f005e5 | 2020-12-27 11:54:33 -0800 | [diff] [blame] | 92 | |
| 93 | #------------------------------------------------------------------------------- |
| 94 | # Derived flags based on primary options |
| 95 | #------------------------------------------------------------------------------- |
| 96 | |
Marius Brehler | 5400f0f | 2021-08-11 01:41:34 +0200 | [diff] [blame] | 97 | option(IREE_ENABLE_EMITC "Enables MLIR EmitC dependencies." ${IREE_BUILD_COMPILER}) |
Marius Brehler | fd8be7f | 2020-06-18 15:59:28 -0700 | [diff] [blame] | 98 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 99 | #------------------------------------------------------------------------------- |
Lei Zhang | 8bea2e8 | 2020-06-04 10:17:56 -0400 | [diff] [blame] | 100 | # Target and backend configuration |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 101 | #------------------------------------------------------------------------------- |
| 102 | |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 103 | # List of all HAL drivers to be built by default: |
| 104 | set(IREE_ALL_HAL_DRIVERS |
Thomas | a98c3c0 | 2021-02-16 09:56:03 -0800 | [diff] [blame] | 105 | Cuda |
Scott Todd | 217904d | 2020-06-04 13:38:32 -0700 | [diff] [blame] | 106 | DyLib |
Ben Vanik | 0f14db0 | 2021-04-19 23:29:29 -0700 | [diff] [blame] | 107 | VMVX |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 108 | Vulkan |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 109 | ) |
| 110 | |
Ben Vanik | 85cdd86 | 2020-11-14 11:26:12 -0800 | [diff] [blame] | 111 | if(IREE_HAL_DRIVERS_TO_BUILD STREQUAL "all") |
| 112 | set(IREE_HAL_DRIVERS_TO_BUILD ${IREE_ALL_HAL_DRIVERS}) |
Lei Zhang | 6171a98 | 2020-09-08 12:48:25 -0400 | [diff] [blame] | 113 | |
| 114 | # For Apple platforms we need to use Metal instead of Vulkan. |
| 115 | if(APPLE) |
| 116 | list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Vulkan) |
Lei Zhang | 6171a98 | 2020-09-08 12:48:25 -0400 | [diff] [blame] | 117 | endif() |
Thomas | a98c3c0 | 2021-02-16 09:56:03 -0800 | [diff] [blame] | 118 | # Remove Cuda from Android and Apple platforms. |
| 119 | if(ANDROID OR APPLE) |
| 120 | list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Cuda) |
| 121 | endif() |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 122 | endif() |
Scott Todd | 6132bb3 | 2020-08-11 12:04:40 -0700 | [diff] [blame] | 123 | message(STATUS "Building HAL drivers: ${IREE_HAL_DRIVERS_TO_BUILD}") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 124 | |
| 125 | # Default every IREE_HAL_DRIVER_* to OFF |
| 126 | foreach(_backend ${IREE_ALL_HAL_DRIVERS}) |
| 127 | string(TOUPPER "${_backend}" uppercase_backend) |
| 128 | set(IREE_HAL_DRIVER_${uppercase_backend} OFF CACHE BOOL "" FORCE) |
| 129 | endforeach() |
| 130 | |
| 131 | # Set IREE_HAL_DRIVER_* based on configuration |
| 132 | foreach(_backend ${IREE_HAL_DRIVERS_TO_BUILD}) |
| 133 | string(TOUPPER "${_backend}" uppercase_backend) |
Marius Brehler | 30f06a0 | 2020-12-18 13:39:26 +0000 | [diff] [blame] | 134 | string(REPLACE "\"" "" uppercase_backend ${uppercase_backend}) |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 135 | set(IREE_HAL_DRIVER_${uppercase_backend} ON CACHE BOOL "" FORCE) |
| 136 | endforeach() |
| 137 | |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 138 | # List of all target backends to be built by default: |
| 139 | set(IREE_ALL_TARGET_BACKENDS |
Thomas | d85738e | 2021-02-23 11:02:55 -0800 | [diff] [blame] | 140 | CUDA |
Scott Todd | 9f0148f | 2021-03-17 15:14:07 -0700 | [diff] [blame] | 141 | DYLIB-LLVM-AOT |
| 142 | WASM-LLVM-AOT |
Lei Zhang | 3cbb28e | 2020-09-22 15:30:27 -0400 | [diff] [blame] | 143 | Metal-SPIRV |
harsh-nod | f6d36fe | 2021-05-17 15:38:31 -0700 | [diff] [blame] | 144 | ROCM |
Lei Zhang | 7d90e0e | 2020-07-23 16:01:13 -0400 | [diff] [blame] | 145 | Vulkan-SPIRV |
Ben Vanik | 907f353 | 2021-04-20 13:27:00 -0700 | [diff] [blame] | 146 | VMVX |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 147 | ) |
| 148 | |
Scott Todd | 28cacaa | 2021-06-29 09:31:46 -0700 | [diff] [blame] | 149 | if(${IREE_BUILD_COMPILER}) |
| 150 | if(IREE_TARGET_BACKENDS_TO_BUILD STREQUAL "all") |
| 151 | set(IREE_TARGET_BACKENDS_TO_BUILD ${IREE_ALL_TARGET_BACKENDS}) |
| 152 | endif() |
| 153 | message(STATUS "Building target backends: ${IREE_TARGET_BACKENDS_TO_BUILD}") |
| 154 | else() |
| 155 | set(IREE_TARGET_BACKENDS_TO_BUILD "" CACHE STRING "" FORCE) |
| 156 | message(STATUS "Compiler is disabled, building no target backends") |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 157 | endif() |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 158 | |
| 159 | # Default every IREE_TARGET_BACKEND_* to OFF |
| 160 | foreach(_backend ${IREE_ALL_TARGET_BACKENDS}) |
| 161 | string(TOUPPER "${_backend}" uppercase_backend) |
| 162 | set(IREE_TARGET_BACKEND_${uppercase_backend} OFF CACHE BOOL "" FORCE) |
| 163 | endforeach() |
| 164 | |
| 165 | # Set IREE_TARGET_BACKEND_* based on configuration |
| 166 | foreach(_backend ${IREE_TARGET_BACKENDS_TO_BUILD}) |
| 167 | string(TOUPPER "${_backend}" uppercase_backend) |
Marius Brehler | 30f06a0 | 2020-12-18 13:39:26 +0000 | [diff] [blame] | 168 | string(REPLACE "\"" "" uppercase_backend ${uppercase_backend}) |
Marius Brehler | 0a4b67f | 2020-05-08 13:19:16 -0700 | [diff] [blame] | 169 | set(IREE_TARGET_BACKEND_${uppercase_backend} ON CACHE BOOL "" FORCE) |
| 170 | endforeach() |
| 171 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 172 | list(APPEND CMAKE_MODULE_PATH |
| 173 | ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 174 | ${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/ |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 175 | ) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 176 | |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 177 | #------------------------------------------------------------------------------- |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 178 | # IREE compilation toolchain configuration |
| 179 | #------------------------------------------------------------------------------- |
| 180 | |
| 181 | # Enable using lld as the linker for C/C++ targets. This affects IREE and all |
| 182 | # dependency projects. |
| 183 | option(IREE_ENABLE_LLD "Use lld when linking" OFF) |
| 184 | option(IREE_ENABLE_ASAN "Enable address sanitizer" OFF) |
| 185 | option(IREE_ENABLE_MSAN "Enable memory sanitizer" OFF) |
| 186 | option(IREE_ENABLE_TSAN "Enable thread sanitizer" OFF) |
bjacob | e694d95 | 2020-11-03 12:05:35 -0500 | [diff] [blame] | 187 | option(IREE_ENABLE_CCACHE "Use ccache if installed to speed up rebuilds." OFF) |
| 188 | |
Ben Vanik | 85cdd86 | 2020-11-14 11:26:12 -0800 | [diff] [blame] | 189 | if(${IREE_ENABLE_CCACHE}) |
bjacob | e694d95 | 2020-11-03 12:05:35 -0500 | [diff] [blame] | 190 | find_program(CCACHE_PROGRAM ccache) |
| 191 | if(CCACHE_PROGRAM) |
| 192 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") |
| 193 | endif() |
| 194 | endif() |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 195 | |
Stella Laurenzo | 5b63912 | 2021-06-18 14:44:10 -0700 | [diff] [blame] | 196 | |
| 197 | #------------------------------------------------------------------------------- |
| 198 | # IREE assertions |
| 199 | # We don't love the way this is done, but we have to line it up with how LLVM |
| 200 | # does it and not diverge, since all implementations and all header users must |
| 201 | # have the same definition of NDEBUG. |
| 202 | # |
| 203 | # LLVM defaults LLVM_ENABLE_ASSERTIONS to ON for Debug builds only but then |
| 204 | # conditions itself to only update flags if not building Debug. We just let |
| 205 | # IREE_ENABLE_ASSERTIONS be not conditioned on anything and only update the |
| 206 | # flags in appropriate build types. |
| 207 | # |
| 208 | # If IREE_ENABLE_ASSERTIONS is set ON manually, then |
| 209 | # - NDEBUG must be undefined |
| 210 | # - LLVM_ENABLE_ASSERTIONS is forced off in order to keep multiple parties |
| 211 | # from mucking with globals. |
| 212 | # |
| 213 | # Since CMake forces NDEBUG for !Debug builds, some surgery needs to be done |
| 214 | # at the top level to avoid divergence. |
| 215 | #------------------------------------------------------------------------------- |
| 216 | |
| 217 | option(IREE_ENABLE_ASSERTIONS "Force unset of NDEBUG compile option" OFF) |
| 218 | |
| 219 | # Filter -DNDEBUG from CMAKE_CXX_FLAGS_* and CMAKE_C_FLAGS_* (if |
| 220 | # CMAKE_BUILD_TYPE is not Debug). |
| 221 | function(iree_fix_ndebug) |
| 222 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 223 | if(IREE_ENABLE_ASSERTIONS AND NOT "${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG") |
| 224 | # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines. |
| 225 | foreach (flags_var_to_scrub |
| 226 | CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} |
| 227 | CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}) |
| 228 | set(original_flags "${${flags_var_to_scrub}}") |
| 229 | string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " |
| 230 | altered_flags "${original_flags}") |
| 231 | if(NOT "${original_flags}" STREQUAL "${altered_flags}") |
| 232 | message(STATUS |
| 233 | "IREE_ENABLE_ASSERTIONS force disabled NDEBUG for ${flags_var_to_scrub}: '${original_flags}' -> '${altered_flags}'") |
| 234 | set(${flags_var_to_scrub} "${altered_flags}" PARENT_SCOPE) |
| 235 | endif() |
| 236 | endforeach() |
| 237 | |
| 238 | # Make sure that LLVM doesn't add its own logic for assertion disabling. |
| 239 | # We'd like to make sure that we are not dueling over globals. |
| 240 | set(LLVM_ENABLE_ASSERTIONS OFF PARENT_SCOPE) |
| 241 | endif() |
| 242 | endfunction() |
| 243 | iree_fix_ndebug() |
| 244 | |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 245 | #------------------------------------------------------------------------------- |
Lei Zhang | 7e253da | 2020-06-10 07:51:19 -0700 | [diff] [blame] | 246 | # IREE utility definitions |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 247 | #------------------------------------------------------------------------------- |
| 248 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 249 | include(iree_macros) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 250 | include(iree_copts) |
bjacob | c12ba3b | 2020-11-03 10:32:00 -0500 | [diff] [blame] | 251 | include(sanitizers) |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 252 | include(iree_cc_binary) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 253 | include(iree_cc_library) |
| 254 | include(iree_cc_test) |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 255 | include(iree_tablegen_library) |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 256 | include(iree_tablegen_doc) |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 257 | include(iree_third_party_cmake_options) |
CindyLiu | 40ed02d | 2021-04-22 16:16:28 +0000 | [diff] [blame] | 258 | include(iree_c_embed_data) |
Scott Todd | 11adcab | 2019-12-18 14:10:44 -0800 | [diff] [blame] | 259 | include(iree_bytecode_module) |
Marius Brehler | 46e8331 | 2021-03-25 00:11:39 +0100 | [diff] [blame] | 260 | include(iree_c_module) |
Stella Laurenzo | 94363e2 | 2020-12-15 13:46:14 -0800 | [diff] [blame] | 261 | include(iree_python) |
Geoffrey Martin-Noble | f0eaf37 | 2020-01-28 10:03:14 -0800 | [diff] [blame] | 262 | include(iree_lit_test) |
Geoffrey Martin-Noble | 4526dcc | 2020-03-09 11:59:52 -0700 | [diff] [blame] | 263 | include(iree_add_all_subdirs) |
Geoffrey Martin-Noble | e5fd5b5 | 2020-03-31 11:31:30 -0700 | [diff] [blame] | 264 | include(iree_check_test) |
Geoffrey Martin-Noble | 4889612 | 2021-01-05 21:04:18 -0800 | [diff] [blame] | 265 | include(iree_run_binary_test) |
Lei Zhang | fe4403e | 2021-06-01 15:09:43 -0400 | [diff] [blame] | 266 | include(iree_mlir_benchmark_suite) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 267 | |
Marius Brehler | c4b6b91 | 2020-01-15 08:44:23 -0800 | [diff] [blame] | 268 | set(DEFAULT_CMAKE_BUILD_TYPE "Release") |
Ben Vanik | 85cdd86 | 2020-11-14 11:26:12 -0800 | [diff] [blame] | 269 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
Marius Brehler | c4b6b91 | 2020-01-15 08:44:23 -0800 | [diff] [blame] | 270 | message(STATUS "No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}") |
| 271 | set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE) |
| 272 | endif() |
| 273 | |
Marius Brehler | 06ac36e | 2020-01-10 14:44:11 -0800 | [diff] [blame] | 274 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 275 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 276 | #------------------------------------------------------------------------------- |
Lei Zhang | e88470f | 2020-09-08 13:21:09 -0400 | [diff] [blame] | 277 | # IREE compilation flags |
Scott Todd | 29d654e | 2020-06-11 15:24:17 -0700 | [diff] [blame] | 278 | #------------------------------------------------------------------------------- |
| 279 | |
Lei Zhang | dd21f32 | 2020-09-10 10:47:33 -0400 | [diff] [blame] | 280 | iree_append_list_to_string(CMAKE_C_FLAGS_DEBUG ${IREE_C_FLAGS_DEBUG_LIST}) |
| 281 | 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] | 282 | |
| 283 | set(CMAKE_CXX_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C++ compiler during fast builds." FORCE) |
| 284 | set(CMAKE_C_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C compiler during fast builds." FORCE) |
| 285 | set(CMAKE_EXE_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used for linking binaries during fast builds." FORCE) |
| 286 | set(CMAKE_SHARED_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used by the shared libraries linker binaries during fast builds." FORCE) |
| 287 | mark_as_advanced( |
| 288 | CMAKE_CXX_FLAGS_FASTBUILD |
| 289 | CMAKE_C_FLAGS_FASTBUILD |
| 290 | CMAKE_EXE_LINKER_FLAGS_FASTBUILD |
| 291 | CMAKE_SHARED_LINKER_FLAGS_FASTBUILD |
| 292 | ) |
| 293 | |
| 294 | include(iree_setup_toolchain) |
| 295 | |
| 296 | #------------------------------------------------------------------------------- |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 297 | # Configure python early if there are any features that need it. |
| 298 | # Note that doing this early ensures that dependencies that make incidental |
| 299 | # use of Python (such as LLVM) resolve the same version. |
| 300 | #------------------------------------------------------------------------------- |
| 301 | |
| 302 | if(${IREE_BUILD_COMPILER} OR |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 303 | ${IREE_BUILD_PYTHON_BINDINGS}) |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 304 | find_package(Python3 COMPONENTS Interpreter REQUIRED) |
| 305 | endif() |
| 306 | |
| 307 | #------------------------------------------------------------------------------- |
Niloy Sikdar | 47238df | 2021-07-28 23:37:33 +0530 | [diff] [blame] | 308 | # Check if git submodules have been initialized. |
| 309 | # This will only run if python3 is available. |
| 310 | #------------------------------------------------------------------------------- |
| 311 | |
| 312 | find_package(Python3 COMPONENTS Interpreter QUIET) |
| 313 | if(Python3_FOUND) |
| 314 | execute_process( |
| 315 | COMMAND ${Python3_EXECUTABLE} scripts/git/check_submodule_init.py |
| 316 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 317 | RESULT_VARIABLE ret |
| 318 | ) |
| 319 | if(NOT ret EQUAL "0") |
| 320 | message(FATAL_ERROR "check_submodule_init.py failed, see the logs above") |
| 321 | endif() |
| 322 | endif() |
| 323 | |
| 324 | #------------------------------------------------------------------------------- |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 325 | # MLIR/LLVM Dependency |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 326 | #------------------------------------------------------------------------------- |
| 327 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 328 | if(NOT IREE_BUILD_COMPILER) |
| 329 | message(STATUS "Not adding LLVM/MLIR because the configuration does not require it") |
| 330 | elseif(TARGET LLVMSupport) |
| 331 | message(STATUS "Not adding IREE bundled LLVM because it has already been included") |
| 332 | if(NOT TARGET MLIRIR) |
| 333 | message(FATAL_ERROR "Detected externally provided LLVM project but could not find MLIR projects (is it enabled/installed?)") |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 334 | endif() |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 335 | else() |
| 336 | message(STATUS "Adding bundled LLVM source dependency") |
| 337 | iree_set_llvm_cmake_options() |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 338 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 339 | # Disable LLVM's warnings. |
| 340 | set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "don't use global flags /facepalm") |
| 341 | |
Ben Vanik | 89a77fa | 2020-10-07 17:19:31 -0700 | [diff] [blame] | 342 | # Stash cmake build type in case LLVM messes with it. |
| 343 | set(_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}") |
| 344 | |
Stella Laurenzo | 62fbef0 | 2021-08-09 20:52:48 -0700 | [diff] [blame] | 345 | # Add default external projects. |
Stella Laurenzo | 02230c1 | 2021-08-10 03:58:42 +0000 | [diff] [blame] | 346 | iree_add_llvm_external_project(mlir-iree-dialects MLIR_IREE_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}/llvm-external-projects/iree-dialects) |
Stella Laurenzo | 62fbef0 | 2021-08-09 20:52:48 -0700 | [diff] [blame] | 347 | iree_add_llvm_external_project(mlir-hlo MLIR_HLO ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mlir-hlo) |
| 348 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 349 | add_subdirectory("third_party/llvm-project/llvm" EXCLUDE_FROM_ALL) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 350 | |
Ben Vanik | 89a77fa | 2020-10-07 17:19:31 -0700 | [diff] [blame] | 351 | # Reset CMAKE_BUILD_TYPE to its previous setting. |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 352 | set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE) |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 353 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 354 | # Extend module path to allow submodules to use LLVM and MLIR CMake modules. |
| 355 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/mlir") |
| 356 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/lib/cmake/llvm/") |
Marius Brehler | 71f76cb | 2020-11-10 20:56:55 +0100 | [diff] [blame] | 357 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 358 | # Add the bundled include directories for cmake files looking for them. |
| 359 | list(APPEND LLVM_INCLUDE_DIRS |
| 360 | ${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include |
| 361 | ${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include |
| 362 | ) |
| 363 | list(APPEND MLIR_INCLUDE_DIRS |
| 364 | ${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include |
| 365 | ${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include |
| 366 | ) |
Marius Brehler | 71f76cb | 2020-11-10 20:56:55 +0100 | [diff] [blame] | 367 | |
Stella Laurenzo | 62fbef0 | 2021-08-09 20:52:48 -0700 | [diff] [blame] | 368 | function(_hack_llvm_include_paths) |
| 369 | set(_common_include_dirs |
| 370 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include> |
| 371 | $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include> |
| 372 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include> |
| 373 | $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include> |
| 374 | $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir-hlo/include> |
| 375 | ) |
| 376 | # Avoid globally modifying paths by instead adding the include paths to the |
| 377 | # rules that really should have them in the first place. |
| 378 | target_include_directories(LLVMSupport PUBLIC ${_common_include_dirs}) |
| 379 | target_include_directories(MLIRSupport PUBLIC ${_common_include_dirs}) |
| 380 | endfunction() |
| 381 | _hack_llvm_include_paths() |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 382 | endif() |
| 383 | |
Stella Laurenzo | 382122d | 2020-06-11 16:18:09 -0700 | [diff] [blame] | 384 | #------------------------------------------------------------------------------- |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 385 | # Python bindings. |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 386 | #------------------------------------------------------------------------------- |
| 387 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 388 | if(IREE_BUILD_PYTHON_BINDINGS) |
Stella Laurenzo | c8f906c | 2020-07-21 13:55:50 -0700 | [diff] [blame] | 389 | # Note: Optional because python libs can be manually specified. |
Marius Brehler | af7b4c3 | 2020-11-24 19:19:17 +0100 | [diff] [blame] | 390 | find_package(Python3 COMPONENTS Interpreter Development REQUIRED) |
Scott Todd | 4af17b6 | 2019-12-17 16:47:00 -0800 | [diff] [blame] | 391 | endif() |
| 392 | |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 393 | #------------------------------------------------------------------------------- |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 394 | # Other dependencies. |
| 395 | #------------------------------------------------------------------------------- |
| 396 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 397 | include(external_cc_library) |
Ben Vanik | 2d1808b | 2020-07-17 19:02:16 -0700 | [diff] [blame] | 398 | include(flatbuffer_c_library) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 399 | |
Thomas | 3079fb1 | 2021-05-12 20:31:20 -0700 | [diff] [blame] | 400 | add_subdirectory(build_tools/third_party/cuda EXCLUDE_FROM_ALL) |
Ben Vanik | a903649 | 2021-06-25 09:39:53 -0700 | [diff] [blame] | 401 | add_subdirectory(build_tools/third_party/libyaml EXCLUDE_FROM_ALL) |
CindyLiu | 807f457 | 2021-05-12 23:41:41 +0000 | [diff] [blame] | 402 | add_subdirectory(build_tools/third_party/stblib EXCLUDE_FROM_ALL) |
Ben Vanik | a903649 | 2021-06-25 09:39:53 -0700 | [diff] [blame] | 403 | add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 404 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 405 | iree_set_googletest_cmake_options() |
Marius Brehler | f5022e8 | 2019-12-13 15:20:25 -0800 | [diff] [blame] | 406 | add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL) |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 407 | |
| 408 | if(IREE_ENABLE_THREADING) |
| 409 | iree_set_benchmark_cmake_options() |
Cindy Liu | 331946c | 2021-06-01 12:20:30 -0700 | [diff] [blame] | 410 | add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL) |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 411 | iree_set_cpuinfo_cmake_options() |
Cindy Liu | 331946c | 2021-06-01 12:20:30 -0700 | [diff] [blame] | 412 | add_subdirectory(third_party/cpuinfo EXCLUDE_FROM_ALL) |
Cindy Liu | 331946c | 2021-06-01 12:20:30 -0700 | [diff] [blame] | 413 | endif() |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 414 | |
| 415 | iree_set_flatcc_cmake_options() |
| 416 | add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL) |
Ben Vanik | 71527c2 | 2020-07-17 13:09:57 -0700 | [diff] [blame] | 417 | add_subdirectory(third_party/flatcc EXCLUDE_FROM_ALL) |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 418 | |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 419 | add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL) |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 420 | |
Scott Todd | 4e1a69b | 2021-01-25 15:29:49 -0800 | [diff] [blame] | 421 | # TODO(scotttodd): Iterate some more and find a better place for this. |
| 422 | if (NOT CMAKE_CROSSCOMPILING) |
| 423 | install(TARGETS iree-flatcc-cli |
| 424 | COMPONENT iree-flatcc-cli |
| 425 | RUNTIME DESTINATION bin) |
Lei Zhang | 0d281b7 | 2020-06-01 20:00:23 -0400 | [diff] [blame] | 426 | endif() |
| 427 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 428 | if(IREE_BUILD_COMPILER) |
Marius Brehler | 3eaf444 | 2021-01-13 18:22:08 +0100 | [diff] [blame] | 429 | add_subdirectory(build_tools/third_party/mlir-hlo EXCLUDE_FROM_ALL) |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 430 | endif() |
| 431 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 432 | if(IREE_ENABLE_EMITC) |
Marius Brehler | 75d4bb8 | 2021-07-14 10:59:20 +0000 | [diff] [blame] | 433 | add_subdirectory(build_tools/third_party/mlir-emitc EXCLUDE_FROM_ALL) |
| 434 | endif() |
| 435 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 436 | if(IREE_BUILD_TESTS) |
Marius Brehler | 575b63a | 2020-01-07 09:39:24 -0800 | [diff] [blame] | 437 | enable_testing(iree) |
Marius Brehler | 2967650 | 2019-12-27 17:07:10 -0800 | [diff] [blame] | 438 | endif() |
| 439 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 440 | if(IREE_BUILD_PYTHON_BINDINGS) |
Marius Brehler | f3d73c9 | 2020-01-16 16:11:52 -0800 | [diff] [blame] | 441 | add_subdirectory(third_party/pybind11 EXCLUDE_FROM_ALL) |
| 442 | endif() |
| 443 | |
Stella Laurenzo | 275215d | 2021-08-06 11:50:28 -0700 | [diff] [blame] | 444 | if(IREE_TARGET_BACKEND_METAL-SPIRV) |
| 445 | iree_set_spirv_cross_cmake_options() |
Lei Zhang | 3cbb28e | 2020-09-22 15:30:27 -0400 | [diff] [blame] | 446 | # SPIRV-Cross is needed to cross compile SPIR-V into MSL source code. |
| 447 | add_subdirectory(third_party/spirv_cross EXCLUDE_FROM_ALL) |
| 448 | endif() |
| 449 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 450 | #------------------------------------------------------------------------------- |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 451 | # IREE top-level targets |
| 452 | #------------------------------------------------------------------------------- |
| 453 | |
Lei Zhang | fe4403e | 2021-06-01 15:09:43 -0400 | [diff] [blame] | 454 | if(${IREE_BUILD_BENCHMARKS}) |
| 455 | # Add a top-level custom target to drive generating benchmark suites. |
| 456 | add_custom_target(iree-benchmark-suites) |
| 457 | endif() |
| 458 | |
Lei Zhang | 22f0e24 | 2020-03-30 12:09:20 -0700 | [diff] [blame] | 459 | if(${IREE_BUILD_DOCS}) |
| 460 | # Add a top-level custom target to drive generating all documentation. |
| 461 | # Register it to the default target given that IREE_BUILD_DOCS is explicitly |
| 462 | # requested. |
| 463 | add_custom_target(iree-doc ALL) |
| 464 | endif() |
| 465 | |
| 466 | #------------------------------------------------------------------------------- |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 467 | # IREE top-level libraries |
| 468 | #------------------------------------------------------------------------------- |
| 469 | |
Marius Brehler | f5022e8 | 2019-12-13 15:20:25 -0800 | [diff] [blame] | 470 | add_subdirectory(build_tools/embed_data/) |
| 471 | |
Ben Vanik | 185d30c | 2019-09-19 14:24:11 -0700 | [diff] [blame] | 472 | add_subdirectory(iree/base) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 473 | add_subdirectory(iree/hal) |
Marius Brehler | 9317d1f | 2020-01-08 10:34:11 -0800 | [diff] [blame] | 474 | add_subdirectory(iree/modules) |
Ben Vanik | b69d0cc | 2021-05-05 18:16:22 -0700 | [diff] [blame] | 475 | add_subdirectory(iree/runtime) |
Ben Vanik | 512d2d3 | 2019-09-20 13:22:34 -0700 | [diff] [blame] | 476 | add_subdirectory(iree/schemas) |
Ben Vanik | 01600a5 | 2020-12-15 17:18:04 -0800 | [diff] [blame] | 477 | add_subdirectory(iree/task) |
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) |
not-jenni | bd3610e | 2020-12-23 17:00:22 -0800 | [diff] [blame] | 480 | add_subdirectory(iree/vm) |
Lei Zhang | ff38a68 | 2021-06-08 21:12:24 -0400 | [diff] [blame] | 481 | |
| 482 | if(${IREE_BUILD_BENCHMARKS}) |
Lei Zhang | 08cea04 | 2021-07-20 12:44:01 -0400 | [diff] [blame] | 483 | add_subdirectory(benchmarks) |
Lei Zhang | ff38a68 | 2021-06-08 21:12:24 -0400 | [diff] [blame] | 484 | endif() |
| 485 | |
raikonenfnu | 4b31bd9 | 2021-05-18 18:20:25 -0700 | [diff] [blame] | 486 | if(${IREE_BUILD_EXPERIMENTAL_ROCM}) |
| 487 | add_subdirectory(build_tools/third_party/rocm EXCLUDE_FROM_ALL) |
| 488 | add_subdirectory(experimental/rocm) |
raikonenfnu | 4b31bd9 | 2021-05-18 18:20:25 -0700 | [diff] [blame] | 489 | endif() |
Ben Vanik | cc2aff9 | 2019-09-24 10:23:55 -0700 | [diff] [blame] | 490 | |
| 491 | if(${IREE_BUILD_COMPILER}) |
| 492 | add_subdirectory(iree/compiler) |
| 493 | endif() |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 494 | |
| 495 | add_subdirectory(iree/tools) |
| 496 | |
Stella Laurenzo | 77a63cd | 2021-01-04 17:29:54 -0800 | [diff] [blame] | 497 | # Order constraint: The python bindings install tools targets from iree/tools |
| 498 | # and must come after it. |
| 499 | if(${IREE_BUILD_PYTHON_BINDINGS}) |
| 500 | add_subdirectory(bindings/python) |
| 501 | endif() |
| 502 | |
Ben Vanik | cd1132f | 2021-01-29 15:58:17 -0800 | [diff] [blame] | 503 | if(${IREE_BUILD_BINDINGS_TFLITE}) |
| 504 | add_subdirectory(bindings/tflite) |
| 505 | endif() |
| 506 | |
Ben Vanik | 6b112ef | 2019-10-03 10:45:14 -0700 | [diff] [blame] | 507 | if(${IREE_BUILD_SAMPLES}) |
| 508 | add_subdirectory(iree/samples) |
| 509 | endif() |
Ben Vanik | b64e918 | 2020-01-30 15:19:37 -0800 | [diff] [blame] | 510 | |
Stella Laurenzo | 0f005e5 | 2020-12-27 11:54:33 -0800 | [diff] [blame] | 511 | if(${IREE_BUILD_EXPERIMENTAL_REMOTING}) |
| 512 | # NOTE: Currently liburing is only used by the experimental remoting |
| 513 | # support, so keeping it scoped here. If this broadens, then include along |
| 514 | # with other dependencies as normal. |
| 515 | if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
| 516 | message(STATUS "Enabling liburing") |
| 517 | add_subdirectory(build_tools/third_party/liburing EXCLUDE_FROM_ALL) |
| 518 | endif() |
| 519 | add_subdirectory(experimental/remoting) |
Ben Vanik | b64e918 | 2020-01-30 15:19:37 -0800 | [diff] [blame] | 520 | endif() |
Scott Todd | ee30e1b | 2020-02-03 16:44:15 -0800 | [diff] [blame] | 521 | |
not-jenni | 603e9f1 | 2021-01-26 16:49:18 -0800 | [diff] [blame] | 522 | if(${IREE_BUILD_EXPERIMENTAL_JAVA_BINDINGS}) |
| 523 | add_subdirectory(experimental/bindings/java) |
| 524 | endif() |
| 525 | |
Stella Laurenzo | a4137ef | 2020-12-09 21:28:08 -0800 | [diff] [blame] | 526 | if(${IREE_ENABLE_TENSORFLOW}) |
Stella Laurenzo | a3e97f1 | 2020-12-05 23:29:13 -0800 | [diff] [blame] | 527 | add_subdirectory(integrations/tensorflow) |
| 528 | endif() |
| 529 | |
Stella Laurenzo | 03e48db | 2020-06-11 18:35:13 -0700 | [diff] [blame] | 530 | set(IREE_PUBLIC_INCLUDE_DIRS "${IREE_COMMON_INCLUDE_DIRS}" |
| 531 | CACHE INTERNAL "IREE: Include Directories" FORCE) |