New projects (particularly out of tree) have a tendency to hijack the existing
llvm configuration options and build targets (add_llvm_library,
add_llvm_tool). This can lead to some confusion.
- When querying a configuration variable, do we care about how LLVM was
configured, or how these options were configured for the out of tree project?
- LLVM has lots of defaults, which are easy to miss
(e.g. LLVM_BUILD_TOOLS=ON). These options all need to be duplicated in the
CMakeLists.txt for the project.
In addition, with LLVM Incubators coming online, we need better ways for these
incubators to do things the "LLVM way" without alot of futzing. Ideally, this
would happen in a way that eases importing into the LLVM monorepo when
projects mature.
This patch creates some generic infrastructure in llvm/cmake/modules and
refactors MLIR to use this infrastructure. This should expand to include
add_xxx_library, which is by far the most complicated bit of building a
project correctly, since it has to deal with lots of shared library
configuration bits. (MLIR currently hijacks the LLVM infrastructure for
building libMLIR.so, so this needs to get refactored anyway.)
Are there any of these that we can remove from LLVM, so we don't have to duplicate them for other projects? It seems to be that we could drop all the INCLUDE_* options. I'm guessing they exist, so that things like examples are buildable, but aren't added to the all target? To me it seems better to automatically add everything to all, and users that want to build less then all can just specify the targets that they want to build. Having both BUILD_* and INCLUDE_* options is very confusing.