When LIBCLANG_BUILD_STATIC=ON and LLVM_ENABLE_PIC=ON, PIC version of libclang.a and libclang.so are built as expected. However libclang.a is not installed. Looking at the macro llvm_add_library(), when both SHARED and STATIC are set, it renames the static library to ${name}_static and then adds it to targets. But when add_clang_library() calls install, it only checks if ${name} is in targets.
To work around this issue, loop through both ${name} and ${name}_static and install both of them if they're in targets. This is still correct if only shared or static library is built. In those cases, only ${name} is added to targets and cmake install will generate the right install script depending on the library's type.
Test plan:
cmake with LIBCLANG_BUILD_STATIC=ON and then ninja install, from master and this diff. Compare the result directory trees. Confirm that only difference is the added libclang.a.