BUILD_SHARED_LIBS is a LLVM's CMake option to build components as shared libraries (.so) instead of static library (.a). It is often used by developers to reduce build (especially linking) time as well as disk size.
This patch makes it possible to use BUILD_SHARED_LIBS=ON while compiling MLIR.
Currently, MLIR itself cannot be compiled as a shared library because of the cyclic dependency among MLIR components.
Hence this patch adds add_mlir_library cmake function, which sets the library type STATIC even BUILD_SHARED_LIBS is ON. Other than thar, add_mlir_library is equivalent with add_llvm_library.
By this, we can get most of the benefits of BUILD_SHARED_LIBS=ON since LLVM components are compiled as shared libraries while only MLIR, which is smaller than the entire LLVM, is still compiled as static libraries.
This patch should not affect if BUILD_SHARED_LIBS is set to OFF (default).