Adding IREE_EXTERNAL_HAL_DRIVERS cmake var.
This allows for out-of-tree drivers by specifying the static library
target and registration function, ala LLVM_EXTERNAL_PROJECTS.

To test this the ROCM driver has been moved to an external driver and can
be enabled with -DIREE_EXTERNAL_HAL_DRIVERS=rocm during cmake config.

With some bazel work we'd be able to make the internal drivers work this
way too and remove a lot of boilerplate. For now the existing options are
preserved.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff038f8..6999c61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,7 +70,6 @@
 
 option(IREE_BUILD_EXPERIMENTAL_REMOTING "Builds experimental remoting support." OFF)
 option(IREE_BUILD_EXPERIMENTAL_WEB_SAMPLES "Builds experimental web samples." OFF)
-option(IREE_HAL_DRIVER_EXPERIMENTAL_ROCM "Builds the experimental ROCm Backend." OFF)
 
 #-------------------------------------------------------------------------------
 # Derived flags based on primary options
@@ -85,6 +84,10 @@
 #   -DIREE_HAL_DRIVER_DEFAULTS=OFF
 #-------------------------------------------------------------------------------
 
+# External HAL drivers; see runtime/src/iree/hal/drivers/CMakeLists.txt for more
+# information on how to declare external drivers.
+set(IREE_EXTERNAL_HAL_DRIVERS "" CACHE STRING "")
+
 option(IREE_HAL_DRIVER_DEFAULTS "Sets the default value for all runtime HAL drivers" ON)
 # CUDA support must be explicitly enabled.
 set(IREE_HAL_DRIVER_CUDA_DEFAULT OFF)
@@ -144,6 +147,9 @@
 if(IREE_HAL_DRIVER_VULKAN)
   message(STATUS "  - vulkan")
 endif()
+if(IREE_EXTERNAL_HAL_DRIVERS)
+  message(STATUS "  + external: ${IREE_EXTERNAL_HAL_DRIVERS}")
+endif()
 
 message(STATUS "IREE HAL local executable library loaders:")
 if(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF)
@@ -157,6 +163,15 @@
 endif()
 
 #-------------------------------------------------------------------------------
+# Experimental ROCM HAL driver
+#-------------------------------------------------------------------------------
+
+set(IREE_EXTERNAL_ROCM_HAL_DRIVER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/experimental/rocm")
+set(IREE_EXTERNAL_ROCM_HAL_DRIVER_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/experimental/rocm")
+set(IREE_EXTERNAL_ROCM_HAL_DRIVER_TARGET "iree::experimental::rocm::registration")
+set(IREE_EXTERNAL_ROCM_HAL_DRIVER_REGISTER "iree_hal_rocm_driver_module_register")
+
+#-------------------------------------------------------------------------------
 # Compiler Target Options
 # By default, all compiler targets supported by the current platform which do
 # not require external deps are enabled by default. This can be changed with:
@@ -669,11 +684,6 @@
   add_subdirectory(benchmarks)
 endif()
 
-if(IREE_HAL_DRIVER_EXPERIMENTAL_ROCM)
-  add_subdirectory(build_tools/third_party/rocm EXCLUDE_FROM_ALL)
-  add_subdirectory(experimental/rocm)
-endif()
-
 if(IREE_BUILD_COMPILER)
   add_subdirectory(compiler)
 endif()