Separate install target for MLIR?

Yesterday, I noticed that there is not a target for install-mlir, and it seems to roll up to the global install target via the LLVM_INSTALL_TOOLS option.

Does anyone more familiar with the build have a pointer on how to get an explicit install-mlir target or equiv? When iterating, installing all tools takes minutes and many GB of disk thrash (with debug symbols).

For reference, here is my build/install script: https://github.com/google/mlir-npcomp/blob/master/tools/install_mlir.sh

Does add_llvm_install_targets do what you want? When clang added it

Kind of, but after messing with it for a half hour, I need to back out.

  • install-mlir-headers works as expected
  • I feel like there should be an install-mlir-libraries and the bits below got that going.
  • There is no add_mlir_tool so tools are just rolling up to the LLVM install target via add_llvm_tool
  • I gave up when trying to convince lib/Tablegen to install in a way my proejct could find it (there is a disclaimer in the CMakeLists.txt for that explaining why it is unusual, but I don’t quite track it.)

I added this blurb to AddMLIR.cmake:

      if (NOT LLVM_ENABLE_IDE)
        add_llvm_install_targets(install-${name}
                                 DEPENDS ${name}
                                 COMPONENT ${name})
        set_property(GLOBAL APPEND PROPERTY MLIR_ALL_INSTALL_TARGETS 
                     install-${name})
      endif()

And then this to the mlir/CMakeLists.txt:

    get_property(MLIR_ALL_INSTALL_TARGETS GLOBAL PROPERTY MLIR_ALL_INSTALL_TARGETS)
    message(STATUS ":::MLIR LIBS ${MLIR_ALL_INSTALL_TARGETS}")
    add_llvm_install_targets(install-mlir-libraries
      DEPENDS ${MLIR_ALL_INSTALL_TARGETS}
      COMPONENT install-mlir-libraries)

That got me an install-mlir-libraries target that worked. However, there were enough other missing pieces that my project still wouldn’t build. I’m setting this aside and just taking the install time hit for now. I learn a little more about CMake on every incursion, but still not enough to really untangle this.