[Mlir-commits] [mlir] 93f7e52 - [MLIR] Update documentation of cmake best practices

Stephen Neuendorffer llvmlistbot at llvm.org
Mon May 4 20:48:39 PDT 2020


Author: Stephen Neuendorffer
Date: 2020-05-04T20:47:58-07:00
New Revision: 93f7e525f519b75bd1bd9430b600169c40b6078a

URL: https://github.com/llvm/llvm-project/commit/93f7e525f519b75bd1bd9430b600169c40b6078a
DIFF: https://github.com/llvm/llvm-project/commit/93f7e525f519b75bd1bd9430b600169c40b6078a.diff

LOG: [MLIR] Update documentation of cmake best practices

Added: 
    

Modified: 
    mlir/docs/Tutorials/CreatingADialect.md

Removed: 
    


################################################################################
diff  --git a/mlir/docs/Tutorials/CreatingADialect.md b/mlir/docs/Tutorials/CreatingADialect.md
index bcf34fc11e55..9f9eb7a8317b 100644
--- a/mlir/docs/Tutorials/CreatingADialect.md
+++ b/mlir/docs/Tutorials/CreatingADialect.md
@@ -72,12 +72,14 @@ add_mlir_dialect_library(FooOps
 	DEPENDS
 	MLIRFooOpsIncGen
 	MLIRFooTransformsIncGen
-	)
-target_link_libraries(FooOps
-	PUBLIC
+
+	LINK_COMPONENTS
+	Core
+
+	LINK_LIBS PUBLIC
 	BarOps
 	<some-other-library>
-	)
+   )
 
 ```
 
@@ -99,8 +101,15 @@ corresponding IncGen targets.  The PUBLIC link dependency is
 sufficient.  Also note that we avoid using add_dependencies
 explicitly, since the dependencies need to be available to the
 underlying add_llvm_library() call, allowing it to correctly create
-new targets with the same sources.
+new targets with the same sources.  However, dialects that depend on
+LLVM IR may need to depend on the LLVM 'intrinsics_gen' target to
+ensure that tablegen'd LLVM header files have been generated.
 
+In addition, linkage to MLIR libraries is specified using the
+LINK_LIBS descriptor and linkage to LLVM libraries is specified using
+the LINK_COMPONENTS descriptor.  This allows cmake infrastructure to
+generate new library targets with correct linkage, in particular, when
+BUILD_SHARED_LIBS=on or LLVM_LINK_LLVM_DYLIB=on are specified.
 
 
 # Dialect Conversions
@@ -136,9 +145,8 @@ add_mlir_conversion_library(MLIRBarToFoo
 
         ADDITIONAL_HEADER_DIRS
         ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/BarToFoo
-	)
-target_link_libraries(MLIRBarToFoo
-	PUBLIC
+
+   LINK_LIBS PUBLIC
 	BarOps
 	FooOps
 	)
@@ -157,3 +165,10 @@ MLIR_CONVERSION_LIBS global property:
 get_property(dialect_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
 
 ```
+
+Note that it is only necessary to specify a PUBLIC dependence against
+dialects to generate compile-time and link-time dependencies, and it
+is not necessary to explicitly depend on the dialects' IncGen targets.
+However, conversions that directly include LLVM IR header files may
+need to depend on the LLVM 'intrinsics_gen' target to ensure that
+tablegen'd LLVM header files have been generated.


        


More information about the Mlir-commits mailing list