150
|
1 # MLIR project.
|
173
|
2 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
|
|
3 set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )
|
150
|
4
|
173
|
5 set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
6 set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
7 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
|
150
|
8
|
|
9 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|
10
|
|
11 include(AddMLIR)
|
|
12
|
|
13 # Installing the headers and docs needs to depend on generating any public
|
|
14 # tablegen'd targets.
|
173
|
15 # mlir-generic-headers are dialect-independent.
|
|
16 add_custom_target(mlir-generic-headers)
|
|
17 set_target_properties(mlir-generic-headers PROPERTIES FOLDER "Misc")
|
|
18 # mlir-headers may be dialect-dependent.
|
150
|
19 add_custom_target(mlir-headers)
|
|
20 set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
|
173
|
21 add_dependencies(mlir-headers mlir-generic-headers)
|
150
|
22 add_custom_target(mlir-doc)
|
|
23
|
|
24 # Build the CUDA conversions and run according tests if the NVPTX backend
|
|
25 # is available
|
|
26 if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
27 set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
|
|
28 else()
|
|
29 set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
|
|
30 endif()
|
173
|
31 # TODO: we should use a config.h file like LLVM does
|
|
32 add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED})
|
150
|
33
|
|
34 set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
|
173
|
35 set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
|
|
36
|
|
37 option(MLIR_INCLUDE_TESTS
|
|
38 "Generate build targets for the MLIR unit tests."
|
|
39 ${LLVM_INCLUDE_TESTS})
|
150
|
40
|
|
41 include_directories( "include")
|
|
42 include_directories( ${MLIR_INCLUDE_DIR})
|
|
43
|
173
|
44 # Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
|
|
45 # MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
|
|
46 # from another directory like tools
|
|
47 add_subdirectory(tools/mlir-tblgen)
|
|
48
|
150
|
49 add_subdirectory(include/mlir)
|
|
50 add_subdirectory(lib)
|
173
|
51 if (MLIR_INCLUDE_TESTS)
|
|
52 add_definitions(-DMLIR_INCLUDE_TESTS)
|
|
53 add_subdirectory(unittests)
|
|
54 add_subdirectory(test)
|
|
55 endif()
|
|
56 # Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
|
|
57 # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
|
150
|
58 add_subdirectory(tools)
|
|
59
|
|
60 if( LLVM_INCLUDE_EXAMPLES )
|
|
61 add_subdirectory(examples)
|
|
62 endif()
|
|
63
|
|
64 option(MLIR_INCLUDE_DOCS "Generate build targets for the MLIR docs."
|
|
65 ${LLVM_INCLUDE_DOCS})
|
|
66 if (MLIR_INCLUDE_DOCS)
|
|
67 add_subdirectory(docs)
|
|
68 endif()
|
|
69
|
|
70 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
71 install(DIRECTORY include/mlir include/mlir-c
|
|
72 DESTINATION include
|
|
73 COMPONENT mlir-headers
|
|
74 FILES_MATCHING
|
|
75 PATTERN "*.def"
|
|
76 PATTERN "*.h"
|
|
77 PATTERN "*.inc"
|
|
78 PATTERN "*.td"
|
|
79 PATTERN "LICENSE.TXT"
|
|
80 )
|
|
81
|
|
82 install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
|
|
83 DESTINATION include
|
|
84 COMPONENT mlir-headers
|
|
85 FILES_MATCHING
|
|
86 PATTERN "*.def"
|
|
87 PATTERN "*.h"
|
|
88 PATTERN "*.gen"
|
|
89 PATTERN "*.inc"
|
|
90 PATTERN "*.td"
|
|
91 PATTERN "CMakeFiles" EXCLUDE
|
|
92 PATTERN "config.h" EXCLUDE
|
|
93 )
|
|
94
|
|
95 if (NOT LLVM_ENABLE_IDE)
|
|
96 add_llvm_install_targets(install-mlir-headers
|
|
97 DEPENDS mlir-headers
|
|
98 COMPONENT mlir-headers)
|
|
99 endif()
|
|
100 endif()
|
|
101
|
|
102 add_subdirectory(cmake/modules)
|