Clang] Fix expansion of response files in -Wp after integrated-cc1 change
[llvm-project.git] / mlir / CMakeLists.txt
blob9c463effa7c533cecbd2a662c569181ea10d0a8f
1 # MLIR project.
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)
22   add_custom_command(
23           OUTPUT ${GEN_DOC_FILE}
24           COMMAND ${CMAKE_COMMAND} -E copy
25                   ${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md
26                   ${GEN_DOC_FILE}
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)
30 endfunction()
32 include(AddMLIR)
34 # Installing the headers and docs needs to depend on generating any public
35 # tablegen'd targets.
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
41 # is available
42 if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
43   set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
44 else()
45   set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
46 endif()
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)
54 add_subdirectory(lib)
55 add_subdirectory(tools)
56 add_subdirectory(unittests)
57 add_subdirectory(test)
59 if( LLVM_INCLUDE_EXAMPLES )
60   add_subdirectory(examples)
61 endif()
63 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
64   install(DIRECTORY include/mlir include/mlir-c
65     DESTINATION include
66     COMPONENT mlir-headers
67     FILES_MATCHING
68     PATTERN "*.def"
69     PATTERN "*.h"
70     PATTERN "*.inc"
71     PATTERN "*.td"
72     PATTERN "LICENSE.TXT"
73     )
75   install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
76     DESTINATION include
77     COMPONENT mlir-headers
78     FILES_MATCHING
79     PATTERN "*.def"
80     PATTERN "*.h"
81     PATTERN "*.gen"
82     PATTERN "*.inc"
83     PATTERN "*.td"
84     PATTERN "CMakeFiles" EXCLUDE
85     PATTERN "config.h" EXCLUDE
86     )
88   if (NOT LLVM_ENABLE_IDE)
89     add_llvm_install_targets(install-mlir-headers
90                              DEPENDS mlir-headers
91                              COMPONENT mlir-headers)
92   endif()
93 endif()
95 add_subdirectory(cmake/modules)