Unify compiler and runtime HAL driver plugin systems. (#15551)
Functional changes:
* CMake variable -DIREE_COMPILER_PLUGIN_PATHS is now generically
-DIREE_CMAKE_PLUGIN_PATHS.
* Super-project variable IREE_COMPILER_BUILTIN_PLUGIN_PATHS is similarly
renamed.
* Plugin directories can contain an iree_compiler_plugin.cmake (changed
from iree_compiler_plugin_group.cmake) file and/or
iree_runtime_plugin.cmake file.
* External HAL drivers are not configured with loose CMake variables
anymore (since they do not span scopes correctly): they use GLOBAL
properties of the same name.
* We recommend using the iree_register_external_hal_driver() function to
setup HAL driver registration vs setting loose properties. In-tree
drivers are switched to this.
This was tested on a private branch of the iree-amd-aie repo, which will
require some post-submit adjustment.
diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt
index 4ac14b3..01adabd 100644
--- a/compiler/CMakeLists.txt
+++ b/compiler/CMakeLists.txt
@@ -27,11 +27,27 @@
# The compiler implementation is gated on the global setting.
if(IREE_BUILD_COMPILER)
+ # Force enable BUILD_SHARED_LIBS for the compiler if instructed.
+ set(_IREE_ORIG_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+ if(IREE_COMPILER_BUILD_SHARED_LIBS)
+ set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
+ endif()
+
# Must configure plugins before processing the compiler sources so that
# the static link list can be set.
- iree_compiler_configure_plugins()
+ iree_include_cmake_plugin_dirs(
+ LOG_LABEL
+ compiler
+ BINARY_DIR
+ "${IREE_BINARY_DIR}/compiler/plugins"
+ PLUGIN_CMAKE_FILE
+ "iree_compiler_plugin.cmake"
+ )
add_subdirectory(src)
+ # Reset BUILD_SHARED_LIBS.
+ set(BUILD_SHARED_LIBS ${_IREE_ORIG_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
+
# Copy Python packaging files to the build dir so that we can install from
# there.
if(IREE_BUILD_PYTHON_BINDINGS)