1include(AddMLIRPython) 2 3# Specifies that all MLIR packages are co-located under the `mlir_standalone` 4# top level package (the API has been embedded in a relocatable way). 5# TODO: Add an upstream cmake param for this vs having a global here. 6add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=mlir_standalone.") 7 8 9################################################################################ 10# Sources 11################################################################################ 12 13declare_mlir_python_sources(StandalonePythonSources) 14 15declare_mlir_dialect_python_bindings( 16 ADD_TO_PARENT StandalonePythonSources 17 ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir_standalone" 18 TD_FILE dialects/StandaloneOps.td 19 SOURCES 20 dialects/standalone.py 21 DIALECT_NAME standalone) 22 23declare_mlir_python_extension(StandalonePythonSources.Extension 24 MODULE_NAME _standaloneDialects 25 ADD_TO_PARENT StandalonePythonSources 26 SOURCES 27 StandaloneExtension.cpp 28 EMBED_CAPI_LINK_LIBS 29 StandaloneCAPI 30) 31 32################################################################################ 33# Common CAPI 34################################################################################ 35 36add_mlir_python_common_capi_library(StandalonePythonCAPI 37 INSTALL_COMPONENT StandalonePythonModules 38 INSTALL_DESTINATION python_packages/standalone/mlir_standalone/_mlir_libs 39 OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone/_mlir_libs" 40 RELATIVE_INSTALL_ROOT "../../../.." 41 DECLARED_SOURCES 42 StandalonePythonSources 43 MLIRPythonSources.Core 44) 45 46################################################################################ 47# Instantiation of all Python modules 48################################################################################ 49 50add_mlir_python_modules(StandalonePythonModules 51 ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone" 52 INSTALL_PREFIX "python_packages/standalone/mlir_standalone" 53 DECLARED_SOURCES 54 StandalonePythonSources 55 MLIRPythonSources 56 COMMON_CAPI_LINK_LIBS 57 StandalonePythonCAPI 58 ) 59