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 # TODO: Remove this in favor of showing fine grained registration once 44 # available. 45 MLIRPythonExtension.RegisterEverything 46 MLIRPythonSources.Core 47) 48 49################################################################################ 50# Instantiation of all Python modules 51################################################################################ 52 53add_mlir_python_modules(StandalonePythonModules 54 ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone" 55 INSTALL_PREFIX "python_packages/standalone/mlir_standalone" 56 DECLARED_SOURCES 57 StandalonePythonSources 58 # TODO: Remove this in favor of showing fine grained registration once 59 # available. 60 MLIRPythonExtension.RegisterEverything 61 MLIRPythonSources 62 COMMON_CAPI_LINK_LIBS 63 StandalonePythonCAPI 64 ) 65