forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
574 lines (479 loc) · 21.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# Copyright 2019 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.13.4)
# Do not set MSVC warning flags like /W3 by default (since 3.15):
# https://cmake.org/cmake/help/v3.15/policy/CMP0092.html
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
# LLVM requires CMP0116 for tblgen: https://reviews.llvm.org/D101083
# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
set(CMAKE_POLICY_DEFAULT_CMP0116 OLD)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(iree ASM C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(IREE_IDE_FOLDER IREE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(${MSVC})
enable_language(ASM_MASM)
else()
enable_language(ASM)
endif()
#-------------------------------------------------------------------------------
# Project component configuration
#-------------------------------------------------------------------------------
option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF)
option(IREE_ENABLE_COMPILER_TRACING "Enables instrumented compiler tracing." OFF)
option(IREE_ENABLE_MLIR "Enables MLIR/LLVM dependencies." ON)
option(IREE_ENABLE_EMITC "Enables MLIR EmitC dependencies." OFF)
option(IREE_BUILD_COMPILER "Builds the IREE compiler." ON)
option(IREE_BUILD_TESTS "Builds IREE unit tests." ON)
option(IREE_BUILD_BENCHMARKS "Builds IREE benchmark suites." OFF)
option(IREE_BUILD_DOCS "Builds IREE docs." OFF)
option(IREE_BUILD_SAMPLES "Builds IREE sample projects." ON)
option(IREE_BUILD_TENSORFLOW_ALL "Builds all TensorFlow compiler frontends." OFF)
option(IREE_BUILD_TENSORFLOW_COMPILER "Builds TensorFlow compiler frontend." OFF)
option(IREE_BUILD_TFLITE_COMPILER "Builds the TFLite compiler frontend." OFF)
option(IREE_BUILD_XLA_COMPILER "Builds TensorFlow XLA compiler frontend." OFF)
option(IREE_ENABLE_THREADING "Builds IREE in with thread library support." ON)
set(IREE_HAL_DRIVERS_TO_BUILD "all"
CACHE STRING "Semicolon-separated list of HAL drivers to build, or \"all\".")
set(IREE_TARGET_BACKENDS_TO_BUILD "all"
CACHE STRING "Semicolon-separated list of target backends to build, or \"all\".")
# Properties controlling version and naming of release artifacts.
set(IREE_RELEASE_PACKAGE_SUFFIX "-dev" CACHE STRING "Suffix to append to distributed package names")
set(IREE_RELEASE_VERSION "0.1a1" CACHE STRING "Version to embed in distributed packages")
set(IREE_RELEASE_REVISION "HEAD" CACHE STRING "Version control revision information to embed in distributed packages")
# Master enable for tensorflow build support.
# Note that this is a normal CMake variable used to gate build features (not
# a cache variable that is user-settable).
set(IREE_ENABLE_TENSORFLOW OFF)
if(${IREE_BUILD_TENSORFLOW_ALL} OR
${IREE_BUILD_TENSORFLOW_COMPILER} OR
${IREE_BUILD_TFLITE_COMPILER} OR
${IREE_BUILD_XLA_COMPILER})
set(IREE_ENABLE_TENSORFLOW ON)
endif()
option(IREE_BUILD_BINDINGS_TFLITE "Builds the IREE TFLite C API compatibility shim" ON)
option(IREE_BUILD_BINDINGS_TFLITE_JAVA "Builds the IREE TFLite Java bindings with the C API compatibility shim" ON)
# Default python bindings to enabled for some features.
if(${IREE_ENABLE_TENSORFLOW})
option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" ON)
else()
option(IREE_BUILD_PYTHON_BINDINGS "Builds the IREE python bindings" OFF)
endif()
#-------------------------------------------------------------------------------
# Experimental project flags
#-------------------------------------------------------------------------------
option(IREE_BUILD_EXPERIMENTAL_REMOTING "Builds experimental remoting support." OFF)
option(IREE_BUILD_EXPERIMENTAL_JAVA_BINDINGS "Builds the experimental java bindings." OFF)
option(IREE_BUILD_EXPERIMENTAL_ROCM "Builds the experimental ROCM Backend." OFF)
option(IREE_ENABLE_NEW_INTEGRATION_TESTS "Enables new integration tests and disables old." OFF)
#-------------------------------------------------------------------------------
# Derived flags based on primary options
#-------------------------------------------------------------------------------
if(${IREE_BUILD_COMPILER})
set(IREE_ENABLE_MLIR ON CACHE BOOL "Enable LLVM dependencies if the IREE compiler is build." FORCE)
endif()
if(${IREE_ENABLE_MLIR})
set(IREE_MLIR_DEP_MODE "BUNDLED" CACHE STRING "One of BUNDLED (default), DISABLED, INSTALLED")
endif()
if(${IREE_ENABLE_EMITC})
if(NOT ${IREE_ENABLE_MLIR})
message(FATAL_ERROR "Enabling EmitC requires setting IREE_ENABLE_MLIR to ON.")
endif()
string(TOUPPER "${IREE_MLIR_DEP_MODE}" uppercase_IREE_MLIR_DEP_MODE)
if(NOT uppercase_IREE_MLIR_DEP_MODE MATCHES "^(BUNDLED|INSTALLED)$")
message(FATAL_ERROR "Enabling EmitC requires IREE_MLIR_DEP_MODE set to BUNDELED or INSTALLED.")
endif()
endif()
#-------------------------------------------------------------------------------
# Target and backend configuration
#-------------------------------------------------------------------------------
# List of all HAL drivers to be built by default:
set(IREE_ALL_HAL_DRIVERS
Cuda
DyLib
VMVX
Vulkan
)
if(IREE_HAL_DRIVERS_TO_BUILD STREQUAL "all")
set(IREE_HAL_DRIVERS_TO_BUILD ${IREE_ALL_HAL_DRIVERS})
# For Apple platforms we need to use Metal instead of Vulkan.
if(APPLE)
list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Vulkan)
endif()
# Remove Cuda from Android and Apple platforms.
if(ANDROID OR APPLE)
list(REMOVE_ITEM IREE_HAL_DRIVERS_TO_BUILD Cuda)
endif()
endif()
message(STATUS "Building HAL drivers: ${IREE_HAL_DRIVERS_TO_BUILD}")
# Default every IREE_HAL_DRIVER_* to OFF
foreach(_backend ${IREE_ALL_HAL_DRIVERS})
string(TOUPPER "${_backend}" uppercase_backend)
set(IREE_HAL_DRIVER_${uppercase_backend} OFF CACHE BOOL "" FORCE)
endforeach()
# Set IREE_HAL_DRIVER_* based on configuration
foreach(_backend ${IREE_HAL_DRIVERS_TO_BUILD})
string(TOUPPER "${_backend}" uppercase_backend)
string(REPLACE "\"" "" uppercase_backend ${uppercase_backend})
set(IREE_HAL_DRIVER_${uppercase_backend} ON CACHE BOOL "" FORCE)
endforeach()
# List of all target backends to be built by default:
set(IREE_ALL_TARGET_BACKENDS
CUDA
DYLIB-LLVM-AOT
WASM-LLVM-AOT
Metal-SPIRV
ROCM
Vulkan-SPIRV
VMVX
)
if(${IREE_BUILD_COMPILER})
if(IREE_TARGET_BACKENDS_TO_BUILD STREQUAL "all")
set(IREE_TARGET_BACKENDS_TO_BUILD ${IREE_ALL_TARGET_BACKENDS})
endif()
message(STATUS "Building target backends: ${IREE_TARGET_BACKENDS_TO_BUILD}")
else()
set(IREE_TARGET_BACKENDS_TO_BUILD "" CACHE STRING "" FORCE)
message(STATUS "Compiler is disabled, building no target backends")
endif()
# Default every IREE_TARGET_BACKEND_* to OFF
foreach(_backend ${IREE_ALL_TARGET_BACKENDS})
string(TOUPPER "${_backend}" uppercase_backend)
set(IREE_TARGET_BACKEND_${uppercase_backend} OFF CACHE BOOL "" FORCE)
endforeach()
# Set IREE_TARGET_BACKEND_* based on configuration
foreach(_backend ${IREE_TARGET_BACKENDS_TO_BUILD})
string(TOUPPER "${_backend}" uppercase_backend)
string(REPLACE "\"" "" uppercase_backend ${uppercase_backend})
set(IREE_TARGET_BACKEND_${uppercase_backend} ON CACHE BOOL "" FORCE)
endforeach()
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/
${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/
)
#-------------------------------------------------------------------------------
# IREE compilation toolchain configuration
#-------------------------------------------------------------------------------
# Enable using lld as the linker for C/C++ targets. This affects IREE and all
# dependency projects.
option(IREE_ENABLE_LLD "Use lld when linking" OFF)
option(IREE_ENABLE_ASAN "Enable address sanitizer" OFF)
option(IREE_ENABLE_MSAN "Enable memory sanitizer" OFF)
option(IREE_ENABLE_TSAN "Enable thread sanitizer" OFF)
option(IREE_ENABLE_CCACHE "Use ccache if installed to speed up rebuilds." OFF)
if(${IREE_ENABLE_CCACHE})
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
endif()
#-------------------------------------------------------------------------------
# IREE assertions
# We don't love the way this is done, but we have to line it up with how LLVM
# does it and not diverge, since all implementations and all header users must
# have the same definition of NDEBUG.
#
# LLVM defaults LLVM_ENABLE_ASSERTIONS to ON for Debug builds only but then
# conditions itself to only update flags if not building Debug. We just let
# IREE_ENABLE_ASSERTIONS be not conditioned on anything and only update the
# flags in appropriate build types.
#
# If IREE_ENABLE_ASSERTIONS is set ON manually, then
# - NDEBUG must be undefined
# - LLVM_ENABLE_ASSERTIONS is forced off in order to keep multiple parties
# from mucking with globals.
#
# Since CMake forces NDEBUG for !Debug builds, some surgery needs to be done
# at the top level to avoid divergence.
#-------------------------------------------------------------------------------
option(IREE_ENABLE_ASSERTIONS "Force unset of NDEBUG compile option" OFF)
# Filter -DNDEBUG from CMAKE_CXX_FLAGS_* and CMAKE_C_FLAGS_* (if
# CMAKE_BUILD_TYPE is not Debug).
function(iree_fix_ndebug)
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if(IREE_ENABLE_ASSERTIONS AND NOT "${uppercase_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
foreach (flags_var_to_scrub
CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}
CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE})
set(original_flags "${${flags_var_to_scrub}}")
string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
altered_flags "${original_flags}")
if(NOT "${original_flags}" STREQUAL "${altered_flags}")
message(STATUS
"IREE_ENABLE_ASSERTIONS force disabled NDEBUG for ${flags_var_to_scrub}: '${original_flags}' -> '${altered_flags}'")
set(${flags_var_to_scrub} "${altered_flags}" PARENT_SCOPE)
endif()
endforeach()
# Make sure that LLVM doesn't add its own logic for assertion disabling.
# We'd like to make sure that we are not dueling over globals.
set(LLVM_ENABLE_ASSERTIONS OFF PARENT_SCOPE)
endif()
endfunction()
iree_fix_ndebug()
#-------------------------------------------------------------------------------
# IREE utility definitions
#-------------------------------------------------------------------------------
include(iree_macros)
include(iree_copts)
include(sanitizers)
include(iree_cc_binary)
include(iree_cc_library)
include(iree_cc_test)
include(iree_tablegen_library)
include(iree_tablegen_doc)
include(iree_c_embed_data)
include(iree_bytecode_module)
include(iree_c_module)
include(iree_python)
include(iree_lit_test)
include(iree_add_all_subdirs)
include(iree_check_test)
include(iree_run_binary_test)
include(iree_mlir_benchmark_suite)
set(DEFAULT_CMAKE_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to ${DEFAULT_CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE "${DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
#-------------------------------------------------------------------------------
# IREE compilation flags
#-------------------------------------------------------------------------------
iree_append_list_to_string(CMAKE_C_FLAGS_DEBUG ${IREE_C_FLAGS_DEBUG_LIST})
iree_append_list_to_string(CMAKE_CXX_FLAGS_DEBUG ${IREE_CXX_FLAGS_DEBUG_LIST})
set(CMAKE_CXX_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C++ compiler during fast builds." FORCE)
set(CMAKE_C_FLAGS_FASTBUILD "-gmlt" CACHE STRING "Flags used by the C compiler during fast builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used for linking binaries during fast builds." FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_FASTBUILD "-Wl,-S" CACHE STRING "Flags used by the shared libraries linker binaries during fast builds." FORCE)
mark_as_advanced(
CMAKE_CXX_FLAGS_FASTBUILD
CMAKE_C_FLAGS_FASTBUILD
CMAKE_EXE_LINKER_FLAGS_FASTBUILD
CMAKE_SHARED_LINKER_FLAGS_FASTBUILD
)
include(iree_setup_toolchain)
#-------------------------------------------------------------------------------
# Configure python early if there are any features that need it.
# Note that doing this early ensures that dependencies that make incidental
# use of Python (such as LLVM) resolve the same version.
#-------------------------------------------------------------------------------
if(${IREE_BUILD_COMPILER} OR
${IREE_BUILD_PYTHON_BINDINGS})
find_package(Python3 COMPONENTS Interpreter REQUIRED)
endif()
#-------------------------------------------------------------------------------
# Check if git submodules have been initialized.
# This will only run if python3 is available.
#-------------------------------------------------------------------------------
find_package(Python3 COMPONENTS Interpreter QUIET)
if(Python3_FOUND)
execute_process(
COMMAND ${Python3_EXECUTABLE} scripts/git/check_submodule_init.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE ret
)
if(NOT ret EQUAL "0")
message(FATAL_ERROR "check_submodule_init.py failed, see the logs above")
endif()
endif()
#-------------------------------------------------------------------------------
# MLIR/LLVM Dependency
# We treat the LLVM dependency specially because we support several different
# ways to use it:
# - Bundled (default): a source dependency directly on the
# third_party/llvm-project submodule.
# - External: An external (source or installed) dependency on LLVM.
# - Provided: When IREE is used as a sub-project, it is assumed that the LLVM
# dependency is added prior to including this configuration.
#-------------------------------------------------------------------------------
# Disable LLVM's warnings.
set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "don't use global flags /facepalm")
# Adds bundled projects that must be included after the LLVM directory has
# been added and within the scope of its settings (i.e. build type override,
# etc).
function(add_bundled_mlir_dependent_projects)
if(${IREE_BUILD_COMPILER})
add_subdirectory(third_party/mlir-hlo EXCLUDE_FROM_ALL)
endif()
endfunction()
function(add_iree_mlir_src_dep llvm_monorepo_path)
# Stash cmake build type in case LLVM messes with it.
set(_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
add_subdirectory("${llvm_monorepo_path}/llvm" "third_party/llvm-project/llvm" EXCLUDE_FROM_ALL)
# Reset CMAKE_BUILD_TYPE to its previous setting.
set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE)
endfunction()
if(${IREE_ENABLE_MLIR})
if(${IREE_MLIR_DEP_MODE} STREQUAL "DISABLED")
message(STATUS "Not adding MLIR/LLVM dep due to IREE_MLIR_DEP_MODE=DISABLED")
elseif(${IREE_MLIR_DEP_MODE} STREQUAL "BUNDLED")
message(STATUS "Adding bundled LLVM source dependency")
add_iree_mlir_src_dep("third_party/llvm-project")
# Extend module path to allow submodules to use LLVM and MLIR CMake modules.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/mlir")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/lib/cmake/llvm/")
# Add the bundled include directories for cmake files looking for them.
list(APPEND LLVM_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include
${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include
)
list(APPEND MLIR_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include
${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include
)
# Avoid globally modifying paths by instead adding the include paths to the
# rules that really should have them in the first place.
target_include_directories(LLVMSupport PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/llvm/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/include>
)
target_include_directories(MLIRSupport PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/llvm-project/mlir/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third_party/llvm-project/llvm/tools/mlir/include>
)
# Set build option to use MHLO alongside with bundled MLIR
set(MHLO_BUILD_EMBEDDED ON)
elseif(${IREE_MLIR_DEP_MODE} STREQUAL "INSTALLED")
# Deps of installed MLIR/LLVM packages.
find_package(ZLIB) # See: https://reviews.llvm.org/D79219
message(STATUS "Looking for installed MLIR/LLVM packages (configure with MLIR_DIR variable)")
find_package(MLIR REQUIRED CONFIG)
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
# Add include/link directories
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
include_directories(SYSTEM ${MLIR_INCLUDE_DIRS})
link_directories(${LLVM_BUILD_LIBRARY_DIR})
add_definitions(${LLVM_DEFINITIONS})
else()
message(FATAL "Unsupported IREE_MLIR_DEP_MODE=${IREE_MLIR_DEP_MODE}")
endif()
add_bundled_mlir_dependent_projects()
endif()
#-------------------------------------------------------------------------------
# Python bindings.
#-------------------------------------------------------------------------------
if(${IREE_BUILD_PYTHON_BINDINGS})
# Note: Optional because python libs can be manually specified.
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
endif()
#-------------------------------------------------------------------------------
# Other dependencies.
#-------------------------------------------------------------------------------
include(external_cc_library)
include(flatbuffer_c_library)
add_subdirectory(build_tools/third_party/cuda EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/libyaml EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/stblib EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
if(${IREE_ENABLE_THREADING})
add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL)
add_subdirectory(third_party/cpuinfo EXCLUDE_FROM_ALL)
endif()
add_subdirectory(third_party/flatcc EXCLUDE_FROM_ALL)
add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL)
# TODO(scotttodd): Iterate some more and find a better place for this.
if (NOT CMAKE_CROSSCOMPILING)
install(TARGETS iree-flatcc-cli
COMPONENT iree-flatcc-cli
RUNTIME DESTINATION bin)
endif()
if(${IREE_BUILD_COMPILER})
add_subdirectory(build_tools/third_party/mlir-hlo EXCLUDE_FROM_ALL)
endif()
if(${IREE_ENABLE_EMITC})
add_subdirectory(build_tools/third_party/mlir-emitc EXCLUDE_FROM_ALL)
endif()
if(${IREE_BUILD_TESTS})
enable_testing(iree)
endif()
if(${IREE_BUILD_PYTHON_BINDINGS})
add_subdirectory(third_party/pybind11 EXCLUDE_FROM_ALL)
endif()
if(${IREE_TARGET_BACKEND_METAL-SPIRV})
# SPIRV-Cross is needed to cross compile SPIR-V into MSL source code.
add_subdirectory(third_party/spirv_cross EXCLUDE_FROM_ALL)
endif()
#-------------------------------------------------------------------------------
# IREE top-level targets
#-------------------------------------------------------------------------------
if(${IREE_BUILD_BENCHMARKS})
# Add a top-level custom target to drive generating benchmark suites.
add_custom_target(iree-benchmark-suites)
endif()
if(${IREE_BUILD_DOCS})
# Add a top-level custom target to drive generating all documentation.
# Register it to the default target given that IREE_BUILD_DOCS is explicitly
# requested.
add_custom_target(iree-doc ALL)
endif()
#-------------------------------------------------------------------------------
# IREE top-level libraries
#-------------------------------------------------------------------------------
add_subdirectory(build_tools/embed_data/)
add_subdirectory(iree/base)
add_subdirectory(iree/hal)
add_subdirectory(iree/modules)
add_subdirectory(iree/runtime)
add_subdirectory(iree/schemas)
add_subdirectory(iree/task)
add_subdirectory(iree/testing)
add_subdirectory(iree/test)
add_subdirectory(iree/vm)
if(${IREE_BUILD_BENCHMARKS})
add_subdirectory(benchmarks)
endif()
if(${IREE_BUILD_EXPERIMENTAL_ROCM})
add_subdirectory(build_tools/third_party/rocm EXCLUDE_FROM_ALL)
add_subdirectory(experimental/rocm)
endif()
if(${IREE_BUILD_COMPILER})
add_subdirectory(iree/compiler)
endif()
add_subdirectory(iree/tools)
# Order constraint: The python bindings install tools targets from iree/tools
# and must come after it.
if(${IREE_BUILD_PYTHON_BINDINGS})
add_subdirectory(bindings/python)
endif()
if(${IREE_BUILD_BINDINGS_TFLITE})
add_subdirectory(bindings/tflite)
endif()
if(${IREE_BUILD_SAMPLES})
add_subdirectory(iree/samples)
endif()
if(${IREE_BUILD_EXPERIMENTAL_REMOTING})
# NOTE: Currently liburing is only used by the experimental remoting
# support, so keeping it scoped here. If this broadens, then include along
# with other dependencies as normal.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message(STATUS "Enabling liburing")
add_subdirectory(build_tools/third_party/liburing EXCLUDE_FROM_ALL)
endif()
add_subdirectory(experimental/remoting)
endif()
if(${IREE_BUILD_EXPERIMENTAL_JAVA_BINDINGS})
add_subdirectory(experimental/bindings/java)
endif()
if(${IREE_ENABLE_TENSORFLOW})
add_subdirectory(integrations/tensorflow)
endif()
set(IREE_PUBLIC_INCLUDE_DIRS "${IREE_COMMON_INCLUDE_DIRS}"
CACHE INTERNAL "IREE: Include Directories" FORCE)