blob: 6fc136912e15a41d565191402d14d33b8c4bc516 [file] [log] [blame]
Geoffrey Martin-Noble552d3f82021-05-25 17:56:09 -07001# Copyright 2019 The IREE Authors
Ben Vanik185d30c2019-09-19 14:24:11 -07002#
Geoffrey Martin-Noble552d3f82021-05-25 17:56:09 -07003# 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 Vanik185d30c2019-09-19 14:24:11 -07006
Geoffrey Martin-Noble4fd7a1d2022-11-17 15:09:49 -08007cmake_minimum_required(VERSION 3.21...3.24)
Ben Vanik552c5f42021-06-21 17:39:14 -07008
9# LLVM requires CMP0116 for tblgen: https://reviews.llvm.org/D101083
10# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
11# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
12set(CMAKE_POLICY_DEFAULT_CMP0116 OLD)
13
Ben Vanik512d2d32019-09-20 13:22:34 -070014set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Ben Vanik185d30c2019-09-19 14:24:11 -070015
Stella Laurenzo688670f2021-09-24 18:16:25 -070016project(IREE ASM C CXX)
Lei Zhang6c5907b2020-06-02 09:06:08 -070017set(CMAKE_C_STANDARD 11)
Scott Todd07349fa2022-07-27 12:16:05 -070018set(CMAKE_CXX_STANDARD 17)
Stella Laurenzobc09f0e2022-07-27 16:22:39 -070019# LLVM defines this as a CACHE property and uses a policy that causes the
20# cache value to take precedence. This is causing us to mix 17/14 across
21# the boundary.
22# TODO: Remove this once the LLVM mechanism is updated. See:
23# https://discourse.llvm.org/t/important-new-toolchain-requirements-to-build-llvm-will-most-likely-be-landing-within-a-week-prepare-your-buildbots/61447/9
24set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE)
Ben Vanik185d30c2019-09-19 14:24:11 -070025set(IREE_IDE_FOLDER IREE)
26set_property(GLOBAL PROPERTY USE_FOLDERS ON)
27
Scott Todd1a1aea62022-04-28 09:12:11 -070028if(MSVC)
Ben Vanik96fd2772021-04-19 20:30:56 -070029 enable_language(ASM_MASM)
30else()
31 enable_language(ASM)
32endif()
33
Cindy Liub1bfb9c2022-06-27 10:46:13 -070034# Set the default CMake build type so some of the build type dependent setting
35# in the submodules and functions (IREE assertion) can be set properly.
Cindy Liu23dafd02022-06-22 15:36:21 -070036set(DEFAULT_CMAKE_BUILD_TYPE "Release")
37if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
38 message(STATUS "No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}")
39 set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE)
40endif()
41
Scott Todd99e9f5b2021-12-30 10:56:12 -080042include(CMakeDependentOption)
43
Lei Zhang7e253da2020-06-10 07:51:19 -070044#-------------------------------------------------------------------------------
45# Project component configuration
46#-------------------------------------------------------------------------------
47
Ben Vanik56d44bf2020-05-15 13:20:50 -070048option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF)
Scott Todd1cd9f0a2021-07-29 10:05:44 -070049option(IREE_ENABLE_COMPILER_TRACING "Enables instrumented compiler tracing." OFF)
Ben Vanik2d79c202022-10-24 15:08:57 -070050option(IREE_ENABLE_RENDERDOC_PROFILING "Enables profiling HAL devices with the RenderDoc tool." OFF)
Geoffrey Martin-Noblefe74bd42021-10-27 22:17:13 -070051option(IREE_ENABLE_THREADING "Builds IREE in with thread library support." ON)
Rob Sudermand42e0022022-06-08 16:38:45 -070052option(IREE_ENABLE_CLANG_TIDY "Builds IREE in with clang tidy enabled on IREE's libraries." OFF)
Ben Vanik512d2d32019-09-20 13:22:34 -070053
Ben Vanik4aae0032022-04-19 15:49:26 -070054# TODO(#8469): remove the dependency on cpuinfo entirely.
55option(IREE_ENABLE_CPUINFO "Enables runtime use of cpuinfo for processor topology detection." ON)
56
Marius Brehleredfc57f2019-12-18 11:19:38 -080057option(IREE_BUILD_COMPILER "Builds the IREE compiler." ON)
Ben Vanik512d2d32019-09-20 13:22:34 -070058option(IREE_BUILD_TESTS "Builds IREE unit tests." ON)
Lei Zhang22f0e242020-03-30 12:09:20 -070059option(IREE_BUILD_DOCS "Builds IREE docs." OFF)
Ben Vanik6b112ef2019-10-03 10:45:14 -070060option(IREE_BUILD_SAMPLES "Builds IREE sample projects." ON)
Scott Todd382fc632022-06-06 10:57:24 -070061option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" OFF)
Stella Laurenzod3770ff2021-10-18 22:54:18 -070062option(IREE_BUILD_TRACY "Builds tracy server tools." OFF)
Ben Vanikcd1132f2021-01-29 15:58:17 -080063
Scott Todd352da3f2022-07-20 15:25:11 -070064option(IREE_BYTECODE_MODULE_FORCE_LLVM_SYSTEM_LINKER "Use the system linker when generating IREE modules in tests/samples/benchmarks (useful for Tracy)." OFF)
bjacob1af90ee2022-03-28 22:10:53 -040065
Stella Laurenzobb1de962021-01-05 08:18:33 -080066# Properties controlling version and naming of release artifacts.
Stella Laurenzof33f5b52022-01-08 17:49:52 +000067set(IREE_RELEASE_PACKAGE_SUFFIX "" CACHE STRING "Suffix to append to distributed package names")
Stella Laurenzobb1de962021-01-05 08:18:33 -080068set(IREE_RELEASE_VERSION "0.1a1" CACHE STRING "Version to embed in distributed packages")
69set(IREE_RELEASE_REVISION "HEAD" CACHE STRING "Version control revision information to embed in distributed packages")
70
Ben Vanikcd1132f2021-01-29 15:58:17 -080071option(IREE_BUILD_BINDINGS_TFLITE "Builds the IREE TFLite C API compatibility shim" ON)
Kojo Acquah5bf39942021-04-22 16:01:28 -070072option(IREE_BUILD_BINDINGS_TFLITE_JAVA "Builds the IREE TFLite Java bindings with the C API compatibility shim" ON)
Ben Vanikcd1132f2021-01-29 15:58:17 -080073
Jerry Wub6b1dee2022-06-01 13:45:16 +000074# Properties building and controlling benchmark suites.
75option(IREE_BUILD_BENCHMARKS "Builds IREE benchmark suites." OFF)
76# TODO(pzread): Currently IREE_ENABLE_COMPILATION_BENCHMARKS needs
77# IREE_BUILD_BENCHMARKS. Eventually we will decouple them.
78cmake_dependent_option(IREE_ENABLE_COMPILATION_BENCHMARKS "Builds IREE benchmark suites for compilation statistics." OFF ${IREE_BUILD_BENCHMARKS} OFF)
79
80option(IREE_BUILD_MICROBENCHMARKS "Builds IREE microbenchmark suites." OFF)
81
Stella Laurenzo0f005e52020-12-27 11:54:33 -080082#-------------------------------------------------------------------------------
83# Experimental project flags
84#-------------------------------------------------------------------------------
85
Stella Laurenzo0f005e52020-12-27 11:54:33 -080086option(IREE_BUILD_EXPERIMENTAL_REMOTING "Builds experimental remoting support." OFF)
Ben Vanika372ab52022-07-25 18:40:22 -070087option(IREE_BUILD_EXPERIMENTAL_VMVX_MMT4D "Enables MMT4D methods in the VMVX module." OFF)
Scott Toddf237b5e2022-01-28 11:02:25 -080088option(IREE_BUILD_EXPERIMENTAL_WEB_SAMPLES "Builds experimental web samples." OFF)
Jerry Wu16e2d9c2022-11-22 06:19:46 +000089option(IREE_BUILD_EXPERIMENTAL_E2E_TEST_ARTIFACTS "Builds IREE E2E test artifacts suite generated by the e2e test framework." OFF)
Stella Laurenzo0f005e52020-12-27 11:54:33 -080090
91#-------------------------------------------------------------------------------
Stella Laurenzo74b04b72022-03-02 10:21:11 -080092# Runtime HAL Driver Options
93# By default, all runtime drivers supported by the current platform which do
94# not require external deps are enabled by default. This can be changed with:
95# -DIREE_HAL_DRIVER_DEFAULTS=OFF
Ben Vanik185d30c2019-09-19 14:24:11 -070096#-------------------------------------------------------------------------------
97
Ben Vanik4e6af052022-06-07 17:10:20 -070098# External HAL drivers; see runtime/src/iree/hal/drivers/CMakeLists.txt for more
99# information on how to declare external drivers.
100set(IREE_EXTERNAL_HAL_DRIVERS "" CACHE STRING "")
101
Ben Vanik89160272022-09-26 16:44:11 -0700102# Additional executable loader deps to add dependent libraries to any target
103# using the default executable loader registration utilities.
104# TODO(benvanik): extend the deps to encompass the built-in loaders too so that
105# we have one flag. We could also support a list of deps and automatically
106# generate the registration from that via a configure file.
107set(IREE_HAL_EXECUTABLE_LOADER_EXTRA_DEPS "" CACHE STRING "")
108
Scott Toddd1620f02021-12-22 14:55:38 -0800109option(IREE_HAL_DRIVER_DEFAULTS "Sets the default value for all runtime HAL drivers" ON)
Stella Laurenzo98388662022-02-03 15:37:30 -0800110# CUDA support must be explicitly enabled.
111set(IREE_HAL_DRIVER_CUDA_DEFAULT OFF)
Ben Vanika9aaebe2022-12-16 09:14:53 -0800112
Scott Toddd1620f02021-12-22 14:55:38 -0800113# Vulkan is not natively supported on Apple platforms.
114# Metal should generally be used instead, though MoltenVK may also work.
Scott Todd1a1aea62022-04-28 09:12:11 -0700115if(APPLE)
Scott Toddd1620f02021-12-22 14:55:38 -0800116 set(IREE_HAL_DRIVER_VULKAN_DEFAULT OFF)
117else()
118 set(IREE_HAL_DRIVER_VULKAN_DEFAULT ${IREE_HAL_DRIVER_DEFAULTS})
119endif()
Marius Brehler0a4b67f2020-05-08 13:19:16 -0700120
Scott Toddd1620f02021-12-22 14:55:38 -0800121option(IREE_HAL_DRIVER_CUDA "Enables the 'cuda' runtime HAL driver" ${IREE_HAL_DRIVER_CUDA_DEFAULT})
Ben Vanike3058072022-06-06 19:21:44 -0700122option(IREE_HAL_DRIVER_LOCAL_SYNC "Enables the 'local-sync' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS})
123option(IREE_HAL_DRIVER_LOCAL_TASK "Enables the 'local-task' runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULTS})
124option(IREE_HAL_DRIVER_VULKAN "Enables the 'vulkan' runtime HAL driver" ${IREE_HAL_DRIVER_VULKAN_DEFAULT})
125
Ben Vanik6e64b6e2022-06-07 09:14:53 -0700126option(IREE_HAL_EXECUTABLE_LOADER_DEFAULTS "Sets the default value for all runtime HAL executable loaders" ON)
127set(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF_DEFAULT ${IREE_HAL_EXECUTABLE_LOADER_DEFAULTS})
128set(IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY_DEFAULT ${IREE_HAL_EXECUTABLE_LOADER_DEFAULTS})
129set(IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE_DEFAULT ${IREE_HAL_EXECUTABLE_LOADER_DEFAULTS})
Ben Vanike3058072022-06-06 19:21:44 -0700130
131# Emscripten builds don't support embedded ELF libraries.
132if(EMSCRIPTEN)
Ben Vanik2e8540e2022-06-06 20:39:34 -0700133 set(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF_DEFAULT OFF)
Ben Vanike3058072022-06-06 19:21:44 -0700134endif()
135
136# If forcing system libraries (for TSAN/debugging tools/etc) then ensure the
137# system library loader is linked in.
Scott Todd352da3f2022-07-20 15:25:11 -0700138if(IREE_BYTECODE_MODULE_FORCE_LLVM_SYSTEM_LINKER)
Ben Vanike3058072022-06-06 19:21:44 -0700139 set(IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY_DEFAULT ON)
140endif()
141
Ben Vanik6e64b6e2022-06-07 09:14:53 -0700142# If no local driver is enabled then we force all the loaders off; this allows
143# for simpler checks that don't need to see if both the driver and loader is
144# available.
145if(NOT IREE_HAL_DRIVER_LOCAL_SYNC AND NOT IREE_HAL_DRIVER_LOCAL_TASK)
146 set(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF_DEFAULT OFF)
147 set(IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY_DEFAULT OFF)
148 set(IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE_DEFAULT OFF)
149endif()
150
Ben Vanik2e8540e2022-06-06 20:39:34 -0700151option(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF "Enables the embedded dynamic library loader for local HAL drivers" ${IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF_DEFAULT})
Ben Vanike3058072022-06-06 19:21:44 -0700152option(IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY "Enables the system dynamic library loader for local HAL drivers" ${IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY_DEFAULT})
153option(IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE "Enables the VMVX module loader for local HAL drivers" ${IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE_DEFAULT})
154
Scott Todd0f1f8eb2022-06-10 15:53:30 -0700155if(IREE_BUILD_COMPILER)
156 # The compiler requires the local task driver with the VMVX loader.
157 set(IREE_HAL_DRIVER_LOCAL_TASK ON)
158 set(IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE ON)
159endif()
160
Ben Vanike3058072022-06-06 19:21:44 -0700161message(STATUS "IREE HAL drivers:")
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800162if(IREE_HAL_DRIVER_CUDA)
163 message(STATUS " - cuda")
164endif()
Ben Vanike3058072022-06-06 19:21:44 -0700165if(IREE_HAL_DRIVER_LOCAL_SYNC)
166 message(STATUS " - local-sync")
167endif()
168if(IREE_HAL_DRIVER_LOCAL_TASK)
169 message(STATUS " - local-task")
170endif()
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800171if(IREE_HAL_DRIVER_VULKAN)
172 message(STATUS " - vulkan")
173endif()
Ben Vanik4e6af052022-06-07 17:10:20 -0700174if(IREE_EXTERNAL_HAL_DRIVERS)
175 message(STATUS " + external: ${IREE_EXTERNAL_HAL_DRIVERS}")
176endif()
Ben Vanik512d2d32019-09-20 13:22:34 -0700177
Ben Vanike3058072022-06-06 19:21:44 -0700178message(STATUS "IREE HAL local executable library loaders:")
Ben Vanik2e8540e2022-06-06 20:39:34 -0700179if(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF)
180 message(STATUS " - embedded-elf")
Ben Vanike3058072022-06-06 19:21:44 -0700181endif()
182if(IREE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY)
183 message(STATUS " - system-library")
184endif()
185if(IREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE)
186 message(STATUS " - vmvx-module")
187endif()
188
Lei Zhang0d281b72020-06-01 20:00:23 -0400189#-------------------------------------------------------------------------------
Ben Vanik4e6af052022-06-07 17:10:20 -0700190# Experimental ROCM HAL driver
191#-------------------------------------------------------------------------------
192
193set(IREE_EXTERNAL_ROCM_HAL_DRIVER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/experimental/rocm")
194set(IREE_EXTERNAL_ROCM_HAL_DRIVER_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/experimental/rocm")
195set(IREE_EXTERNAL_ROCM_HAL_DRIVER_TARGET "iree::experimental::rocm::registration")
196set(IREE_EXTERNAL_ROCM_HAL_DRIVER_REGISTER "iree_hal_rocm_driver_module_register")
197
198#-------------------------------------------------------------------------------
Scott Todd382fc632022-06-06 10:57:24 -0700199# Compiler Target Options
200# By default, all compiler targets supported by the current platform which do
201# not require external deps are enabled by default. This can be changed with:
202# -DIREE_TARGET_BACKEND_DEFAULTS=OFF
203#-------------------------------------------------------------------------------
204
205option(IREE_TARGET_BACKEND_DEFAULTS "Sets the default value for all compiler target backends" ON)
206
207# The VMVX backend is always enabled.
208cmake_dependent_option(IREE_TARGET_BACKEND_VMVX "Enables the 'vmvx' compiler target backend" ON ${IREE_BUILD_COMPILER} OFF)
209
210# Supported default target backends.
Scott Todd352da3f2022-07-20 15:25:11 -0700211cmake_dependent_option(IREE_TARGET_BACKEND_LLVM_CPU "Enables the 'llvm-cpu' compiler target backend" ${IREE_TARGET_BACKEND_DEFAULTS} ${IREE_BUILD_COMPILER} OFF)
212cmake_dependent_option(IREE_TARGET_BACKEND_LLVM_CPU_WASM "Enables WebAssembly in the 'llvm-cpu' compiler target backend" ${IREE_TARGET_BACKEND_DEFAULTS} ${IREE_TARGET_BACKEND_LLVM_CPU} OFF)
Scott Todd382fc632022-06-06 10:57:24 -0700213cmake_dependent_option(IREE_TARGET_BACKEND_METAL_SPIRV "Enables the 'metal-spirv' compiler target backend" ${IREE_TARGET_BACKEND_DEFAULTS} ${IREE_BUILD_COMPILER} OFF)
Scott Todd382fc632022-06-06 10:57:24 -0700214cmake_dependent_option(IREE_TARGET_BACKEND_VULKAN_SPIRV "Enables the 'vulkan-spirv' compiler target backend" ${IREE_TARGET_BACKEND_DEFAULTS} ${IREE_BUILD_COMPILER} OFF)
215
216# Non-default target backends either have additional dependencies or are
217# experimental/niche in some fashion.
218cmake_dependent_option(IREE_TARGET_BACKEND_CUDA "Enables the 'cuda' compiler target backend" OFF ${IREE_BUILD_COMPILER} OFF)
219cmake_dependent_option(IREE_TARGET_BACKEND_ROCM "Enables the 'rocm' compiler target backend" OFF ${IREE_BUILD_COMPILER} OFF)
220# Disable WebGPU by default - it has complex deps and is under development.
221cmake_dependent_option(IREE_TARGET_BACKEND_WEBGPU "Enables the 'webgpu' compiler target backend" OFF ${IREE_BUILD_COMPILER} OFF)
222
223#-------------------------------------------------------------------------------
Scott Todde23d4a72022-07-27 14:16:39 -0700224# Compiler Input Dialects
225#-------------------------------------------------------------------------------
226
227cmake_dependent_option(IREE_INPUT_MHLO "Builds support for compiling MHLO programs" ON ${IREE_BUILD_COMPILER} OFF)
228cmake_dependent_option(IREE_INPUT_TORCH "Builds support for compiling Torch MLIR programs" ON ${IREE_BUILD_COMPILER} OFF)
229cmake_dependent_option(IREE_INPUT_TOSA "Builds support for compiling TOSA programs" ON ${IREE_BUILD_COMPILER} OFF)
230
Marius Brehler36f24512022-08-04 17:39:03 +0200231if(IREE_BUILD_COMPILER)
232 message(STATUS "IREE compiler input dialects:")
233 if(IREE_INPUT_MHLO)
234 message(STATUS " - MHLO")
235 endif()
236 if(IREE_INPUT_TORCH)
237 message(STATUS " - Torch MLIR")
238 endif()
239 if(IREE_INPUT_TOSA)
240 message(STATUS " - TOSA")
241 endif()
Scott Todde23d4a72022-07-27 14:16:39 -0700242endif()
243
244#-------------------------------------------------------------------------------
Scott Todd2a1925c2022-06-13 10:03:52 -0700245# Compiler Output Formats
246#-------------------------------------------------------------------------------
247
Scott Todd2a1925c2022-06-13 10:03:52 -0700248cmake_dependent_option(IREE_OUTPUT_FORMAT_C "Enables the 'vm-c' output format, using MLIR EmitC" ON ${IREE_BUILD_COMPILER} OFF)
249
Marius Brehler36f24512022-08-04 17:39:03 +0200250if(IREE_BUILD_COMPILER)
251 message(STATUS "IREE compiler output formats:")
252 if(IREE_OUTPUT_FORMAT_C)
253 message(STATUS " - C source module")
254 endif()
255 # The 'vm-bytecode' and 'vm-asm' formats are always enabled.
256 message(STATUS " - VM Bytecode")
257 message(STATUS " - VM MLIR Assembly")
Scott Todde23d4a72022-07-27 14:16:39 -0700258endif()
Scott Todde23d4a72022-07-27 14:16:39 -0700259
Scott Todd2a1925c2022-06-13 10:03:52 -0700260#-------------------------------------------------------------------------------
Lei Zhange88470f2020-09-08 13:21:09 -0400261# IREE compilation toolchain configuration
262#-------------------------------------------------------------------------------
263
Lei Zhange88470f2020-09-08 13:21:09 -0400264option(IREE_ENABLE_ASAN "Enable address sanitizer" OFF)
265option(IREE_ENABLE_MSAN "Enable memory sanitizer" OFF)
266option(IREE_ENABLE_TSAN "Enable thread sanitizer" OFF)
bjacob7cf5b842022-04-04 16:48:04 -0400267option(IREE_BYTECODE_MODULE_ENABLE_TSAN "Enable thread sanitizer in IREE modules in tests" OFF)
Jakub Kuderski068b1722022-07-27 18:14:59 -0400268option(IREE_ENABLE_UBSAN "Enable undefined behavior sanitizer" OFF)
Stella Laurenzodeb48052022-11-25 10:41:46 -0800269option(IREE_ENABLE_SPLIT_DWARF "Enable gsplit-dwarf for debug information if the platform supports it" OFF)
270option(IREE_ENABLE_THIN_ARCHIVES "Enables thin ar archives (elf systems only). Disable for released static archives" OFF)
Ben Vanikadadd032022-11-28 23:18:16 -0800271option(IREE_LINK_COMPILER_SHARED_LIBRARY "Links IREE tools using the compiler compiled into a shared library" ON)
bjacob7cf5b842022-04-04 16:48:04 -0400272
273# STREQUAL feels wrong here - we don't care about the exact true-value used,
274# ON or TRUE or something else. But we haven't been able to think of a less bad
Scott Todd7df39732022-06-28 09:21:35 -0700275# alternative. https://github.com/iree-org/iree/pull/8474#discussion_r840790062
bjacob7cf5b842022-04-04 16:48:04 -0400276if(NOT IREE_ENABLE_TSAN STREQUAL IREE_BYTECODE_MODULE_ENABLE_TSAN)
277 message(SEND_ERROR
278 "IREE_ENABLE_TSAN and IREE_BYTECODE_MODULE_ENABLE_TSAN must be "
279 "simultaneously ON or OFF. "
280 "A discrepancy between the two would cause tests to crash as IREE "
281 "runtime code (controlled by IREE_ENABLE_TSAN) calls into test IREE "
282 "modules (controlled by IREE_BYTECODE_MODULE_ENABLE_TSAN)")
283endif()
284
285if(IREE_BYTECODE_MODULE_ENABLE_TSAN)
Scott Todd352da3f2022-07-20 15:25:11 -0700286 if(NOT IREE_BYTECODE_MODULE_FORCE_LLVM_SYSTEM_LINKER)
bjacob7cf5b842022-04-04 16:48:04 -0400287 message(SEND_ERROR
288 "When IREE_BYTECODE_MODULE_ENABLE_TSAN is ON, "
Scott Todd352da3f2022-07-20 15:25:11 -0700289 "IREE_BYTECODE_MODULE_FORCE_LLVM_SYSTEM_LINKER must also be ON. "
bjacob7cf5b842022-04-04 16:48:04 -0400290 "TSAN instrumentation is not currently supported in embedded modules.")
291 endif()
292endif()
293
Geoffrey Martin-Noble61ea1ed2022-11-23 16:25:57 -0800294option(IREE_ENABLE_CCACHE
295 "[DEPRECATED: Use CMAKE_<LANG>_COMPILER_LAUNCHER configure options or environment variables instead.] Use ccache if installed."
296 OFF)
bjacobe694d952020-11-03 12:05:35 -0500297
Scott Todd1a1aea62022-04-28 09:12:11 -0700298if(IREE_ENABLE_CCACHE)
Geoffrey Martin-Noble61ea1ed2022-11-23 16:25:57 -0800299 message(WARNING
300 "IREE_ENABLE_CCACHE is deprecated. Use CMAKE_<LANG>_COMPILER_LAUNCHER"
301 " configure options or environment variables instead.")
bjacobe694d952020-11-03 12:05:35 -0500302 find_program(CCACHE_PROGRAM ccache)
303 if(CCACHE_PROGRAM)
304 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
Geoffrey Martin-Noble61ea1ed2022-11-23 16:25:57 -0800305 else()
306 message(SEND_ERROR
307 "IREE_ENABLE_CCACHE was set, but executable `ccache` was not found.")
bjacobe694d952020-11-03 12:05:35 -0500308 endif()
309endif()
Lei Zhange88470f2020-09-08 13:21:09 -0400310
Geoffrey Martin-Noble3fa4f8d2021-09-10 09:25:27 -0700311option(IREE_DEV_MODE "Configure settings to optimize for IREE development (as opposed to CI or release)" OFF)
Stella Laurenzo5b639122021-06-18 14:44:10 -0700312
313#-------------------------------------------------------------------------------
314# IREE assertions
315# We don't love the way this is done, but we have to line it up with how LLVM
316# does it and not diverge, since all implementations and all header users must
317# have the same definition of NDEBUG.
318#
319# LLVM defaults LLVM_ENABLE_ASSERTIONS to ON for Debug builds only but then
320# conditions itself to only update flags if not building Debug. We just let
321# IREE_ENABLE_ASSERTIONS be not conditioned on anything and only update the
322# flags in appropriate build types.
323#
324# If IREE_ENABLE_ASSERTIONS is set ON manually, then
325# - NDEBUG must be undefined
326# - LLVM_ENABLE_ASSERTIONS is forced off in order to keep multiple parties
327# from mucking with globals.
328#
329# Since CMake forces NDEBUG for !Debug builds, some surgery needs to be done
330# at the top level to avoid divergence.
331#-------------------------------------------------------------------------------
332
333option(IREE_ENABLE_ASSERTIONS "Force unset of NDEBUG compile option" OFF)
334
335# Filter -DNDEBUG from CMAKE_CXX_FLAGS_* and CMAKE_C_FLAGS_* (if
336# CMAKE_BUILD_TYPE is not Debug).
337function(iree_fix_ndebug)
Scott Todd1a1aea62022-04-28 09:12:11 -0700338 string(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPERCASE_CMAKE_BUILD_TYPE)
339 if(IREE_ENABLE_ASSERTIONS AND NOT "${_UPPERCASE_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
Stella Laurenzo5b639122021-06-18 14:44:10 -0700340 # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
Scott Todd1a1aea62022-04-28 09:12:11 -0700341 foreach(_FLAGS_VAR_TO_SCRUB
342 CMAKE_CXX_FLAGS_${_UPPERCASE_CMAKE_BUILD_TYPE}
343 CMAKE_C_FLAGS_${_UPPERCASE_CMAKE_BUILD_TYPE})
344 set(_ORIGINAL_FLAGS "${${_FLAGS_VAR_TO_SCRUB}}")
345 string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " _ALTERED_FLAGS "${_ORIGINAL_FLAGS}")
346 if(NOT "${_ORIGINAL_FLAGS}" STREQUAL "${_ALTERED_FLAGS}")
Stella Laurenzo5b639122021-06-18 14:44:10 -0700347 message(STATUS
Scott Todd1a1aea62022-04-28 09:12:11 -0700348 "IREE_ENABLE_ASSERTIONS force disabled NDEBUG for ${_FLAGS_VAR_TO_SCRUB}: '${_ORIGINAL_FLAGS}' -> '${_ALTERED_FLAGS}'")
349 set(${_FLAGS_VAR_TO_SCRUB} "${_ALTERED_FLAGS}" PARENT_SCOPE)
Stella Laurenzo5b639122021-06-18 14:44:10 -0700350 endif()
351 endforeach()
352
353 # Make sure that LLVM doesn't add its own logic for assertion disabling.
354 # We'd like to make sure that we are not dueling over globals.
355 set(LLVM_ENABLE_ASSERTIONS OFF PARENT_SCOPE)
356 endif()
357endfunction()
358iree_fix_ndebug()
359
Lei Zhange88470f2020-09-08 13:21:09 -0400360#-------------------------------------------------------------------------------
Lei Zhang7e253da2020-06-10 07:51:19 -0700361# IREE utility definitions
Lei Zhang0d281b72020-06-01 20:00:23 -0400362#-------------------------------------------------------------------------------
363
Scott Toddd1620f02021-12-22 14:55:38 -0800364list(APPEND CMAKE_MODULE_PATH
365 ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/
Scott Toddd1620f02021-12-22 14:55:38 -0800366)
367
Ben Vanik512d2d32019-09-20 13:22:34 -0700368include(iree_macros)
Ben Vanik185d30c2019-09-19 14:24:11 -0700369include(iree_copts)
Ben Vanik6b112ef2019-10-03 10:45:14 -0700370include(iree_cc_binary)
Ben Vanik185d30c2019-09-19 14:24:11 -0700371include(iree_cc_library)
372include(iree_cc_test)
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800373include(iree_external_cmake_options)
Ben Vanikcc2aff92019-09-24 10:23:55 -0700374include(iree_tablegen_library)
Lei Zhang22f0e242020-03-30 12:09:20 -0700375include(iree_tablegen_doc)
CindyLiu40ed02d2021-04-22 16:16:28 +0000376include(iree_c_embed_data)
Scott Todd11adcab2019-12-18 14:10:44 -0800377include(iree_bytecode_module)
Marius Brehler46e83312021-03-25 00:11:39 +0100378include(iree_c_module)
Stella Laurenzo94363e22020-12-15 13:46:14 -0800379include(iree_python)
Geoffrey Martin-Noblef0eaf372020-01-28 10:03:14 -0800380include(iree_lit_test)
Geoffrey Martin-Noble4526dcc2020-03-09 11:59:52 -0700381include(iree_add_all_subdirs)
Geoffrey Martin-Noblee5fd5b52020-03-31 11:31:30 -0700382include(iree_check_test)
bjacob5feef482021-10-21 16:53:58 -0400383include(iree_trace_runner_test)
Geoffrey Martin-Noble435c2702022-01-24 15:56:56 -0800384include(iree_native_test)
Geoffrey Martin-Noble2811e502022-01-25 09:44:40 -0800385include(iree_cc_binary_benchmark)
Geoffrey Martin-Noble66d48892021-10-29 12:24:58 -0700386include(iree_benchmark_suite)
Han-Chung Wanga6fbb762022-04-15 14:25:04 -0700387include(iree_microbenchmark_suite)
Scott Todd434ff0e2021-12-21 10:38:36 -0800388include(iree_hal_cts_test_suite)
CindyLiuae72b952022-08-23 15:26:08 -0700389include(iree_static_linker_test)
Jerry Wu116db872022-09-22 19:33:13 +0000390include(iree_fetch_artifact)
CindyLiu080198f2022-10-06 07:21:17 -0700391include(iree_run_module_test)
Ben Vanik185d30c2019-09-19 14:24:11 -0700392
Marius Brehler06ac36e2020-01-10 14:44:11 -0800393set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
394
Ben Vanik185d30c2019-09-19 14:24:11 -0700395#-------------------------------------------------------------------------------
Lei Zhange88470f2020-09-08 13:21:09 -0400396# IREE compilation flags
Scott Todd29d654e2020-06-11 15:24:17 -0700397#-------------------------------------------------------------------------------
398
Lei Zhangdd21f322020-09-10 10:47:33 -0400399iree_append_list_to_string(CMAKE_C_FLAGS_DEBUG ${IREE_C_FLAGS_DEBUG_LIST})
400iree_append_list_to_string(CMAKE_CXX_FLAGS_DEBUG ${IREE_CXX_FLAGS_DEBUG_LIST})
Scott Todd29d654e2020-06-11 15:24:17 -0700401
402set(CMAKE_CXX_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C++ compiler during fast builds." FORCE)
403set(CMAKE_C_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C compiler during fast builds." FORCE)
404set(CMAKE_EXE_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used for linking binaries during fast builds." FORCE)
405set(CMAKE_SHARED_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used by the shared libraries linker binaries during fast builds." FORCE)
406mark_as_advanced(
407 CMAKE_CXX_FLAGS_FASTBUILD
408 CMAKE_C_FLAGS_FASTBUILD
409 CMAKE_EXE_LINKER_FLAGS_FASTBUILD
410 CMAKE_SHARED_LINKER_FLAGS_FASTBUILD
411)
412
Scott Todd7649dee2022-07-18 11:31:46 -0700413# Override the system's default linker.
414# See also: https://llvm.org/docs/CMake.html#llvm-use-linker.
415set(IREE_USE_LINKER "" CACHE STRING "")
416# Equivalent to setting -DIREE_USE_LINKER=lld.
417# Note that unlike LLVM's LLVM_ENABLE_LLD, this does _not_ build lld. You will
418# need to either install a recent version of lld or build it from source prior
419# to setting this option. See also: https://lld.llvm.org/#using-lld.
420# This option is disabled on Apple platforms, where lld is not supported.
421cmake_dependent_option(IREE_ENABLE_LLD "Override the system's default linker to lld" OFF "NOT APPLE" OFF)
422
Scott Todd29d654e2020-06-11 15:24:17 -0700423include(iree_setup_toolchain)
424
425#-------------------------------------------------------------------------------
Stella Laurenzo29032b82021-10-14 15:21:44 -0700426# Python
427# If building features that require Python development, find them early in
428# one invocation (some CMake versions are sensitive to resolving out of order).
429# Otherwise, for features that just require the interpreter, find that alone.
Stella Laurenzoa3e97f12020-12-05 23:29:13 -0800430#-------------------------------------------------------------------------------
431
Stella Laurenzo29032b82021-10-14 15:21:44 -0700432if(IREE_BUILD_PYTHON_BINDINGS)
433 # After CMake 3.18, we are able to limit the scope of the search to just
434 # Development.Module. Searching for Development will fail in situations where
435 # the Python libraries are not available. When possible, limit to just
436 # Development.Module.
437 # See https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode
Scott Todda24c8c52022-05-17 09:22:47 -0700438 #
439 # Configuring the Development.Module is flaky in multi-project setups.
440 # "Bootstrapping" by first looking for the optional Development component
441 # seems to be robust generally.
442 # See: https://reviews.llvm.org/D118148
443 find_package(Python3 COMPONENTS Interpreter Development)
444 find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
Stella Laurenzo3149b6d2021-10-24 18:45:17 -0700445elseif(IREE_BUILD_COMPILER OR IREE_BUILD_TESTS)
Stella Laurenzoa3e97f12020-12-05 23:29:13 -0800446 find_package(Python3 COMPONENTS Interpreter REQUIRED)
447endif()
448
Stella Laurenzo3149b6d2021-10-24 18:45:17 -0700449# Extended Python environment checks.
450if(Python3_FOUND)
451 iree_detect_pyyaml()
452endif()
453
454if(IREE_BUILD_TESTS AND NOT IREE_PYYAML_FOUND)
455 message(WARNING "IREE's regression test suite requires PyYAML to run all tests. It is not installed, so some tests will be disabled.")
456endif()
457
Stella Laurenzoa3e97f12020-12-05 23:29:13 -0800458#-------------------------------------------------------------------------------
Niloy Sikdar47238df2021-07-28 23:37:33 +0530459# Check if git submodules have been initialized.
460# This will only run if python3 is available.
461#-------------------------------------------------------------------------------
462
Marius Brehler776d7e62021-12-21 22:50:52 +0100463option(IREE_ERROR_ON_MISSING_SUBMODULES "Error if submodules have not been initialized." ON)
464
Niloy Sikdar47238df2021-07-28 23:37:33 +0530465find_package(Python3 COMPONENTS Interpreter QUIET)
Scott Todde5b269a2021-11-16 15:25:02 -0800466find_package(Git)
Marius Brehler776d7e62021-12-21 22:50:52 +0100467if(IREE_ERROR_ON_MISSING_SUBMODULES AND Python3_FOUND AND Git_FOUND)
Scott Todde5b269a2021-11-16 15:25:02 -0800468 # Only check submodule status when the git commit changes.
Niloy Sikdar47238df2021-07-28 23:37:33 +0530469 execute_process(
Scott Todde5b269a2021-11-16 15:25:02 -0800470 COMMAND git rev-parse --short HEAD
Niloy Sikdar47238df2021-07-28 23:37:33 +0530471 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Scott Todde5b269a2021-11-16 15:25:02 -0800472 RESULT_VARIABLE SHORT_HASH_RESULT
473 OUTPUT_VARIABLE SHORT_HASH)
474 string(REGEX REPLACE "\n$" "" SHORT_HASH "${SHORT_HASH}")
Scott Todd2a8cd3b2021-12-13 11:58:44 -0800475 if(SHORT_HASH_RESULT EQUAL "0" AND NOT "${IREE_GIT_SHORT_HASH}" STREQUAL "${SHORT_HASH}")
CindyLiu0e8fdc62022-10-14 09:35:44 -0700476 if(NOT IREE_BUILD_COMPILER)
477 set(CHECK_SUBMODULE_ARGS "--runtime_only")
478 endif()
Scott Todde5b269a2021-11-16 15:25:02 -0800479 execute_process(
CindyLiu0e8fdc62022-10-14 09:35:44 -0700480 COMMAND ${Python3_EXECUTABLE} build_tools/scripts/git/check_submodule_init.py ${CHECK_SUBMODULE_ARGS}
Scott Todde5b269a2021-11-16 15:25:02 -0800481 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
482 RESULT_VARIABLE SUBMODULE_INIT_RESULT
483 )
484 if(NOT SUBMODULE_INIT_RESULT EQUAL "0")
485 message(FATAL_ERROR "check_submodule_init.py failed, see the logs above")
486 else()
487 set(IREE_GIT_SHORT_HASH "${SHORT_HASH}" CACHE STRING "" FORCE)
488 endif()
Niloy Sikdar47238df2021-07-28 23:37:33 +0530489 endif()
490endif()
491
492#-------------------------------------------------------------------------------
Stella Laurenzo98388662022-02-03 15:37:30 -0800493# CUDA configuration for both the compiler and runtime.
494# We do this at the top level so that we can fail fast and make global
495# decisions that effect both compiler and runtime. It also helps with error
496# messaging to do this all in one place, since we can provide very targeted
497# advice.
498#-------------------------------------------------------------------------------
499
Lei Zhang299fc932022-12-08 16:04:35 -0800500set(IREE_CUDA_LIBDEVICE_PATH "" CACHE FILEPATH "Absolute path to an appropriate libdevice.*.bc (needed to build the IREE cuda compiler target)")
Stella Laurenzo98388662022-02-03 15:37:30 -0800501
502# If any CUDA features are being built, try to locate a CUDA SDK. We will fall
503# back to this as needed for specific features.
504if(IREE_TARGET_BACKEND_CUDA OR IREE_HAL_DRIVER_CUDA)
Stella Laurenzo5062ae32022-02-04 17:59:16 -0800505 find_package(CUDAToolkit)
Stella Laurenzo59439022022-04-12 21:04:26 -0700506
Kojo Acquah719856b2022-06-15 18:35:02 -0400507 if(NOT CUDAToolkit_FOUND)
508 if(DEFINED ENV{IREE_CUDA_DEPS_DIR})
509 # We define the magic IREE_CUDA_DEPS_DIR env var in our CI docker images if we
510 # have a stripped down CUDA toolkit suitable for compiling available. We
511 # trigger on this below as a fallback for locating headers and libdevice
512 # files.
513 set(CUDAToolkit_ROOT "$ENV{IREE_CUDA_DEPS_DIR}")
514 message(STATUS "CUDA SDK not found by CMake but using IREE_CUDA_DEPS = ${CUDAToolkit_ROOT}")
Lei Zhang299fc932022-12-08 16:04:35 -0800515 elseif((NOT EXISTS "${IREE_CUDA_LIBDEVICE_PATH}") OR IREE_HAL_DRIVER_CUDA)
Kojo Acquah719856b2022-06-15 18:35:02 -0400516 # If we haven't found CUDA deps, download at least enough to build for CUDA.
517 # This will define IREE_CUDA_DOWNLOAD_LIBDEVICE_PATH & IREE_CUDA_DOWNLOAD_INCLUDE_PATH
518 # vars with the target deps.
519 message(STATUS "CUDA SDK not found by CMake but downloading dependencies")
520 add_subdirectory(build_tools/third_party/cuda EXCLUDE_FROM_ALL)
521 endif()
Stella Laurenzo59439022022-04-12 21:04:26 -0700522 endif()
Stella Laurenzo98388662022-02-03 15:37:30 -0800523endif()
524
525# If an explicit libdevice file was not specified, and the compiler backend
526# is being built, probe for one.
527if(IREE_TARGET_BACKEND_CUDA)
Lei Zhang299fc932022-12-08 16:04:35 -0800528 if(EXISTS "${IREE_CUDA_LIBDEVICE_PATH}")
Stella Laurenzo9fd5b5d2022-02-14 17:07:28 -0800529 # Explicitly provided: do nothing.
530 elseif(CUDAToolkit_FOUND AND CUDAToolkit_LIBRARY_ROOT)
Stella Laurenzo98388662022-02-03 15:37:30 -0800531 # Note that the variable CUDAToolkit_LIBRARY_ROOT keys off of the presence
532 # of version.txt, which was changed to version.json in recent releases
533 # and thwarts the search.
534 set(IREE_CUDA_LIBDEVICE_PATH "${CUDAToolkit_LIBRARY_ROOT}/nvvm/libdevice/libdevice.10.bc")
535 elseif(CUDAToolkit_FOUND AND CUDAToolkit_BIN_DIR)
536 # Back-track from the bin dir as a fallback.
537 set(IREE_CUDA_LIBDEVICE_PATH "${CUDAToolkit_BIN_DIR}/../nvvm/libdevice/libdevice.10.bc")
Stella Laurenzo5062ae32022-02-04 17:59:16 -0800538 elseif(CUDAToolkit_ROOT)
539 # Sometimes the CUDA toolkit doesn't detect... because, you know. Computers
540 # are hard and such. In this case, if the user went to the trouble to
541 # tell us where it is, we have enough information.
542 set(IREE_CUDA_LIBDEVICE_PATH "${CUDAToolkit_ROOT}/nvvm/libdevice/libdevice.10.bc")
Kojo Acquah719856b2022-06-15 18:35:02 -0400543 elseif(IREE_CUDA_DOWNLOAD_LIBDEVICE_PATH)
544 message(STATUS "Using downloaded CUDA libdevice")
545 set(IREE_CUDA_LIBDEVICE_PATH "${IREE_CUDA_DOWNLOAD_LIBDEVICE_PATH}")
Stella Laurenzo98388662022-02-03 15:37:30 -0800546 else()
547 message(FATAL_ERROR "Building with IREE_TARGET_BACKEND_CUDA requires either a CUDA SDK (consult CMake docs for your version: https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html) or an explicit path to libdevice (set with -DIREE_CUDA_LIBDEVICE_PATH=/path/to/libdevice.10.bc)")
548 endif()
549
550 if(EXISTS "${IREE_CUDA_LIBDEVICE_PATH}")
551 message(STATUS "Using CUDA libdevice: ${IREE_CUDA_LIBDEVICE_PATH}")
552 else()
553 message(SEND_ERROR "Cannot find CUDA libdevice file (${IREE_CUDA_LIBDEVICE_PATH}). Either configure your CUDA SDK such that it can be found or specify explicitly via -DIREE_CUDA_LIBDEVICE_PATH=/path/to/libdevice.10.bc")
554 endif()
555endif()
556
Stella Laurenzo5062ae32022-02-04 17:59:16 -0800557if(IREE_HAL_DRIVER_CUDA)
558 if(CUDAToolkit_FOUND)
559 message(STATUS "Using CUDA INCLUDE_DIRS from found SDK: ${CUDAToolkit_INCLUDE_DIRS}")
560 elseif(CUDAToolkit_ROOT)
561 # See note above about computers being hard.
562 # We make minimal use of CUDA for the runtime and really just need cuda.h
563 # presently. So let's make a guess at that.
564 set(CUDAToolkit_INCLUDE_DIRS "${CUDAToolkit_ROOT}/include")
565 if(EXISTS "${CUDAToolkit_INCLUDE_DIRS}/cuda.h")
566 message(STATUS "Using CUDA INCLUDE_DIRS from CUDAToolkit_ROOT: ${CUDAToolkit_INCLUDE_DIRS}")
567 else()
568 message(SEND_ERROR "Using explicitly specified CUDAToolkit_ROOT, could not find cuda.h at: ${CUDAToolkit_INCLUDE_DIRS}")
569 endif()
Kojo Acquah719856b2022-06-15 18:35:02 -0400570 elseif(IREE_CUDA_DOWNLOAD_INCLUDE_PATH)
571 message(STATUS "Using downloaded CUDA includes")
572 set(CUDAToolkit_INCLUDE_DIRS "${IREE_CUDA_DOWNLOAD_INCLUDE_PATH}")
Stella Laurenzo5062ae32022-02-04 17:59:16 -0800573 else()
574 message(SEND_ERROR "Cannot build IREE runtime CUDA components (-DIREE_HAL_DRIVER_CUDA=ON) because a CUDA SDK was not found. Consult CMake docs for your version: https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html")
575 endif()
Stella Laurenzo98388662022-02-03 15:37:30 -0800576endif()
577
578#-------------------------------------------------------------------------------
Stella Laurenzo382122d2020-06-11 16:18:09 -0700579# MLIR/LLVM Dependency
Stella Laurenzo382122d2020-06-11 16:18:09 -0700580#-------------------------------------------------------------------------------
581
Stella Laurenzo275215d2021-08-06 11:50:28 -0700582if(NOT IREE_BUILD_COMPILER)
583 message(STATUS "Not adding LLVM/MLIR because the configuration does not require it")
584elseif(TARGET LLVMSupport)
585 message(STATUS "Not adding IREE bundled LLVM because it has already been included")
586 if(NOT TARGET MLIRIR)
587 message(FATAL_ERROR "Detected externally provided LLVM project but could not find MLIR projects (is it enabled/installed?)")
Stella Laurenzo382122d2020-06-11 16:18:09 -0700588 endif()
Stella Laurenzo275215d2021-08-06 11:50:28 -0700589else()
590 message(STATUS "Adding bundled LLVM source dependency")
591 iree_set_llvm_cmake_options()
Stella Laurenzo382122d2020-06-11 16:18:09 -0700592
Stella Laurenzo688670f2021-09-24 18:16:25 -0700593 # Enable MLIR Python bindings if IREE Python bindings enabled.
594 if(IREE_BUILD_PYTHON_BINDINGS)
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800595 set(MLIR_ENABLE_BINDINGS_PYTHON ON)
596 set(MHLO_ENABLE_BINDINGS_PYTHON ON)
Stella Laurenzo688670f2021-09-24 18:16:25 -0700597 endif()
598
Stella Laurenzo275215d2021-08-06 11:50:28 -0700599 # Disable LLVM's warnings.
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800600 set(LLVM_ENABLE_WARNINGS OFF)
Stella Laurenzo275215d2021-08-06 11:50:28 -0700601
Ben Vanik89a77fa2020-10-07 17:19:31 -0700602 # Stash cmake build type in case LLVM messes with it.
603 set(_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
604
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700605 # Add default external projects.
Stella Laurenzo02230c12021-08-10 03:58:42 +0000606 iree_add_llvm_external_project(mlir-iree-dialects MLIR_IREE_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}/llvm-external-projects/iree-dialects)
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700607 iree_add_llvm_external_project(mlir-hlo MLIR_HLO ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mlir-hlo)
Scott Todde23d4a72022-07-27 14:16:39 -0700608 if(IREE_INPUT_TORCH)
Yi Zhangc35fee82022-04-06 14:35:28 -0400609 iree_add_llvm_external_project(torch-mlir-dialects TORCH_MLIR_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/torch-mlir-dialects)
610 endif()
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700611
Stella Laurenzo275215d2021-08-06 11:50:28 -0700612 add_subdirectory("third_party/llvm-project/llvm" EXCLUDE_FROM_ALL)
Stella Laurenzo382122d2020-06-11 16:18:09 -0700613
Ben Vanik89a77fa2020-10-07 17:19:31 -0700614 # Reset CMAKE_BUILD_TYPE to its previous setting.
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800615 set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" )
Stella Laurenzo382122d2020-06-11 16:18:09 -0700616
Stella Laurenzo275215d2021-08-06 11:50:28 -0700617 # Extend module path to allow submodules to use LLVM and MLIR CMake modules.
618 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/mlir")
619 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/lib/cmake/llvm/")
Marius Brehler71f76cb2020-11-10 20:56:55 +0100620
Stella Laurenzo275215d2021-08-06 11:50:28 -0700621 # Add the bundled include directories for cmake files looking for them.
622 list(APPEND LLVM_INCLUDE_DIRS
623 ${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include
624 ${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include
625 )
626 list(APPEND MLIR_INCLUDE_DIRS
627 ${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include
628 ${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include
629 )
Marius Brehler71f76cb2020-11-10 20:56:55 +0100630
Stella Laurenzo60128592022-04-17 21:52:09 -0700631 # TODO: It should be possible to fix upstream targets so as to not require
632 # any of these. Remove as they become unnecessary.
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700633 function(_hack_llvm_include_paths)
Scott Todd1a1aea62022-04-28 09:12:11 -0700634 set(_COMMON_INCLUDE_DIRS
Stella Laurenzo60128592022-04-17 21:52:09 -0700635 # LLVM
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700636 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include>
637 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include>
Stella Laurenzo60128592022-04-17 21:52:09 -0700638
639 # MLIR
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700640 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include>
641 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include>
Stella Laurenzo60128592022-04-17 21:52:09 -0700642
643 # LLD
644 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/lld/include>
645 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/lld/include>
646
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700647 )
648 # Avoid globally modifying paths by instead adding the include paths to the
649 # rules that really should have them in the first place.
Scott Todd1a1aea62022-04-28 09:12:11 -0700650 target_include_directories(LLVMSupport PUBLIC ${_COMMON_INCLUDE_DIRS})
651 target_include_directories(MLIRSupport PUBLIC ${_COMMON_INCLUDE_DIRS})
Stella Laurenzo7ec09ce2022-11-24 11:13:52 -0800652
653 # Also add a library that can be depended on to get LLVM includes setup
654 # properly. bazel_to_cmake targets this for some header only pseudo deps.
655 add_library(IREELLVMIncludeSetup INTERFACE)
656 target_include_directories(IREELLVMIncludeSetup INTERFACE ${_COMMON_INCLUDE_DIRS})
Stella Laurenzo62fbef02021-08-09 20:52:48 -0700657 endfunction()
658 _hack_llvm_include_paths()
Stella Laurenzo382122d2020-06-11 16:18:09 -0700659endif()
660
Stella Laurenzo382122d2020-06-11 16:18:09 -0700661#-------------------------------------------------------------------------------
Scott Todd8b0b0cd2021-12-16 15:13:57 -0800662# Other dependencies
Stella Laurenzoa3e97f12020-12-05 23:29:13 -0800663#-------------------------------------------------------------------------------
664
Ben Vanik512d2d32019-09-20 13:22:34 -0700665include(external_cc_library)
Ben Vanik2d1808b2020-07-17 19:02:16 -0700666include(flatbuffer_c_library)
Ben Vanik512d2d32019-09-20 13:22:34 -0700667
Ben Vanika9036492021-06-25 09:39:53 -0700668add_subdirectory(build_tools/third_party/libyaml EXCLUDE_FROM_ALL)
Jerry Wuae05f302022-05-17 13:58:13 +0000669add_subdirectory(build_tools/third_party/llvm-project EXCLUDE_FROM_ALL)
Ben Vanika9036492021-06-25 09:39:53 -0700670add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL)
Ben Vanik512d2d32019-09-20 13:22:34 -0700671
Stella Laurenzo275215d2021-08-06 11:50:28 -0700672iree_set_googletest_cmake_options()
Marius Brehlerf5022e82019-12-13 15:20:25 -0800673add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
Stella Laurenzo275215d2021-08-06 11:50:28 -0700674
675if(IREE_ENABLE_THREADING)
676 iree_set_benchmark_cmake_options()
Cindy Liu331946c2021-06-01 12:20:30 -0700677 add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL)
Ben Vanik4aae0032022-04-19 15:49:26 -0700678 if(IREE_ENABLE_CPUINFO)
679 iree_set_cpuinfo_cmake_options()
680 add_subdirectory(third_party/cpuinfo EXCLUDE_FROM_ALL)
681 endif()
Cindy Liu331946c2021-06-01 12:20:30 -0700682endif()
Stella Laurenzo275215d2021-08-06 11:50:28 -0700683
Stella Laurenzo275215d2021-08-06 11:50:28 -0700684add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL)
Stella Laurenzo275215d2021-08-06 11:50:28 -0700685
Marius Brehler9b86ad52022-06-08 17:09:02 +0200686if(IREE_HAL_DRIVER_VULKAN)
687 add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL)
688endif()
Ben Vanik185d30c2019-09-19 14:24:11 -0700689
Scott Todd4e1a69b2021-01-25 15:29:49 -0800690# TODO(scotttodd): Iterate some more and find a better place for this.
Scott Todd1a1aea62022-04-28 09:12:11 -0700691if(NOT CMAKE_CROSSCOMPILING)
Ben Vanik68747192021-10-26 20:38:45 -0700692 install(
693 TARGETS iree-flatcc-cli
694 COMPONENT iree-flatcc-cli
695 RUNTIME DESTINATION bin
696 )
Lei Zhang0d281b72020-06-01 20:00:23 -0400697endif()
698
Stella Laurenzo275215d2021-08-06 11:50:28 -0700699if(IREE_BUILD_COMPILER)
Marius Brehler3eaf4442021-01-13 18:22:08 +0100700 add_subdirectory(build_tools/third_party/mlir-hlo EXCLUDE_FROM_ALL)
Ben Vanikcc2aff92019-09-24 10:23:55 -0700701endif()
702
Stella Laurenzo275215d2021-08-06 11:50:28 -0700703if(IREE_BUILD_TESTS)
Geoffrey Martin-Noble10f18222022-06-09 16:00:13 -0700704 include(iree_configure_testing)
Marius Brehler29676502019-12-27 17:07:10 -0800705endif()
706
MaheshRavishankar1547ac22021-09-23 15:22:46 -0700707if(IREE_BUILD_PYTHON_BINDINGS)
Stella Laurenzo95ad84c2021-09-24 14:56:01 -0700708 if(NOT TARGET pybind11::module)
709 message(STATUS "Using bundled pybind11")
710 add_subdirectory(third_party/pybind11 EXCLUDE_FROM_ALL)
711 else()
712 message(STATUS "Not including bundled pybind11 (already configured)")
713 endif()
Marius Brehlerf3d73c92020-01-16 16:11:52 -0800714endif()
715
Scott Toddd1620f02021-12-22 14:55:38 -0800716if(IREE_TARGET_BACKEND_METAL_SPIRV)
Stella Laurenzo275215d2021-08-06 11:50:28 -0700717 iree_set_spirv_cross_cmake_options()
Lei Zhang3cbb28e2020-09-22 15:30:27 -0400718 # SPIRV-Cross is needed to cross compile SPIR-V into MSL source code.
719 add_subdirectory(third_party/spirv_cross EXCLUDE_FROM_ALL)
720endif()
721
Scott Toddf8519ca2021-12-16 16:01:49 -0800722if(IREE_TARGET_BACKEND_WEBGPU)
723 # Tint is needed to compile SPIR-V into WGSL source code.
724 # Tint also requires SPIRV-Tools, which requires SPIRV-Headers.
725 iree_set_spirv_headers_cmake_options()
726 add_subdirectory(third_party/spirv_headers EXCLUDE_FROM_ALL)
727 add_subdirectory(build_tools/third_party/spirv-tools EXCLUDE_FROM_ALL)
728 add_subdirectory(build_tools/third_party/tint EXCLUDE_FROM_ALL)
729endif()
730
Ben Vanik185d30c2019-09-19 14:24:11 -0700731#-------------------------------------------------------------------------------
Lei Zhang22f0e242020-03-30 12:09:20 -0700732# IREE top-level targets
733#-------------------------------------------------------------------------------
734
Jerry Wu16e2d9c2022-11-22 06:19:46 +0000735if(IREE_BUILD_BENCHMARKS OR IREE_BUILD_EXPERIMENTAL_E2E_TEST_ARTIFACTS)
Scott Todd9ca75632022-04-13 10:47:11 -0700736 # Add top-level custom targets to drive generating benchmark suites.
737
738 # iree-benchmark-import-models imports benchmark models from their source
739 # formats, such as .tflite flatbuffers, to IREE-compatible .mlir files.
740 add_custom_target(iree-benchmark-import-models)
741
742 # iree-benchmark-suites fully prepares benchmark models for benchmarking:
743 # * importing from source formats to IREE-compatible .mlir files
744 # * compiling from .mlir files to benchmark-ready .vmfb files
745 # * generating flagfiles for executing the benchmark .vmfb files
Lei Zhangfe4403e2021-06-01 15:09:43 -0400746 add_custom_target(iree-benchmark-suites)
747endif()
748
Jerry Wud41d0732022-11-23 01:43:55 +0000749# TODO(#11263): This conditional block should be merged with the block above
750# once we remove IREE_BUILD_BENCHMARKS.
751if(IREE_BUILD_EXPERIMENTAL_E2E_TEST_ARTIFACTS)
Jerry Wufb87ad12022-12-21 05:59:02 +0000752 # iree-e2e-compile-stats-suites compiles the benchmark models with specific
753 # flags to collect the compilation statistics.
754 add_custom_target(iree-e2e-compile-stats-suites)
755
Jerry Wud41d0732022-11-23 01:43:55 +0000756 # iree-e2e-test-artifacts builds all e2e test artifacts, including benchmarks
757 # and model tests.
758 add_custom_target(iree-e2e-test-artifacts)
Jerry Wud41d0732022-11-23 01:43:55 +0000759 add_dependencies(iree-e2e-test-artifacts
760 iree-benchmark-import-models
761 iree-benchmark-suites
Jerry Wufb87ad12022-12-21 05:59:02 +0000762 iree-e2e-compile-stats-suites
Jerry Wud41d0732022-11-23 01:43:55 +0000763 )
764endif()
765
Scott Todd1a1aea62022-04-28 09:12:11 -0700766if(IREE_BUILD_MICROBENCHMARKS)
Han-Chung Wanga6fbb762022-04-15 14:25:04 -0700767 # Add top-level custom targets to drive generating microbenchmark suites.
768 add_custom_target(iree-microbenchmark-suites)
769endif()
770
Scott Todd1a1aea62022-04-28 09:12:11 -0700771if(IREE_BUILD_DOCS)
Lei Zhang22f0e242020-03-30 12:09:20 -0700772 # Add a top-level custom target to drive generating all documentation.
773 # Register it to the default target given that IREE_BUILD_DOCS is explicitly
774 # requested.
775 add_custom_target(iree-doc ALL)
776endif()
777
Stella Laurenzo74b04b72022-03-02 10:21:11 -0800778# Testing rules that require generation will add dependencies to this target.
779# This allows them to be EXCLUDE_FROM_ALL but still invokable.
780add_custom_target(iree-test-deps COMMENT "Building IREE test deps")
781
CindyLiu99373e02022-10-12 09:22:24 -0700782# Testing rules that generate test scripts for iree-run-module-test will add
783# dependencies to this target. It is a subset of `iree-test-deps`.
784add_custom_target(iree-run-module-test-deps
785 COMMENT
786 "Building IREE run module test targets"
787)
788
Ben Vanik5efe0342022-11-22 17:28:04 -0800789# Samples may require additional files to be built/configured and will add
Ben Vanikb4bf5f72022-12-05 19:28:57 -0800790# dependencies to this target.
Ben Vanik5efe0342022-11-22 17:28:04 -0800791add_custom_target(iree-sample-deps
792 COMMENT
793 "Building IREE sample data targets"
794)
795
Lei Zhang22f0e242020-03-30 12:09:20 -0700796#-------------------------------------------------------------------------------
Ben Vanik185d30c2019-09-19 14:24:11 -0700797# IREE top-level libraries
798#-------------------------------------------------------------------------------
799
Rob Sudermand42e0022022-06-08 16:38:45 -0700800if(IREE_ENABLE_CLANG_TIDY)
801 set(CMAKE_CXX_CLANG_TIDY clang-tidy -warnings-as-errors=*)
802endif()
803
Marius Brehlerf5022e82019-12-13 15:20:25 -0800804add_subdirectory(build_tools/embed_data/)
805
Jerry Wu16e2d9c2022-11-22 06:19:46 +0000806if(IREE_BUILD_BENCHMARKS OR IREE_BUILD_EXPERIMENTAL_E2E_TEST_ARTIFACTS)
Stella Laurenzoa6bf65c2022-01-11 20:47:51 -0800807 find_program(IREE_IMPORT_TFLITE_PATH iree-import-tflite)
808 if(IREE_IMPORT_TFLITE_PATH)
809 message(STATUS "Found ${IREE_IMPORT_TFLITE_PATH} to generate benchmark artifacts")
810 else()
811 message(STATUS "iree-import-tflite not found. Some benchmarks may not configure")
812 endif()
Jerry Wu60798ca2022-06-21 23:36:40 +0000813 find_program(IREE_IMPORT_TF_PATH iree-import-tf)
814 if(IREE_IMPORT_TF_PATH)
815 message(STATUS "Found ${IREE_IMPORT_TF_PATH} to generate benchmark artifacts")
816 else()
817 message(STATUS "iree-import-tf not found. Some benchmarks may not configure")
818 endif()
Jerry Wu16e2d9c2022-11-22 06:19:46 +0000819endif()
820
821# Note: Test deps are not built as part of all (use the iree-test-deps target).
822add_subdirectory(tests EXCLUDE_FROM_ALL)
823
824if(IREE_BUILD_BENCHMARKS)
Lei Zhang08cea042021-07-20 12:44:01 -0400825 add_subdirectory(benchmarks)
Lei Zhangff38a682021-06-08 21:12:24 -0400826endif()
827
Scott Todd1a1aea62022-04-28 09:12:11 -0700828if(IREE_BUILD_COMPILER)
Stella Laurenzo41a2ceb2022-04-29 12:49:36 -0700829 add_subdirectory(compiler)
Ben Vanikcc2aff92019-09-24 10:23:55 -0700830endif()
Ben Vanik6b112ef2019-10-03 10:45:14 -0700831
Scott Todd4f16b992022-05-17 10:33:53 -0700832add_subdirectory(runtime)
833
Scott Todd4c022df2022-05-10 16:55:18 -0700834# tools/ can depend on compiler/ and runtime/
Scott Toddf57ab752022-05-23 10:36:44 -0700835add_subdirectory(tools)
Ben Vanik6b112ef2019-10-03 10:45:14 -0700836
Rob Sudermand42e0022022-06-08 16:38:45 -0700837
838if(IREE_ENABLE_CLANG_TIDY)
839 set(CMAKE_CXX_CLANG_TIDY "")
840endif()
841
Stella Laurenzod3770ff2021-10-18 22:54:18 -0700842if(IREE_BUILD_TRACY)
Stella Laurenzo3149b6d2021-10-24 18:45:17 -0700843 if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
Stella Laurenzod3770ff2021-10-18 22:54:18 -0700844 message(WARNING "Building Tracy (IREE_BUILD_TRACY) on non-Linux is unsupported and may fail below.")
845 endif()
846 add_subdirectory(build_tools/third_party/tracy ${CMAKE_CURRENT_BINARY_DIR}/tracy)
847 if(NOT TARGET IREETracyCaptureServer)
848 message(SEND_ERROR "Could not build Tracy. Either unset IREE_BUILD_TRACY or look for missing dependencies above and install them.")
849 endif()
850endif()
851
Scott Toddf57ab752022-05-23 10:36:44 -0700852# Order constraint: The python bindings install tools targets from tools/
Stella Laurenzod3770ff2021-10-18 22:54:18 -0700853# and tracy, and must come after it.
Stella Laurenzo3b44a0a2022-04-18 19:57:57 -0700854if(IREE_BUILD_PYTHON_BINDINGS)
Stella Laurenzo60128592022-04-17 21:52:09 -0700855 # Write out a .env file to make IDEs and developers happy.
856 # Yes, we are writing this to the source dir. It is only for IDEs and if
Scott Toddfe9cb172022-12-08 09:17:52 -0800857 # it gets clobbered, it is fine (it is also ignored in .gitignore).
Stella Laurenzo41a2ceb2022-04-29 12:49:36 -0700858 set(_PYTHONPATH_ENV "PYTHONPATH=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}/compiler/bindings/python;${CMAKE_CURRENT_BINARY_DIR}/runtime/bindings/python>\n")
Scott Toddfe9cb172022-12-08 09:17:52 -0800859 file(GENERATE OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/.env" CONTENT "${_PYTHONPATH_ENV}")
860 file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/.env" CONTENT "${_PYTHONPATH_ENV}")
861 # Similarly, write out .env.bat for Windows.
862 set(_PYTHONPATH_ENV_BAT "set PYTHONPATH=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}/compiler/bindings/python;${CMAKE_CURRENT_BINARY_DIR}/runtime/bindings/python>\n")
863 file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/.env.bat" CONTENT "${_PYTHONPATH_ENV_BAT}")
Stella Laurenzo77a63cd2021-01-04 17:29:54 -0800864endif()
865
Scott Todd1a1aea62022-04-28 09:12:11 -0700866if(IREE_BUILD_BINDINGS_TFLITE)
Scott Toddada25e62022-05-03 16:16:15 -0700867 add_subdirectory(runtime/bindings/tflite)
Ben Vanikcd1132f2021-01-29 15:58:17 -0800868endif()
869
Scott Todd1a1aea62022-04-28 09:12:11 -0700870if(IREE_BUILD_EXPERIMENTAL_REMOTING)
Stella Laurenzo0f005e52020-12-27 11:54:33 -0800871 # NOTE: Currently liburing is only used by the experimental remoting
872 # support, so keeping it scoped here. If this broadens, then include along
873 # with other dependencies as normal.
874 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
875 message(STATUS "Enabling liburing")
876 add_subdirectory(build_tools/third_party/liburing EXCLUDE_FROM_ALL)
877 endif()
878 add_subdirectory(experimental/remoting)
Ben Vanikb64e9182020-01-30 15:19:37 -0800879endif()
Scott Toddee30e1b2020-02-03 16:44:15 -0800880
Scott Todd1a1aea62022-04-28 09:12:11 -0700881if(IREE_BUILD_EXPERIMENTAL_WEB_SAMPLES)
Scott Todd15fce0a2022-02-14 12:43:23 -0800882 add_subdirectory(experimental/web)
Scott Toddf237b5e2022-01-28 11:02:25 -0800883endif()
884
Stella Laurenzo03e48db2020-06-11 18:35:13 -0700885set(IREE_PUBLIC_INCLUDE_DIRS "${IREE_COMMON_INCLUDE_DIRS}"
886 CACHE INTERNAL "IREE: Include Directories" FORCE)
Stella Laurenzo688670f2021-09-24 18:16:25 -0700887
Jerry Wu623d1742022-03-31 18:16:02 +0000888#-------------------------------------------------------------------------------
889# IREE benchmark tools
890#-------------------------------------------------------------------------------
891
892add_subdirectory(build_tools/benchmarks)
Stella Laurenzo3b44a0a2022-04-18 19:57:57 -0700893
894#-------------------------------------------------------------------------------
Jerry Wu71562cc2022-09-20 18:56:41 -0700895# IREE build tools python modules
896#-------------------------------------------------------------------------------
897
898add_subdirectory(build_tools/python)
899
900#-------------------------------------------------------------------------------
Scott Todd4f16b992022-05-17 10:33:53 -0700901# Samples
Stella Laurenzo3b44a0a2022-04-18 19:57:57 -0700902#-------------------------------------------------------------------------------
903
Scott Todd4c022df2022-05-10 16:55:18 -0700904# samples/ can depend on anything, so we include it last
Stella Laurenzo1e8d1fa2022-04-22 09:50:43 -0700905if(IREE_BUILD_SAMPLES)
906 add_subdirectory(samples)
907endif()
Geoffrey Martin-Noble10f18222022-06-09 16:00:13 -0700908
909if(IREE_BUILD_TESTS)
910 iree_create_ctest_customization()
911endif()