forked from iree-org/iree-llvm-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (88 loc) · 4.23 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
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR
"This project is intended to be built as part of LLVM via "
"-DLLVM_EXTERNAL_PROJECTS=iree_llvm_sandbox "
"-DLLVM_EXTERNAL_IREE_LLVM_SANDBOX_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
endif()
set(IREE_LLVM_SANDBOX_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "iree_llvm_sandbox build directory: ${IREE_LLVM_SANDBOX_BINARY_DIR}")
################################################################################
# Compile in IREE dialects.
################################################################################
set(LLVM_EXTERNAL_IREE_DIALECTS_SOURCE_DIR "" CACHE PATH "Path to iree-dialects project")
set(SANDBOX_ENABLE_IREE_DIALECTS OFF)
if(LLVM_EXTERNAL_IREE_DIALECTS_SOURCE_DIR)
message(STATUS "Enabling iree-dialects in sandbox")
set(SANDBOX_ENABLE_IREE_DIALECTS ON)
add_compile_definitions("SANDBOX_ENABLE_IREE_DIALECTS")
else()
# Disable this IREE-defined function when not using IREE.
function(iree_dialects_target_includes target)
endfunction()
endif()
################################################################################
# Set some variables
################################################################################
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir)
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include)
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
if (SANDBOX_ENABLE_ALP)
# ALP includes
add_compile_definitions("SANDBOX_ENABLE_ALP")
include_directories(experimental/alp/include)
include_directories(${CMAKE_BINARY_DIR}/tools/sandbox/experimental/alp/include)
endif()
if (SANDBOX_ENABLE_ITERATORS)
# Iterators includes
add_compile_definitions("SANDBOX_ENABLE_ITERATORS")
include_directories(experimental/iterators/include)
include_directories(${CMAKE_BINARY_DIR}/tools/sandbox/experimental/iterators/include)
endif()
list(APPEND CMAKE_MODULE_PATH ${MLIR_MAIN_SRC_DIR}/cmake/modules)
list(APPEND CMAKE_MODULE_PATH ${LLVM_MAIN_SRC_DIR}/cmake)
set(MLIR_TABLEGEN_EXE mlir-tblgen)
################################################################################
# Set include paths
################################################################################
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(include)
include_directories(${IREE_LLVM_SANDBOX_BINARY_DIR}/include)
if (SANDBOX_ENABLE_IREE_DIALECTS)
# TODO: For finding iree-dialects-c. Should not be necessary.
include_directories(SYSTEM ${LLVM_EXTERNAL_IREE_DIALECTS_SOURCE_DIR}/include)
# Our local files reference a local copy of iree-dialects.
# To work with the actual iree-dialects, drop the need for prefixing.
include_directories(SYSTEM ${LLVM_EXTERNAL_IREE_DIALECTS_SOURCE_DIR}/include/iree-dialects)
# This is the place where Tablegen puts stuff from iree-dialects.
# TODO: find the right env var and avoid the relative path.
include_directories(SYSTEM ${IREE_LLVM_SANDBOX_BINARY_DIR}/../iree-dialects/include/iree-dialects)
endif()
################################################################################
# Enable python (assumes enabled MLIR bindings via MLIR_ENABLE_BINDINGS_PYTHON)
################################################################################
if(NOT DEFINED MLIR_ENABLE_BINDINGS_PYTHON)
message(FATAL_ERROR
"This project requires MLIR_ENABLE_BINDINGS_PYTHON=ON")
endif()
include(MLIRDetectPythonEnv)
mlir_configure_python_dev_packages()
################################################################################
# Enable LLVM stuff
################################################################################
include(TableGen)
include(AddLLVM)
include(AddMLIR)
################################################################################
# Subdirs to recurse into
################################################################################
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(python)
add_subdirectory(test)
add_subdirectory(tools)
add_subdirectory(experimental)