2019-03-30 13:10:12 +08:00
|
|
|
# MLIR project.
|
2020-04-12 14:29:07 +08:00
|
|
|
set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
|
|
|
|
set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )
|
2019-03-30 13:10:12 +08:00
|
|
|
|
2020-04-12 14:29:07 +08:00
|
|
|
set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
|
2019-03-30 13:10:12 +08:00
|
|
|
|
2020-01-22 08:44:17 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
2019-03-30 13:10:12 +08:00
|
|
|
|
2020-01-22 08:44:17 +08:00
|
|
|
include(AddMLIR)
|
|
|
|
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 08:32:41 +08:00
|
|
|
# Installing the headers and docs needs to depend on generating any public
|
|
|
|
# tablegen'd targets.
|
2020-04-25 07:42:07 +08:00
|
|
|
# mlir-generic-headers are dialect-independent.
|
|
|
|
add_custom_target(mlir-generic-headers)
|
|
|
|
set_target_properties(mlir-generic-headers PROPERTIES FOLDER "Misc")
|
|
|
|
# mlir-headers may be dialect-dependent.
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 08:32:41 +08:00
|
|
|
add_custom_target(mlir-headers)
|
|
|
|
set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
|
2020-04-25 07:42:07 +08:00
|
|
|
add_dependencies(mlir-headers mlir-generic-headers)
|
2019-12-03 01:17:51 +08:00
|
|
|
add_custom_target(mlir-doc)
|
|
|
|
|
2019-06-26 20:16:11 +08:00
|
|
|
# Build the CUDA conversions and run according tests if the NVPTX backend
|
|
|
|
# is available
|
|
|
|
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
|
|
|
|
else()
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
|
|
|
|
endif()
|
2020-02-14 17:12:41 +08:00
|
|
|
# TODO: we should use a config.h file like LLVM does
|
|
|
|
add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED})
|
2019-06-26 20:16:11 +08:00
|
|
|
|
2019-07-04 22:49:52 +08:00
|
|
|
set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
|
2020-02-19 22:11:22 +08:00
|
|
|
set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
|
2019-07-04 22:49:52 +08:00
|
|
|
|
2020-05-19 00:44:26 +08:00
|
|
|
option(MLIR_INCLUDE_TESTS
|
|
|
|
"Generate build targets for the MLIR unit tests."
|
|
|
|
${LLVM_INCLUDE_TESTS})
|
|
|
|
|
2019-03-30 13:10:12 +08:00
|
|
|
include_directories( "include")
|
|
|
|
include_directories( ${MLIR_INCLUDE_DIR})
|
|
|
|
|
2020-03-15 02:41:12 +08:00
|
|
|
# Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
|
|
|
|
# MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
|
|
|
|
# from another directory like tools
|
|
|
|
add_subdirectory(tools/mlir-tblgen)
|
|
|
|
|
2019-03-30 13:10:12 +08:00
|
|
|
add_subdirectory(include/mlir)
|
|
|
|
add_subdirectory(lib)
|
2020-05-19 00:44:26 +08:00
|
|
|
if (MLIR_INCLUDE_TESTS)
|
|
|
|
add_definitions(-DMLIR_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2020-02-09 11:27:54 +08:00
|
|
|
# Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
|
|
|
|
# Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
|
|
|
|
add_subdirectory(tools)
|
2019-04-03 01:02:07 +08:00
|
|
|
|
|
|
|
if( LLVM_INCLUDE_EXAMPLES )
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2019-11-20 13:04:45 +08:00
|
|
|
|
2020-01-26 01:17:31 +08:00
|
|
|
option(MLIR_INCLUDE_DOCS "Generate build targets for the MLIR docs."
|
|
|
|
${LLVM_INCLUDE_DOCS})
|
|
|
|
if (MLIR_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
|
|
|
|
2019-11-20 13:04:45 +08:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
|
|
install(DIRECTORY include/mlir include/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
2020-01-06 17:01:59 +08:00
|
|
|
PATTERN "*.def"
|
2019-11-20 13:04:45 +08:00
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.inc"
|
2019-12-30 01:04:09 +08:00
|
|
|
PATTERN "*.td"
|
2019-11-20 13:04:45 +08:00
|
|
|
PATTERN "LICENSE.TXT"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
2020-01-22 08:44:17 +08:00
|
|
|
PATTERN "*.def"
|
2019-11-20 13:04:45 +08:00
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.gen"
|
|
|
|
PATTERN "*.inc"
|
2020-01-22 08:44:17 +08:00
|
|
|
PATTERN "*.td"
|
2019-11-20 13:04:45 +08:00
|
|
|
PATTERN "CMakeFiles" EXCLUDE
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-mlir-headers
|
|
|
|
DEPENDS mlir-headers
|
|
|
|
COMPONENT mlir-headers)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-01-22 08:44:17 +08:00
|
|
|
|
|
|
|
add_subdirectory(cmake/modules)
|