diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -90,6 +90,12 @@ 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 --- a/mlir/cmake/modules/AddMLIR.cmake +++ b/mlir/cmake/modules/AddMLIR.cmake @@ -189,7 +189,7 @@ # 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 @@ # 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 --- a/mlir/cmake/modules/MLIRConfig.cmake.in +++ b/mlir/cmake/modules/MLIRConfig.cmake.in @@ -9,6 +9,7 @@ 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@")