mlir/mlir-cmake-standalone.patch
serge-sans-paille 46f2fcd13b Initial version
2020-09-02 07:05:41 +00:00

57 lines
1.8 KiB
Diff

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 806eb42db..5fa0c16dc 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -1,4 +1,50 @@
-# MLIR project.
+# Check if this is a in tree build.
+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
+ project(Mlir)
+ cmake_minimum_required(VERSION 3.13.4)
+
+ # Where is LLVM installed?
+ find_package(LLVM CONFIG REQUIRED)
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
+ include(HandleLLVMOptions)
+ include(AddLLVM)
+ include(TableGen)
+
+ # Add the llvm header path.
+ include_directories(${LLVM_INCLUDE_DIRS})
+ # Local builddir generated header inclusion
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I.")
+
+ # Sources available, too?
+ if (LLVM_BUILD_MAIN_SRC_DIR)
+ set(LLVM_SOURCE_ROOT ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH
+ "Path to LLVM source tree")
+ else()
+ execute_process(COMMAND "${LLVM_TOOLS_BINARY_DIR}/llvm-config" --src-root
+ OUTPUT_VARIABLE MAIN_SRC_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(LLVM_SOURCE_ROOT ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+ endif()
+
+ # Make sure the isl c files are built as fPIC
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+
+ # Set directory for mlir test.
+ set(MLIR_TOOLS_DIR "${CMAKE_CURRENT_BINARY_DIR}/bin")
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+ if (LLVM_ENABLE_DOXYGEN)
+ message(STATUS "Doxygen enabled.")
+ find_package(Doxygen REQUIRED)
+ else()
+ message(STATUS "Doxygen disabled.")
+ endif()
+
+else ()
+ set(LLVM_SOURCE_ROOT "${LLVM_MAIN_SRC_DIR}")
+endif ()
+
set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )