1 cmake_minimum_required(VERSION 3.20.0)
2 project(standalone-dialect LANGUAGES CXX C)
4 set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
6 set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
8 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9 find_package(MLIR REQUIRED CONFIG)
11 message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
12 message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
14 set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
15 set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
16 set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
18 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
19 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
24 include(HandleLLVMOptions)
26 # Build via external projects mechanism
27 set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir)
28 set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include)
29 set(MLIR_GENERATED_INCLUDE_DIR ${LLVM_BINARY_DIR}/tools/mlir/include)
30 set(MLIR_INCLUDE_DIRS "${MLIR_INCLUDE_DIR};${MLIR_GENERATED_INCLUDE_DIR}")
33 if(MLIR_ENABLE_BINDINGS_PYTHON)
34 include(MLIRDetectPythonEnv)
35 mlir_configure_python_dev_packages()
38 set(STANDALONE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
39 set(STANDALONE_BINARY_DIR ${PROJECT_BINARY_DIR})
40 include_directories(${LLVM_INCLUDE_DIRS})
41 include_directories(${MLIR_INCLUDE_DIRS})
42 include_directories(${STANDALONE_SOURCE_DIR}/include)
43 include_directories(${STANDALONE_BINARY_DIR}/include)
44 link_directories(${LLVM_BUILD_LIBRARY_DIR})
45 add_definitions(${LLVM_DEFINITIONS})
47 add_subdirectory(include)
49 if(MLIR_ENABLE_BINDINGS_PYTHON)
50 message(STATUS "Enabling Python API")
51 add_subdirectory(python)
53 add_subdirectory(test)
54 add_subdirectory(standalone-opt)
55 add_subdirectory(standalone-plugin)
56 add_subdirectory(standalone-translate)