66 lines
1.7 KiB
CMake
66 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(hello_mlir)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
find_package(MLIR REQUIRED CONFIG)
|
|
find_package(LLVM REQUIRED CONFIG)
|
|
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
|
|
|
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
|
|
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
|
|
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
|
|
|
include(TableGen)
|
|
include(AddLLVM)
|
|
include(AddMLIR)
|
|
include(HandleLLVMOptions)
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
include_directories(${MLIR_INCLUDE_DIRS})
|
|
link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
|
add_definitions(${LLVM_DEFINITIONS})
|
|
|
|
include_directories(include)
|
|
# Add include directory in cmake output directory for lint.
|
|
include_directories(${CMAKE_BINARY_DIR}/include)
|
|
add_subdirectory(include)
|
|
|
|
set(LLVM_TARGET_DEFINITIONS lib/HelloCombine.td)
|
|
mlir_tablegen(HelloCombine.inc -gen-rewriters)
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
add_public_tablegen_target(HelloCombineIncGen)
|
|
|
|
add_library(SyntaxNode STATIC
|
|
lib/SyntaxNode.cpp
|
|
lib/Dialect.cpp
|
|
lib/MLIRGen.cpp
|
|
lib/HelloCombine.cpp
|
|
include/SyntaxNode.h
|
|
include/Parser.h
|
|
include/Lexer.h
|
|
)
|
|
|
|
add_dependencies(SyntaxNode HelloOpsIncGen HelloCombineIncGen)
|
|
|
|
target_link_libraries(SyntaxNode
|
|
PRIVATE
|
|
MLIRSupport
|
|
MLIRAnalysis
|
|
MLIRFunctionInterfaces
|
|
MLIRIR
|
|
MLIRParser
|
|
MLIRSideEffectInterfaces
|
|
MLIRTransforms)
|
|
|
|
add_executable(hello-mlir main.cpp)
|
|
|
|
target_link_libraries(hello-mlir
|
|
PRIVATE
|
|
SyntaxNode
|
|
LLVMSupport
|
|
LLVMCore) |