[all-commits] [llvm/llvm-project] 0c9230: Reland [libclang] Install both libclang.a and libc...
Shoaib Meenai via All-commits
all-commits at lists.llvm.org
Wed May 6 19:34:32 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 0c9230dad1692bc3d8f1ce2dddae413a115f2532
https://github.com/llvm/llvm-project/commit/0c9230dad1692bc3d8f1ce2dddae413a115f2532
Author: Han Zhu <zhuhan at fb.com>
Date: 2020-05-06 (Wed, 06 May 2020)
Changed paths:
M clang/cmake/modules/AddClang.cmake
Log Message:
-----------
Reland [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON
f8990feb125a enabled installing PIC version of both libclang.a and
libclang.so when LIBCLANG_BUILD_STATIC is ON. But it broke the no-PIC
build when LLVM_ENABLE_PIC=OFF with the following error:
```
CMake Error at
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/tools/libclang/CMakeLists.txt:123
(target_compile_definitions):
target_compile_definitions called with non-compilable target type
```
This is because as the code loops through ${name} and ${name}_static, it
introduced a side effect, which is adding an empty libclang_static to
targets. Later target_compile_definitions is called on libclang_static.
That function requires that target must have been created by a command
such as add_executable() or add_library(), so it crashed.
The solution is to not naively loop through both libclang and
libclang_static, but only the ones that are actually added by
llvm_add_library(). Here's the library build type to library target name
mapping:
| SHARED only | libclang |
| STATIC only | libclang |
| SHARED and STATIC | libclang and libclang_static |
So only when SHARED and STATIC are both set should we loop through two
targets. Explicitly parse the STATIC argument and set the list
accordingly.
Reviewed By: smeenai
Differential Revision: https://reviews.llvm.org/D79059
More information about the All-commits
mailing list