diff options
author | Brad King <brad.king@kitware.com> | 2022-01-12 22:14:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-01-29 11:48:13 (GMT) |
commit | f3ad061858d03cc2a0569f903df3560152106050 (patch) | |
tree | be604880c112a5b7b6eeee586cf2238c4e952c3e /Tests/ObjectLibrary | |
parent | 193a999cd5ed345d79b91dae1fd284248ec93ba2 (diff) | |
download | CMake-f3ad061858d03cc2a0569f903df3560152106050.zip CMake-f3ad061858d03cc2a0569f903df3560152106050.tar.gz CMake-f3ad061858d03cc2a0569f903df3560152106050.tar.bz2 |
Add usage requirements to update direct link dependencies
Link line construction starts with `LINK_LIBRARIES` and appends
dependencies from the transitive closure of `INTERFACE_LINK_LIBRARIES`.
Only the entries of `LINK_LIBRARIES` are considered direct link
dependencies. In some advanced use cases, particularly involving static
libraries and static plugins, usage requirements need to update the list
of direct link dependencies. This may mean adding new items, removing
existing items, or both.
Add target properties to encode these usage requirements:
* INTERFACE_LINK_LIBRARIES_DIRECT
* INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE
Fixes: #22496
Diffstat (limited to 'Tests/ObjectLibrary')
-rw-r--r-- | Tests/ObjectLibrary/Transitive/BarMain.c | 6 | ||||
-rw-r--r-- | Tests/ObjectLibrary/Transitive/BarObject1.c | 5 | ||||
-rw-r--r-- | Tests/ObjectLibrary/Transitive/BarObject2.c | 5 | ||||
-rw-r--r-- | Tests/ObjectLibrary/Transitive/BarObject3.c | 4 | ||||
-rw-r--r-- | Tests/ObjectLibrary/Transitive/CMakeLists.txt | 14 |
5 files changed, 34 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/Transitive/BarMain.c b/Tests/ObjectLibrary/Transitive/BarMain.c new file mode 100644 index 0000000..aec3e48 --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarMain.c @@ -0,0 +1,6 @@ +extern int BarObject1(void); + +int main(void) +{ + return BarObject1(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject1.c b/Tests/ObjectLibrary/Transitive/BarObject1.c new file mode 100644 index 0000000..2f68386 --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject1.c @@ -0,0 +1,5 @@ +extern int BarObject2(void); +int BarObject1(void) +{ + return BarObject2(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject2.c b/Tests/ObjectLibrary/Transitive/BarObject2.c new file mode 100644 index 0000000..881c64a --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject2.c @@ -0,0 +1,5 @@ +extern int BarObject3(void); +int BarObject2(void) +{ + return BarObject3(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject3.c b/Tests/ObjectLibrary/Transitive/BarObject3.c new file mode 100644 index 0000000..e557dbc --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject3.c @@ -0,0 +1,4 @@ +int BarObject3(void) +{ + return 0; +} diff --git a/Tests/ObjectLibrary/Transitive/CMakeLists.txt b/Tests/ObjectLibrary/Transitive/CMakeLists.txt index e9f57d4..17247eb 100644 --- a/Tests/ObjectLibrary/Transitive/CMakeLists.txt +++ b/Tests/ObjectLibrary/Transitive/CMakeLists.txt @@ -9,3 +9,17 @@ add_library(FooObject2 OBJECT FooObject.c) target_link_libraries(FooObject2 INTERFACE FooStatic) add_executable(Transitive2 Transitive.c) target_link_libraries(Transitive2 PRIVATE FooObject2) + +add_library(FooObjectDirect OBJECT FooObject.c) +add_library(FooStaticDirect STATIC FooStatic.c) +set_property(TARGET FooStaticDirect PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT FooObjectDirect) +add_executable(TransitiveDirect Transitive.c) +target_link_libraries(TransitiveDirect PRIVATE FooStaticDirect) + +add_library(BarObject1 OBJECT BarObject1.c) +add_library(BarObject2 OBJECT BarObject2.c) +add_library(BarObject3 OBJECT BarObject3.c) +set_property(TARGET BarObject1 PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT BarObject2) +set_property(TARGET BarObject2 PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT BarObject3) +add_executable(BarMain BarMain.c) +target_link_libraries(BarMain PRIVATE BarObject1) |