[Mlir-commits] [mlir] a897590 - Add MLIR_INSTALL_AGGREGATE_OBJECTS and default it to ON.

Stella Laurenzo llvmlistbot at llvm.org
Tue Oct 19 16:14:18 PDT 2021


Author: Stella Laurenzo
Date: 2021-10-19T16:14:04-07:00
New Revision: a897590f11b6cb2bacf6cd317a5f96b1d39ed2f2

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

LOG: Add MLIR_INSTALL_AGGREGATE_OBJECTS and default it to ON.

* Package maintainers can opt to disable installation of these objects.
* Per discussion on https://reviews.llvm.org/D111504

Differential Revision: https://reviews.llvm.org/D112090

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/cmake/modules/AddMLIR.cmake
    mlir/cmake/modules/MLIRConfig.cmake.in

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 8c131f27b2a81..1a2583873c131 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -90,6 +90,12 @@ option(MLIR_INCLUDE_TESTS
 option(MLIR_INCLUDE_INTEGRATION_TESTS
        "Generate build targets for the MLIR integration tests.")
 
+set(MLIR_INSTALL_AGGREGATE_OBJECTS 1 CACHE BOOL
+    "Installs object files needed for add_mlir_aggregate to work out of \
+    tree. Package maintainers can disable this to exclude these assets if \
+    not desired. Enabling this will result in object files being written \
+    under lib/objects-{CMAKE_BUILD_TYPE}.")
+
 #-------------------------------------------------------------------------------
 # Python Bindings Configuration
 # Requires:

diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 8441e4c3474de..6f8c1c65ffa31 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -189,7 +189,7 @@ function(add_mlir_library name)
 
     # In order for out-of-tree projects to build aggregates of this library,
     # we need to install the OBJECT library.
-    if(NOT ARG_DISABLE_INSTALL)
+    if(MLIR_INSTALL_AGGREGATE_OBJECTS AND NOT ARG_DISABLE_INSTALL)
       add_mlir_library_install(obj.${name})
     endif()
   endif()
@@ -279,6 +279,10 @@ function(add_mlir_aggregate name)
       # It is an imported target, which can only have flat strings populated
       # (no generator expressions).
       # Rebuild the generator expressions from the imported flat string lists.
+      if(NOT MLIR_INSTALL_AGGREGATE_OBJECTS)
+        message(SEND_ERROR "Cannot build aggregate from imported targets which were not installed via MLIR_INSTALL_AGGREGATE_OBJECTS (for ${lib}).")
+      endif()
+
       get_property(_has_object_lib_prop TARGET ${lib} PROPERTY MLIR_AGGREGATE_OBJECT_LIB_IMPORTED SET)
       get_property(_has_dep_libs_prop TARGET ${lib} PROPERTY MLIR_AGGREGATE_DEP_LIBS_IMPORTED SET)
       if(NOT _has_object_lib_prop OR NOT _has_dep_libs_prop)

diff  --git a/mlir/cmake/modules/MLIRConfig.cmake.in b/mlir/cmake/modules/MLIRConfig.cmake.in
index 2a71629567514..93ca16230c85b 100644
--- a/mlir/cmake/modules/MLIRConfig.cmake.in
+++ b/mlir/cmake/modules/MLIRConfig.cmake.in
@@ -9,6 +9,7 @@ set(MLIR_EXPORTED_TARGETS "@MLIR_EXPORTS@")
 set(MLIR_CMAKE_DIR "@MLIR_CONFIG_CMAKE_DIR@")
 set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
 set(MLIR_TABLEGEN_EXE "@MLIR_TABLEGEN_EXE@")
+set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
 
 # For mlir_tablegen()
 set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")


        


More information about the Mlir-commits mailing list