-
all-targets
: used by libs to depend on all possible targets. used in llvm-config to get a list of all target descs, infos, codegens, etc. during enumeration. the equivalent in cmakelists is:AllTargetsAsmPrinters AllTargetsAsmParsers AllTargetsDescs AllTargetsDisassemblers AllTargetsInfos
which requires expansion by llvm_map_components_to_libnames.
-
llvm_map_components_to_libnames expects:
- all targets to already exist in
- all possible libs in:
- LLVM_AVAILABLE_LIBS, or
- LLVM_LIBS
-
LLVM_LIBS updated by add_llvm_library, which takes the LLVMxxx library name form.
-
LLVM_AVAILABLE_LIBS set by LLVMConfig.cmake, generated by llvmbuild.
-
LLVMConfig.cmake generated by
cmake/modules/CMakeLists.txt
, which is called whencmake/modules
is add_subdirectory-ed last (even after tools and unittests). included by runtimes -
currently, llvmbuild traverses all dirs to build a list of cmake targets comprising of all libs and targets. then it generates the llvm-config .inc and a cmake fragment containing each lib's deps. these deps are read by llvm_add_library: everytime a library of
$name
is added, llvm_add_library will checkLLVMBUILD_LIB_DEPS_${name}
. -
add_subdirectory
behavior:The CMakeLists.txt file in the specified source directory will be processed immediately by CMake before processing in the current input file continues beyond this command
for targets, this means that either it hasn't been scanned or all of it (LLVM${t}) and its components (LLVM${t}Desc/AsmParser/CodeGen/...) are present as targets.
-
options:
- emulate llvmbuild: pre-scan all dirs to build up deps,
- add_subdirectories as normal with a final check that all INTERFACE_LINK_LIBRARIES of each element of LLVM_LIBS are also in LLVM_LIBS, i.e., LLVM_LIBS closed under deps
-
using INTERFACE_LINK_LIBRARIES to enumerate deps might not work if ARG_STATIC is disabled.
-
need a way to check that LINK_COMPONENTS is valid for both libs and exes.
-
can we assume that all callers to add_llvm_library/add_llvm_target are in ./lib? no.
- if yes, then we can patch calls to llvm_map_components_to_libnames from
add_llvm_library to not fail hard when unknown component lib, and then
validate them after add_subdirectory(lib).
- all calls to llvm_map_components_to_libnames, e.g. from add_llvm_tool, can error out as normal
- otherwise, again patch the call, but move the validation to maybe just before add_subdirectory(cmake/modules).
- if yes, then we can patch calls to llvm_map_components_to_libnames from
add_llvm_library to not fail hard when unknown component lib, and then
validate them after add_subdirectory(lib).
` vim: set syntax=markdown textwidth=0 tabstop=2 shiftwidth=2 nolist:
[CMake] Teach CMake how to generate
LibraryDependencies.inc
[CMake] Copy per-component
required_libraries
intoLINK_COMPONENTS
. NFC.[CMake] Subsume LLVMBuild.txt. Disabled by default.