2 set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ) # --src-root
3 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include ) # --includedir
4 set(MLIR_TABLEGEN_EXE mlir-tblgen)
6 set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7 set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
9 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
11 function(add_mlir_dialect dialect dialect_doc_filename)
12 set(LLVM_TARGET_DEFINITIONS ${dialect}.td)
13 mlir_tablegen(${dialect}.h.inc -gen-op-decls)
14 mlir_tablegen(${dialect}.cpp.inc -gen-op-defs)
15 add_public_tablegen_target(MLIR${dialect}IncGen)
16 add_dependencies(mlir-headers MLIR${dialect}IncGen)
18 # Generate Dialect Documentation
19 set(LLVM_TARGET_DEFINITIONS ${dialect_doc_filename}.td)
20 tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
21 set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/Dialects/${dialect_doc_filename}.md)
23 OUTPUT ${GEN_DOC_FILE}
24 COMMAND ${CMAKE_COMMAND} -E copy
25 ${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md
27 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md)
28 add_custom_target(${dialect_doc_filename}DocGen DEPENDS ${GEN_DOC_FILE})
29 add_dependencies(mlir-doc ${dialect_doc_filename}DocGen)
34 # Installing the headers and docs needs to depend on generating any public
36 add_custom_target(mlir-headers)
37 set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
38 add_custom_target(mlir-doc)
40 # Build the CUDA conversions and run according tests if the NVPTX backend
42 if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
43 set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
45 set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
48 set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
50 include_directories( "include")
51 include_directories( ${MLIR_INCLUDE_DIR})
53 add_subdirectory(include/mlir)
55 add_subdirectory(tools)
56 add_subdirectory(unittests)
57 add_subdirectory(test)
59 if( LLVM_INCLUDE_EXAMPLES )
60 add_subdirectory(examples)
63 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
64 install(DIRECTORY include/mlir include/mlir-c
66 COMPONENT mlir-headers
75 install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
77 COMPONENT mlir-headers
84 PATTERN "CMakeFiles" EXCLUDE
85 PATTERN "config.h" EXCLUDE
88 if (NOT LLVM_ENABLE_IDE)
89 add_llvm_install_targets(install-mlir-headers
91 COMPONENT mlir-headers)
95 add_subdirectory(cmake/modules)