[libcxx-commits] [PATCH] D120719: [runtimes] Always configure libc++abi before libc++
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 8 00:47:21 PDT 2022
phosek added a comment.
In D120719#3380448 <https://reviews.llvm.org/D120719#3380448>, @ldionne wrote:
> In D120719#3376333 <https://reviews.llvm.org/D120719#3376333>, @phosek wrote:
>
>> @ldionne this is what I had in mind:
>>
>> cmake_minimum_required(VERSION 3.13.4)
>> project(Test C)
>>
>> add_library(A STATIC a.c)
>>
>> add_library(C SHARED c.c)
>> target_link_libraries(C PRIVATE "$<GENEX_EVAL:$<TARGET_LINKER_FILE:B>>")
>>
>> add_library(B IMPORTED STATIC)
>> set_target_properties(B PROPERTIES IMPORTED_LOCATION "$<TARGET_LINKER_FILE:A>")
>>
>> It seems to be working as expected in this minimal example.
>
> This is really clever, but the problem is that when you do `target_link_libraries(C PRIVATE "$<GENEX_EVAL:$<TARGET_LINKER_FILE:B>>")`, you lose the property of linking against the `B` target itself -- you're only linking against a specific `.dylib` or `.a` file, but you don't get all the target-level stuff like transitive `target_compile_definitions`, `target_include_directories` and so on, right? So for example, below `C` won't get the includes added by `B`:
>
> cmake_minimum_required(VERSION 3.13.4)
> project(Test C)
>
> add_library(A STATIC a.c)
>
> add_library(C SHARED c.c)
> target_link_libraries(C PRIVATE "$<GENEX_EVAL:$<TARGET_LINKER_FILE:B>>") # This doesn't get `-I some/path/include`
>
> add_library(B IMPORTED STATIC)
> target_include_directories(B INTERFACE "some/path/include")
> set_target_properties(B PROPERTIES IMPORTED_LOCATION "$<TARGET_LINKER_FILE:A>")
You can use the same technique for include directories:
cmake_minimum_required(VERSION 3.13.4)
project(Test C)
add_library(A STATIC a.c)
target_include_directories(A PUBLIC "include/a")
add_library(C SHARED c.c)
target_link_libraries(C PRIVATE "$<GENEX_EVAL:$<TARGET_LINKER_FILE:B>>")
target_include_directories(C PRIVATE "$<GENEX_EVAL:$<TARGET_PROPERTY:B,INCLUDE_DIRECTORIES>>")
add_library(B IMPORTED STATIC)
set_target_properties(B PROPERTIES IMPORTED_LOCATION "$<TARGET_LINKER_FILE:A>")
set_target_properties(B PROPERTIES INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:A,INCLUDE_DIRECTORIES>")
Is that what you had in mind?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120719/new/
https://reviews.llvm.org/D120719
More information about the libcxx-commits
mailing list