Build functioning dev packages for IREECompiler and IREERuntime. (#16008)

With this patch, external projects can do:

```
find_package(IREECompiler)
find_package(IREERuntime)
```

and access our targets by adding either the build or install tree
`lib/cmake/IREE` to the CMake package search path.

There are still some ergonomic issues that need to be addressed going
forward:

* cpuinfo breaks the one downstream I am testing this against. We really
should just finish killing that, so I am setting
-DIREE_ENABLE_CPUINFO=OFF in the dist package.
* We are not yet re-establishing the pretty `iree::runtime:...` aliases.
The underscore versions are available (`iree_runtime_...`).
* I want to further isolate the remaining bundled deps (yaml and
flatcc).
* New convenience install targets do not have full dependency
information. Need to do an `all` build first.

As part of this, I did some longstanding cleanups:

* Normalized the install component namespace. Defined
`IREECMakeExports`, `IREEDevLibraries-Compiler`,
`IREEDevLibraries-Runtime`, `IREERuntimeLibraries-Compiler`,
`IREEBundledLibraries`, `IREETools-Runtime`.
* Added convenience `iree-install-*` targets. Each includes a
`-stripped` variant as well.
* Moved MLIRInterop.h to the bindings/c directory where it should have
been all along and straightened the deps.
* Install the mlir-c headers to support libIREECompiler.so dev.
* Added the "busybox" tool binaries to the install distribution
(iree-lld, etc).
* Stopped bundling upstream `lld` and `clang` by default because they
bloat the size. `lld` is now bundled as `iree-lld` just like in the
Python packages. Clang and llvm-link can be gotten by installing the new
`IREETools-CompilerExtra` component if folks need those.

Note that this only installs public headers and libraries needed to
build against the compiler and runtime. Installing private things needed
to develop parts of the system are out of scope.
diff --git a/build_tools/cmake/CMakeLists.txt b/build_tools/cmake/CMakeLists.txt
new file mode 100644
index 0000000..33c3f76
--- /dev/null
+++ b/build_tools/cmake/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright 2023 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+set(_cmake_installdir "${CMAKE_INSTALL_LIBDIR}/cmake/IREE")
+
+if(IREE_BUILD_COMPILER)
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/IREECompilerConfig.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/IREECompilerConfig.cmake
+    @ONLY
+  )
+  install(FILES
+    ${CMAKE_CURRENT_BINARY_DIR}/IREECompilerConfig.cmake
+    DESTINATION ${_cmake_installdir}
+    COMPONENT IREECMakeExports
+  )  
+endif()
+
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/IREERuntimeConfig.cmake.in
+  ${CMAKE_CURRENT_BINARY_DIR}/IREERuntimeConfig.cmake
+  @ONLY
+)
+install(FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/IREERuntimeConfig.cmake
+  DESTINATION ${_cmake_installdir}
+  COMPONENT IREECMakeExports
+)
diff --git a/build_tools/cmake/IREECompilerConfig.cmake.in b/build_tools/cmake/IREECompilerConfig.cmake.in
new file mode 100644
index 0000000..595e4d1
--- /dev/null
+++ b/build_tools/cmake/IREECompilerConfig.cmake.in
@@ -0,0 +1,6 @@
+# This allows users to call find_package(IREECompiler) and access our targets.
+
+include("${CMAKE_CURRENT_LIST_DIR}/IREETargets-Compiler.cmake")
+
+# TODO: Define some properties to reference all libraries and config options.
+# TODO: Iterate over all exported libraries and re-alias them.
diff --git a/build_tools/cmake/IREERuntimeConfig.cmake.in b/build_tools/cmake/IREERuntimeConfig.cmake.in
new file mode 100644
index 0000000..caaf30a
--- /dev/null
+++ b/build_tools/cmake/IREERuntimeConfig.cmake.in
@@ -0,0 +1,6 @@
+# This allows users to call find_package(IREERuntime) and access our targets.
+
+include("${CMAKE_CURRENT_LIST_DIR}/IREETargets-Runtime.cmake")
+
+# TODO: Define some properties to reference all libraries and config options.
+# TODO: Iterate over all exported libraries and re-alias them.
diff --git a/build_tools/cmake/external_cc_library.cmake b/build_tools/cmake/external_cc_library.cmake
index c74695b..fa9cc06 100644
--- a/build_tools/cmake/external_cc_library.cmake
+++ b/build_tools/cmake/external_cc_library.cmake
@@ -169,13 +169,17 @@
     )
   endif()
 
-  add_library(${_RULE_PACKAGE}::${_RULE_NAME} ALIAS ${_NAME})
+  iree_install_targets(
+    TARGETS ${_NAME}
+    HDRS ${_RULE_HDRS}
+  )    
+
+  iree_add_alias_library(${_RULE_PACKAGE}::${_RULE_NAME} ${_NAME})
   # If the library name matches the final component of the package then treat it
   # as a default. For example, 'foo::bar' library 'bar' would end up as
   # 'foo::bar'.
   string(REGEX REPLACE "^.*::" "" _PACKAGE_DIR ${_RULE_PACKAGE})
   if(${_PACKAGE_DIR} STREQUAL ${_RULE_NAME})
-
-    add_library(${_RULE_PACKAGE} ALIAS ${_NAME})
+    iree_add_alias_library(${_RULE_PACKAGE} ${_NAME})
   endif()
 endfunction()
diff --git a/build_tools/cmake/flatbuffer_c_library.cmake b/build_tools/cmake/flatbuffer_c_library.cmake
index 6e54d6f..0f87a89 100644
--- a/build_tools/cmake/flatbuffer_c_library.cmake
+++ b/build_tools/cmake/flatbuffer_c_library.cmake
@@ -116,7 +116,7 @@
   add_dependencies(${_NAME} ${_GEN_TARGET})
   target_include_directories(${_NAME} SYSTEM
     INTERFACE
-      ${CMAKE_CURRENT_BINARY_DIR}
+      $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
     )
   target_link_libraries(${_NAME}
     INTERFACE
@@ -127,10 +127,13 @@
       "-I${IREE_ROOT_DIR}/third_party/flatcc/include/"
       "-I${IREE_ROOT_DIR}/third_party/flatcc/include/flatcc/reflection/"
   )
-
+  iree_install_targets(
+    TARGETS ${_NAME}
+  )
+  
   # Alias the iree_package_name library to iree::package::name.
   # This lets us more clearly map to Bazel and makes it possible to
   # disambiguate the underscores in paths vs. the separators.
   iree_package_ns(_PACKAGE_NS)
-  add_library(${_PACKAGE_NS}::${_RULE_NAME} ALIAS ${_NAME})
+  iree_add_alias_library(${_PACKAGE_NS}::${_RULE_NAME} ${_NAME})
 endfunction()
diff --git a/build_tools/cmake/iree_cc_binary.cmake b/build_tools/cmake/iree_cc_binary.cmake
index ef4ddb2..2e8af2f 100644
--- a/build_tools/cmake/iree_cc_binary.cmake
+++ b/build_tools/cmake/iree_cc_binary.cmake
@@ -27,7 +27,7 @@
 # HOSTONLY: host only; compile using host toolchain when cross-compiling
 # SETUP_INSTALL_RPATH: Sets an install RPATH which assumes the standard
 #   directory layout (to be used if linking against installed shared libs).
-#
+# INSTALL_COMPONENT: CMake install component (Defaults to "IREETool-${_RULE_NAME}").
 # Note:
 # iree_cc_binary will create a binary called ${PACKAGE_NAME}_${NAME}, e.g.
 # iree_base_foo with an alias to ${PACKAGE_NS}::${NAME}.
@@ -55,7 +55,7 @@
   cmake_parse_arguments(
     _RULE
     "EXCLUDE_FROM_ALL;HOSTONLY;TESTONLY;SETUP_INSTALL_RPATH;DISABLE_LLVM_LINK_LLVM_DYLIB"
-    "NAME"
+    "NAME;INSTALL_COMPONENT"
     "SRCS;COPTS;DEFINES;LINKOPTS;DATA;DEPS"
     ${ARGN}
   )
@@ -155,18 +155,23 @@
   set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${IREE_CXX_STANDARD})
   set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
 
+  set(_INSTALL_COMPONENT "${_RULE_INSTALL_COMPONENT}")
+  if(NOT _INSTALL_COMPONENT)
+    set(_INSTALL_COMPONENT "IREETool-${_RULE_NAME}")
+  endif()
+
   if(_RULE_EXCLUDE_FROM_ALL)
     set_property(TARGET ${_NAME} PROPERTY EXCLUDE_FROM_ALL ON)
     install(TARGETS ${_NAME}
             RENAME ${_RULE_NAME}
-            COMPONENT ${_RULE_NAME}
+            COMPONENT ${_INSTALL_COMPONENT}
             RUNTIME DESTINATION bin
             BUNDLE DESTINATION bin
             EXCLUDE_FROM_ALL)
   else()
     install(TARGETS ${_NAME}
       RENAME ${_RULE_NAME}
-      COMPONENT ${_RULE_NAME}
+      COMPONENT ${_INSTALL_COMPONENT}
       RUNTIME DESTINATION bin
       BUNDLE DESTINATION bin)
   endif()
diff --git a/build_tools/cmake/iree_cc_library.cmake b/build_tools/cmake/iree_cc_library.cmake
index a3b06ac..38a6c1a 100644
--- a/build_tools/cmake/iree_cc_library.cmake
+++ b/build_tools/cmake/iree_cc_library.cmake
@@ -292,13 +292,20 @@
     )
   endif()
 
+  if(NOT _RULE_TESTONLY)
+    iree_install_targets(
+      TARGETS ${_NAME}
+      HDRS ${_RULE_HDRS} ${_RULE_TEXTUAL_HDRS}
+    )
+  endif()
+
   # Alias the iree_package_name library to iree::package::name.
   # This lets us more clearly map to Bazel and makes it possible to
   # disambiguate the underscores in paths vs. the separators.
   if(_DEBUG_IREE_PACKAGE_NAME)
     message(STATUS "  + alias ${_PACKAGE_NS}::${_RULE_NAME}")
   endif()
-  add_library(${_PACKAGE_NS}::${_RULE_NAME} ALIAS ${_NAME})
+  iree_add_alias_library(${_PACKAGE_NS}::${_RULE_NAME} ${_NAME})
 
   if(NOT "${_PACKAGE_NS}" STREQUAL "")
     # If the library name matches the final component of the package then treat
@@ -306,7 +313,7 @@
     # 'foo::bar'.
     iree_package_dir(_PACKAGE_DIR)
     if("${_RULE_NAME}" STREQUAL "${_PACKAGE_DIR}")
-      add_library(${_PACKAGE_NS} ALIAS ${_NAME})
+      iree_add_alias_library(${_PACKAGE_NS} ${_NAME})
     endif()
   endif()
 endfunction()
@@ -428,17 +435,21 @@
       $<TARGET_PROPERTY:${_RULE_ROOT},INTERFACE_LINK_LIBRARIES>
   )
 
+  iree_install_targets(
+    TARGETS ${_NAME}
+  )
+
   # Alias the iree_package_name library to iree::package::name.
   # This lets us more clearly map to Bazel and makes it possible to
   # disambiguate the underscores in paths vs. the separators.
-  add_library(${_PACKAGE_NS}::${_RULE_NAME} ALIAS ${_NAME})
+  iree_add_alias_library(${_PACKAGE_NS}::${_RULE_NAME} ${_NAME})
 
   # If the library name matches the final component of the package then treat
   # it as a default. For example, foo/bar/ library 'bar' would end up as
   # 'foo::bar'.
   iree_package_dir(_PACKAGE_DIR)
   if(${_RULE_NAME} STREQUAL ${_PACKAGE_DIR})
-    add_library(${_PACKAGE_NS} ALIAS ${_NAME})
+    iree_add_alias_library(${_PACKAGE_NS} ${_NAME})
   endif()
 endfunction()
 
diff --git a/build_tools/cmake/iree_install_support.cmake b/build_tools/cmake/iree_install_support.cmake
new file mode 100644
index 0000000..7ea2140
--- /dev/null
+++ b/build_tools/cmake/iree_install_support.cmake
@@ -0,0 +1,201 @@
+# Copyright 2023 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+function(iree_add_alias_library to_target from_target)
+  add_library(${to_target} ALIAS ${from_target})
+  # Yes: Leading-lowercase property names are load bearing and the recommended
+  # way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261
+  # We have to export the aliases on the target, and the when we generate
+  # IREEConfig.cmake, generate code to re-establish the alias on import.
+  # Yeah, this is completely sane.
+  set_property(TARGET ${from_target} APPEND PROPERTY iree_ALIAS_TO ${to_target})
+endfunction()
+
+function(iree_install_targets)
+  cmake_parse_arguments(
+    _RULE
+    "FIX_INCLUDE_DIRS"
+    "COMPONENT;EXPORT_SET"
+    "HDRS;TARGETS"
+    ${ARGN}
+  )
+
+  # Determine install component. It can be explicit on the target or implicit
+  # from the CMake variable IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT 
+  # (usually set at the directory level). Note that truthy evaluation is 
+  # intended: Installation can be suppressed by setting "COMPONENT OFF".
+  set(_INSTALL_COMPONENT "${_RULE_COMPONENT}")
+  if(NOT _INSTALL_COMPONENT AND IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT)
+    set(_INSTALL_COMPONENT "${IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT}")
+  endif()
+  if(NOT _INSTALL_COMPONENT)
+    return()
+  endif()
+
+  # Ditto for export set name.
+  set(_EXPORT_SET "${_RULE_EXPORT_SET}")
+  if(NOT _EXPORT_SET AND IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET)
+    set(_EXPORT_SET "${IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET}")
+  endif()
+  if(NOT _EXPORT_SET)
+    message(SEND_ERROR "Installing ${_RULE_TARGETS}: An install COMPONENT was set but EXPORT_SET was not")
+  endif()
+
+  # Process targets.
+  set_property(TARGET ${_RULE_TARGETS} APPEND PROPERTY EXPORT_PROPERTIES iree_ALIAS_TO)
+  foreach(_target ${_RULE_TARGETS})
+    if(_RULE_FIX_INCLUDE_DIRS)
+      get_target_property(_include_dirs ${_target} INTERFACE_INCLUDE_DIRECTORIES)
+      list(TRANSFORM _include_dirs PREPEND "$<BUILD_INTERFACE:")
+      list(TRANSFORM _include_dirs APPEND ">")
+      set_target_properties(${_target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_include_dirs}")
+    endif()
+  endforeach()
+
+  # Add it to the global property that will be processed at the end of the build.
+  set_property(GLOBAL APPEND PROPERTY "IREE_EXPORT_TARGETS_${_EXPORT_SET}" ${_RULE_TARGETS})
+
+  # The export name is set at a directory level to control export.
+  install(
+    TARGETS ${_RULE_TARGETS}
+    EXPORT IREEExported-${_EXPORT_SET}
+    COMPONENT "${_INSTALL_COMPONENT}"
+    EXCLUDE_FROM_ALL
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+  )
+
+  # Install headers if the rule declares them and the directory level
+  # root path is truthy.
+  if(_RULE_HDRS AND IREE_HDRS_ROOT_PATH)
+    foreach(_hdr_file ${_RULE_HDRS})
+      set(_hdr_abs_path "${CMAKE_CURRENT_SOURCE_DIR}/${_hdr_file}")
+      if(NOT EXISTS "${_hdr_abs_path}")
+        # Assume it is generated in the binary dir.
+        set(_hdr_abs_path "${CMAKE_CURRENT_BINARY_DIR}/${_hdr_file}")
+      endif()
+      set(_hdr_base_relative "${CMAKE_CURRENT_SOURCE_DIR}/${_hdr_file}")
+      cmake_path(
+        RELATIVE_PATH _hdr_base_relative
+        BASE_DIRECTORY "${IREE_HDRS_ROOT_PATH}")
+      cmake_path(
+        GET _hdr_base_relative
+        PARENT_PATH _rel_path
+      )
+      install(
+        FILES "${_hdr_abs_path}"
+        DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_rel_path}"
+        COMPONENT "${_INSTALL_COMPONENT}"
+        EXCLUDE_FROM_ALL
+      )
+    endforeach()
+  endif()
+endfunction()
+
+# Generates build and install tree export CMake files for a given named
+# export set.
+# This will export any targets added to iree_install_targets above with the
+# same export set name (either explicit or at the directory level).
+# 
+# This function must be called at a location after which all targets that are
+# part of the export set have been added (typically at the top-level).
+# Exports will not be generated if no targets were added for that export set
+# name.
+#
+# If a COMPONENT is specified, the exports will be installed with that 
+# component. Defaults to IREECMakeExports.
+function(iree_generate_export_targets)
+  cmake_parse_arguments(
+    _RULE
+    ""
+    "COMPONENT;EXPORT_SET"
+    ""
+    ${ARGN}
+  )
+
+  if(NOT _RULE_EXPORT_SET)
+    message(FATAL_ERROR "EXPORT_SET is required")
+    return()
+  endif()
+
+  get_property(_export_targets GLOBAL PROPERTY "IREE_EXPORT_TARGETS_${_RULE_EXPORT_SET}")
+  if(NOT _export_targets)
+    message(STATUS "Skipping generation of export set ${_RULE_EXPORT_SET} (no targets matched)")
+  endif()
+
+  set(_component "${_RULE_COMPONENT}")
+  if(NOT _component)
+    set(_component "IREECMakeExports")
+  endif()
+
+  export(TARGETS ${_export_targets}
+    FILE "${IREE_BINARY_DIR}/lib/cmake/IREE/IREETargets-${_RULE_EXPORT_SET}.cmake")
+
+  install(
+    EXPORT "IREEExported-${_RULE_EXPORT_SET}"
+    COMPONENT "${_component}"
+    FILE "IREETargets-${_RULE_EXPORT_SET}.cmake"
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IREE"
+  )
+
+  # Clear the export targets so that innocent aggregating projects don't
+  # get in trouble if they use our setup.
+  set_property(GLOBAL PROPERTY "IREE_EXPORT_TARGETS_${_RULE_EXPORT_SET}")
+endfunction()
+
+# Adds a convenience install target for a component.
+function(iree_add_install_target)
+  cmake_parse_arguments(
+    _RULE
+    ""
+    "NAME;COMPONENT"
+    "DEPENDS;ADD_TO"
+    ${ARGN}
+  )
+  set(_depends ${_RULE_DEPENDS})
+
+  if(NOT _RULE_COMPONENT)
+    # Just create stub targets.
+    add_custom_target(${_RULE_NAME})
+    add_custom_target(${_RULE_NAME}-stripped)
+  else()
+    # Create targets to install a component.
+    set(_options -DCMAKE_INSTALL_COMPONENT="${_RULE_COMPONENT}")
+
+    # Non-stripped.
+    add_custom_target(
+      ${_RULE_NAME}
+      COMMAND "${CMAKE_COMMAND}"
+              ${_options}
+              -P "${IREE_BINARY_DIR}/cmake_install.cmake"
+      USES_TERMINAL)
+    set_target_properties(${_RULE_NAME} PROPERTIES FOLDER "Component Install Targets")
+
+    # Stripped.
+    add_custom_target(
+      ${_RULE_NAME}-stripped
+      COMMAND "${CMAKE_COMMAND}"
+              ${_options}
+              -DCMAKE_INSTALL_DO_STRIP=1
+              -P "${IREE_BINARY_DIR}/cmake_install.cmake"
+      USES_TERMINAL)
+    set_target_properties(${_RULE_NAME} PROPERTIES FOLDER "Component Install Targets")
+  endif()
+
+  if(_depends)
+    add_dependencies(${_RULE_NAME} ${_depends})
+    add_dependencies(${_RULE_NAME}-stripped ${_depends})
+  endif()
+
+  if(_RULE_ADD_TO)
+    foreach(_add_to ${_RULE_ADD_TO})
+      add_dependencies(${_add_to} ${_RULE_NAME})
+      add_dependencies(${_add_to}-stripped ${_RULE_NAME}-stripped)
+    endforeach()
+  endif()
+endfunction()
\ No newline at end of file
diff --git a/build_tools/cmake/iree_macros.cmake b/build_tools/cmake/iree_macros.cmake
index fa97034..96a88c3 100644
--- a/build_tools/cmake/iree_macros.cmake
+++ b/build_tools/cmake/iree_macros.cmake
@@ -455,6 +455,10 @@
         ${_DUMMY_LIB_NAME}
     )
 
+    iree_install_targets(
+      TARGETS ${_DUMMY_LIB_NAME}
+    )
+
     # Link the js-library to the target.
     # When a linked library starts with a "-" cmake will just add it to the
     # linker command line as it is. The advantage of doing it this way is
diff --git a/build_tools/cmake/iree_tablegen_library.cmake b/build_tools/cmake/iree_tablegen_library.cmake
index 129fe7a..d7ea0b6 100644
--- a/build_tools/cmake/iree_tablegen_library.cmake
+++ b/build_tools/cmake/iree_tablegen_library.cmake
@@ -71,5 +71,5 @@
 
   # Alias the iree_package_name library to iree::package::name.
   iree_package_ns(_PACKAGE_NS)
-  add_library(${_PACKAGE_NS}::${_RULE_NAME} ALIAS ${_NAME})
+  iree_add_alias_library(${_PACKAGE_NS}::${_RULE_NAME} ${_NAME})
 endfunction()
diff --git a/build_tools/github_actions/build_dist.py b/build_tools/github_actions/build_dist.py
index be49b60..e2db481 100644
--- a/build_tools/github_actions/build_dist.py
+++ b/build_tools/github_actions/build_dist.py
@@ -76,7 +76,6 @@
 )
 CI_REQUIREMENTS_TXT = os.path.join(THIS_DIR, "ci_requirements.txt")
 CONFIGURE_BAZEL_PY = os.path.join(IREESRC_DIR, "configure_bazel.py")
-INSTALL_TARGET = "install" if platform.system() == "Windows" else "install/strip"
 
 
 # Load version info.
@@ -147,6 +146,9 @@
             f"-DIREE_BUILD_COMPILER=ON",
             f"-DIREE_BUILD_PYTHON_BINDINGS=OFF",
             f"-DIREE_BUILD_SAMPLES=OFF",
+            # cpuinfo is set to be removed and is problematic from an
+            # installed/bundled library perspective.
+            f"-DIREE_ENABLE_CPUINFO=OFF",
         ],
         check=True,
     )
@@ -159,7 +161,22 @@
             "--build",
             BUILD_DIR,
             "--target",
-            INSTALL_TARGET,
+            "all",
+        ],
+        check=True,
+    )
+
+    # TODO: Get proper dependency management on install targets so we don't
+    # have to build all first.
+    subprocess.run(
+        [
+            sys.executable,
+            CMAKE_CI_SCRIPT,
+            "--build",
+            BUILD_DIR,
+            "--target",
+            "iree-install-dev-libraries-stripped",
+            "iree-install-tools-stripped",
         ],
         check=True,
     )
@@ -168,6 +185,7 @@
     dist_entries = [
         "bin",
         "lib",
+        "include",
     ]
     dist_archive = os.path.join(
         BINDIST_DIR,
diff --git a/build_tools/third_party/cuda/CMakeLists.txt b/build_tools/third_party/cuda/CMakeLists.txt
index cfcbbf3..4e8a701 100644
--- a/build_tools/third_party/cuda/CMakeLists.txt
+++ b/build_tools/third_party/cuda/CMakeLists.txt
@@ -108,6 +108,13 @@
 # Targets that IREE depends on which encapsulate access to CUDA.
 ################################################################################
 
+# We don't install any headers because their only use is in built code
+# (not public).
+set(IREE_HDRS_ROOT_PATH OFF)
+# Considered part of the runtime. See runtime/src/CMakeLists.txt.
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT IREEDevLibraries)
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET Runtime)
+
 iree_c_embed_data(
   PACKAGE
     iree_cuda
@@ -121,16 +128,21 @@
     "iree_cuda/libdevice_embedded.h"
   INCLUDES
     # Allows an include like "iree_cuda/libdevice_embedded.h"
-    "${CMAKE_CURRENT_BINARY_DIR}"
+    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
   FLATTEN
   PUBLIC
 )
 
+# Make include dirs only for the BUILD_INTERFACE
+set(_include_dirs ${CUDAToolkit_INCLUDE_DIRS})
+list(TRANSFORM _include_dirs PREPEND "$<BUILD_INTERFACE:")
+list(TRANSFORM _include_dirs APPEND ">")
+
 iree_cc_library(
   PACKAGE
     iree_cuda
   NAME
     headers
   INCLUDES
-    ${CUDAToolkit_INCLUDE_DIRS}
+    ${_include_dirs}
 )
diff --git a/build_tools/third_party/flatcc/CMakeLists.txt b/build_tools/third_party/flatcc/CMakeLists.txt
index df4e902..87f4923 100644
--- a/build_tools/third_party/flatcc/CMakeLists.txt
+++ b/build_tools/third_party/flatcc/CMakeLists.txt
@@ -6,6 +6,13 @@
 
 set(FLATCC_ROOT "${IREE_ROOT_DIR}/third_party/flatcc/")
 
+# We don't install any headers because their only use is in built code
+# (not public).
+set(IREE_HDRS_ROOT_PATH OFF)
+# Considered part of the runtime. See runtime/src/CMakeLists.txt.
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT IREEBundledLibraries)
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET Runtime)
+
 external_cc_library(
   PACKAGE
     flatcc
diff --git a/build_tools/third_party/libyaml/CMakeLists.txt b/build_tools/third_party/libyaml/CMakeLists.txt
index 93eda90..223fc3c 100644
--- a/build_tools/third_party/libyaml/CMakeLists.txt
+++ b/build_tools/third_party/libyaml/CMakeLists.txt
@@ -6,6 +6,13 @@
 
 set(LIBYAML_ROOT "${IREE_ROOT_DIR}/third_party/libyaml/")
 
+# We don't install any headers because their only use is in built code
+# (not public).
+set(IREE_HDRS_ROOT_PATH OFF)
+# Considered part of the runtime. See runtime/src/CMakeLists.txt.
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT IREEBundledLibraries)
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET Runtime)
+
 external_cc_library(
   PACKAGE
     yaml
diff --git a/build_tools/third_party/nccl/CMakeLists.txt b/build_tools/third_party/nccl/CMakeLists.txt
index 0634276..1fc1693 100644
--- a/build_tools/third_party/nccl/CMakeLists.txt
+++ b/build_tools/third_party/nccl/CMakeLists.txt
@@ -4,6 +4,13 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
+# We don't install any headers because their only use is in built code
+# (not public).
+set(IREE_HDRS_ROOT_PATH OFF)
+# Considered part of the runtime. See runtime/src/CMakeLists.txt.
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT IREEDevLibraries)
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET Runtime)
+
 set(NCCL_SOURCE_DIR
   "${IREE_SOURCE_DIR}/third_party/nccl/"
 )
diff --git a/build_tools/third_party/tracy_client/CMakeLists.txt b/build_tools/third_party/tracy_client/CMakeLists.txt
index 4f86d09..c123f9e 100644
--- a/build_tools/third_party/tracy_client/CMakeLists.txt
+++ b/build_tools/third_party/tracy_client/CMakeLists.txt
@@ -4,6 +4,13 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
+# Traced builds require the headers.
+set(IREE_HDRS_ROOT_PATH "${IREE_ROOT_DIR}/third_party/tracy/public")
+
+# Considered part of the runtime. See runtime/src/CMakeLists.txt.
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_COMPONENT IREEBundledLibraries)
+set(IREE_INSTALL_LIBRARY_TARGETS_DEFAULT_EXPORT_SET "Runtime")
+
 external_cc_library(
   PACKAGE
     tracy_client