mirror of https://github.com/llvm/torch-mlir
Adapt to use installed MLIR
parent
846178dc09
commit
36717e97e1
|
@ -1,3 +1,39 @@
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
if(POLICY CMP0068)
|
||||||
|
cmake_policy(SET CMP0068 NEW)
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0075)
|
||||||
|
cmake_policy(SET CMP0075 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0077)
|
||||||
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(standalone-dialect LANGUAGES CXX C)
|
||||||
|
|
||||||
|
find_package(MLIR REQUIRED CONFIG)
|
||||||
|
|
||||||
|
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
|
||||||
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_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})
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||||
|
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||||
|
link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
||||||
|
add_definitions(${LLVM_DEFINITIONS})
|
||||||
|
|
||||||
# MLIR npcomp project.
|
# MLIR npcomp project.
|
||||||
set(MLIR_NPCOMP_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # --src-root
|
set(MLIR_NPCOMP_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # --src-root
|
||||||
set(MLIR_NPCOMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # --includedir
|
set(MLIR_NPCOMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # --includedir
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Setup directories.
|
||||||
|
td="$(realpath $(dirname $0)/..)"
|
||||||
|
build_dir="$td/build"
|
||||||
|
install_mlir="$td/install-mlir"
|
||||||
|
|
||||||
|
if ! [ -d "$install_mlir/include/mlir" ]; then
|
||||||
|
echo "MLIR install path does not appear valid: $install_mlir"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p "$build_dir"
|
||||||
|
|
||||||
|
# Make sure we are using python3.
|
||||||
|
python_exe="$(which python3)"
|
||||||
|
echo "Using python: $python_exe"
|
||||||
|
if [ -z "$python_exe" ]; then
|
||||||
|
echo "Could not find python3"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
cmake -GNinja \
|
||||||
|
"-H$td" \
|
||||||
|
"-B$build_dir" \
|
||||||
|
"-DPYTHON_EXECUTABLE=$python_exe" \
|
||||||
|
"-DMLIR_DIR=$install_mlir/lib/cmake/mlir" \
|
||||||
|
"-DLLVM_EXTERNAL_LIT=$build_dir/bin/llvm-lit" \
|
||||||
|
"$@"
|
Loading…
Reference in New Issue