2323# grouping. Source groupings form a DAG.
2424# SOURCES: List of specific source files relative to ROOT_DIR to include.
2525# SOURCES_GLOB: List of glob patterns relative to ROOT_DIR to include.
26+ # EMBED_CAPI_LINK_LIBS: Dependent CAPI libraries that this extension depends
27+ # on. These will be collected for all extensions and put into an
28+ # aggregate dylib that is linked against.
2629function (declare_mlir_python_sources name )
2730 cmake_parse_arguments (ARG
2831 ""
2932 "ROOT_DIR;ADD_TO_PARENT"
30- "SOURCES;SOURCES_GLOB"
33+ "SOURCES;SOURCES_GLOB;EMBED_CAPI_LINK_LIBS "
3134 ${ARGN} )
3235
3336 if (NOT ARG_ROOT_DIR)
@@ -53,9 +56,10 @@ function(declare_mlir_python_sources name)
5356 set_target_properties (${name} PROPERTIES
5457 # Yes: Leading-lowercase property names are load bearing and the recommended
5558 # way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261
56- EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_DEPENDS"
59+ EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_DEPENDS;mlir_python_EMBED_CAPI_LINK_LIBS "
5760 mlir_python_SOURCES_TYPE pure
5861 mlir_python_DEPENDS ""
62+ mlir_python_EMBED_CAPI_LINK_LIBS "${ARG_EMBED_CAPI_LINK_LIBS} "
5963 )
6064
6165 # Use the interface include directories and sources on the target to carry the
@@ -374,6 +378,9 @@ endfunction()
374378# This file is where the *EnumAttrs are defined, not where the *Enums are defined.
375379# **WARNING**: This arg will shortly be removed when the just-below TODO is satisfied. Use at your
376380# risk.
381+ # EMBED_CAPI_LINK_LIBS: Dependent CAPI libraries that this extension depends
382+ # on. These will be collected for all extensions and put into an
383+ # aggregate dylib that is linked against.
377384#
378385# TODO: Right now `TD_FILE` can't be the actual dialect tablegen file, since we
379386# use its path to determine where to place the generated python file. If
@@ -383,7 +390,7 @@ function(declare_mlir_dialect_python_bindings)
383390 cmake_parse_arguments (ARG
384391 "GEN_ENUM_BINDINGS"
385392 "ROOT_DIR;ADD_TO_PARENT;TD_FILE;DIALECT_NAME"
386- "SOURCES;SOURCES_GLOB;DEPENDS;GEN_ENUM_BINDINGS_TD_FILE"
393+ "SOURCES;SOURCES_GLOB;DEPENDS;GEN_ENUM_BINDINGS_TD_FILE;EMBED_CAPI_LINK_LIBS "
387394 ${ARGN} )
388395 # Sources.
389396 set (_dialect_target "${ARG_ADD_TO_PARENT} .${ARG_DIALECT_NAME} " )
@@ -424,6 +431,7 @@ function(declare_mlir_dialect_python_bindings)
424431 ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR} "
425432 ADD_TO_PARENT "${_dialect_target} "
426433 SOURCES ${_sources}
434+ EMBED_CAPI_LINK_LIBS "${ARG_EMBED_CAPI_LINK_LIBS} "
427435 )
428436 endif ()
429437endfunction ()
0 commit comments