GenEx: Add support for custom transitive link properties

Teach the `$<TARGET_PROPERTY:...>` generator expression to check for a
new `TRANSITIVE_LINK_PROPERTIES` property in the target's link
closure to enable transitive evaluation of named properties through
the link closure, including entries guarded by `$<LINK_ONLY:...>`.

Fixes: #20416
This commit is contained in:
Brad King 2024-05-09 14:50:41 -04:00
parent b9ee79b8a1
commit c16acd35b3
16 changed files with 266 additions and 7 deletions

View File

@ -614,7 +614,8 @@ The :genex:`TARGET_PROPERTY` generator expression evaluates the above
`usage requirement <Target Usage Requirements_>`_ properties
as builtin transitive properties. It also supports custom transitive
properties defined by the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES`
property on the target and its link dependencies.
and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on the target
and its link dependencies.
For example:
@ -623,21 +624,26 @@ For example:
add_library(example INTERFACE)
set_target_properties(example PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_C"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_L"
INTERFACE_CUSTOM_C "EXAMPLE_CUSTOM_C"
INTERFACE_CUSTOM_L "EXAMPLE_CUSTOM_L"
)
add_library(mylib STATIC mylib.c)
target_link_libraries(mylib PRIVATE example)
set_target_properties(mylib PROPERTIES
CUSTOM_C "MYLIB_PRIVATE_CUSTOM_C"
CUSTOM_L "MYLIB_PRIVATE_CUSTOM_L"
INTERFACE_CUSTOM_C "MYLIB_IFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "MYLIB_IFACE_CUSTOM_L"
)
add_executable(myexe myexe.c)
target_link_libraries(myexe PRIVATE mylib)
set_target_properties(myexe PROPERTIES
CUSTOM_C "MYEXE_CUSTOM_C"
CUSTOM_L "MYEXE_CUSTOM_L"
)
add_custom_target(print ALL VERBATIM
@ -645,8 +651,14 @@ For example:
# Prints "MYLIB_PRIVATE_CUSTOM_C;EXAMPLE_CUSTOM_C"
"$<TARGET_PROPERTY:mylib,CUSTOM_C>"
# Prints "MYLIB_PRIVATE_CUSTOM_L;EXAMPLE_CUSTOM_L"
"$<TARGET_PROPERTY:mylib,CUSTOM_L>"
# Prints "MYEXE_CUSTOM_C"
"$<TARGET_PROPERTY:myexe,CUSTOM_C>"
# Prints "MYEXE_CUSTOM_L;MYLIB_IFACE_CUSTOM_L;EXAMPLE_CUSTOM_L"
"$<TARGET_PROPERTY:myexe,CUSTOM_L>"
)
.. _`Compatible Interface Properties`:

View File

@ -1818,7 +1818,7 @@ The expressions have special evaluation rules for some properties:
* Evaluation of :genex:`$<TARGET_PROPERTY:tgt,PROP>` for some property
``PROP``, named without an ``INTERFACE_`` prefix,
checks the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES`
property on target ``tgt``,
and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on target ``tgt``,
on targets named by its :prop_tgt:`LINK_LIBRARIES`, and on the
transitive closure of targets named by the linked targets'
:prop_tgt:`INTERFACE_LINK_LIBRARIES`.
@ -1834,10 +1834,15 @@ The expressions have special evaluation rules for some properties:
the closure of the linked targets' :prop_tgt:`INTERFACE_LINK_LIBRARIES`,
excluding entries guarded by the :genex:`LINK_ONLY` generator expression.
* If ``PROP`` is named by :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`,
evaluation of the corresponding ``INTERFACE_PROP`` is transitive over
the closure of the linked targets' :prop_tgt:`INTERFACE_LINK_LIBRARIES`,
including entries guarded by the :genex:`LINK_ONLY` generator expression.
* Evaluation of :genex:`$<TARGET_PROPERTY:tgt,INTERFACE_PROP>` for some
property ``INTERFACE_PROP``, named with an ``INTERFACE_`` prefix,
checks the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES`
property on target ``tgt``,
and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on target ``tgt``,
and on the transitive closure of targets named by its
:prop_tgt:`INTERFACE_LINK_LIBRARIES`.
@ -1853,6 +1858,14 @@ The expressions have special evaluation rules for some properties:
the closure of the target's :prop_tgt:`INTERFACE_LINK_LIBRARIES`,
excluding entries guarded by the :genex:`LINK_ONLY` generator expression.
* If ``PROP`` is named by :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`,
evaluation of the corresponding ``INTERFACE_PROP`` is transitive over
the closure of the target's :prop_tgt:`INTERFACE_LINK_LIBRARIES`,
including entries guarded by the :genex:`LINK_ONLY` generator expression.
If a ``PROP`` is named by both :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES`
and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`, the latter takes precedence.
:ref:`Compatible Interface Properties`
These evaluate as a single value combined from the target itself,
from targets named by the target's :prop_tgt:`LINK_LIBRARIES`, and

View File

@ -402,6 +402,7 @@ Properties on Targets
/prop_tgt/SYSTEM
/prop_tgt/TEST_LAUNCHER
/prop_tgt/TRANSITIVE_COMPILE_PROPERTIES
/prop_tgt/TRANSITIVE_LINK_PROPERTIES
/prop_tgt/TYPE
/prop_tgt/UNITY_BUILD
/prop_tgt/UNITY_BUILD_BATCH_SIZE

View File

@ -14,4 +14,6 @@ Any leading ``INTERFACE_`` prefix is ignored, e.g., ``INTERFACE_PROP`` is
treated as just ``PROP``.
See documentation of the :genex:`TARGET_PROPERTY` generator expression
for details of custom transitive property evaluation.
for details of custom transitive property evaluation. See also the
:prop_tgt:`TRANSITIVE_LINK_PROPERTIES` target property, which includes
entries guarded by :genex:`LINK_ONLY`.

View File

@ -0,0 +1,19 @@
TRANSITIVE_LINK_PROPERTIES
--------------------------
.. versionadded:: 3.30
Properties that the :genex:`TARGET_PROPERTY` generator expression, on the
target and its dependents, evaluates as the union of values collected from
the transitive closure of link dependencies, including entries guarded by
:genex:`LINK_ONLY`.
The value is a :ref:`semicolon-separated list <CMake Language Lists>`
of :ref:`custom transitive property <Custom Transitive Properties>` names.
Any leading ``INTERFACE_`` prefix is ignored, e.g., ``INTERFACE_PROP`` is
treated as just ``PROP``.
See documentation of the :genex:`TARGET_PROPERTY` generator expression
for details of custom transitive property evaluation. See also the
:prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` target property, which excludes
entries guarded by :genex:`LINK_ONLY`..

View File

@ -3,5 +3,5 @@ custom-transitive-properties
* The :genex:`TARGET_PROPERTY` generator expression learned to evaluate
:ref:`custom transitive properties <Custom Transitive Properties>`
defined by a new :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES`
target property.
defined by new :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` and
:prop_tgt:`TRANSITIVE_LINK_PROPERTIES` target properties.

View File

@ -611,6 +611,8 @@ void cmExportFileGenerator::PopulateCustomTransitiveInterfaceProperties(
{
this->PopulateInterfaceProperty("TRANSITIVE_COMPILE_PROPERTIES", target,
properties);
this->PopulateInterfaceProperty("TRANSITIVE_LINK_PROPERTIES", target,
properties);
std::set<std::string> ifaceProperties;
for (std::string const& config : this->Configurations) {
for (auto const& i : target->GetCustomTransitiveProperties(

View File

@ -210,7 +210,7 @@ cmGeneratorTarget::IsTransitiveProperty(cm::string_view prop,
UseTo::Compile };
}
} else if (!evaluatingLinkLibraries) {
// Honor TRANSITIVE_COMPILE_PROPERTIES
// Honor TRANSITIVE_COMPILE_PROPERTIES and TRANSITIVE_LINK_PROPERTIES
// from the link closure when we are not evaluating the closure itself.
CustomTransitiveProperties const& ctp =
this->GetCustomTransitiveProperties(config, propertyFor);
@ -286,6 +286,7 @@ cmGeneratorTarget::GetCustomTransitiveProperties(std::string const& config,
}
}
};
addTransitiveProperties("TRANSITIVE_LINK_PROPERTIES", UseTo::Link);
addTransitiveProperties("TRANSITIVE_COMPILE_PROPERTIES", UseTo::Compile);
i = ctpm.emplace(config, std::move(ctp)).first;
}

View File

@ -5,15 +5,20 @@ project(CustomTransitiveProperties C)
add_library(iface1 INTERFACE)
set_target_properties(iface1 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_A" # LINK_ONLY not pierced
TRANSITIVE_LINK_PROPERTIES "CUSTOM_U" # LINK_ONLY pierced
INTERFACE_CUSTOM_A "CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_$<UPPER_CASE:$<TARGET_PROPERTY:NAME>>"
INTERFACE_CUSTOM_B "CUSTOM_B_IFACE1"
INTERFACE_CUSTOM_C "CUSTOM_C_IFACE1"
INTERFACE_CUSTOM_U "CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_$<UPPER_CASE:$<TARGET_PROPERTY:NAME>>"
INTERFACE_CUSTOM_V "CUSTOM_V_IFACE1"
INTERFACE_CUSTOM_W "CUSTOM_W_IFACE1"
)
add_library(iface2 INTERFACE)
set_target_properties(iface2 PROPERTIES
INTERFACE_CUSTOM_A "CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_$<TARGET_PROPERTY:TYPE>"
INTERFACE_CUSTOM_U "CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_$<TARGET_PROPERTY:TYPE>"
)
target_link_libraries(iface2 INTERFACE iface1)
@ -24,30 +29,44 @@ add_library(static1 STATIC static1.c)
target_link_libraries(static1 PRIVATE iface2)
set_target_properties(static1 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "${unnecessary_INTERFACE_}CUSTOM_B" # LINK_ONLY not pierced
TRANSITIVE_LINK_PROPERTIES "${unnecessary_INTERFACE_}CUSTOM_V" # LINK_ONLY pierced
CUSTOM_A "CUSTOM_A_STATIC1"
CUSTOM_B "CUSTOM_B_STATIC1"
CUSTOM_U "CUSTOM_U_STATIC1"
CUSTOM_V "CUSTOM_V_STATIC1"
INTERFACE_CUSTOM_A "CUSTOM_A_STATIC1_IFACE"
INTERFACE_CUSTOM_B "CUSTOM_B_STATIC1_IFACE"
INTERFACE_CUSTOM_U "CUSTOM_U_STATIC1_IFACE"
INTERFACE_CUSTOM_V "CUSTOM_V_STATIC1_IFACE"
)
target_compile_definitions(static1 PRIVATE
$<TARGET_PROPERTY:CUSTOM_A>
$<TARGET_PROPERTY:CUSTOM_B>
$<TARGET_PROPERTY:CUSTOM_U>
$<TARGET_PROPERTY:CUSTOM_V>
)
add_library(object1 OBJECT object1.c)
target_link_libraries(object1 PRIVATE iface2)
set_target_properties(object1 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "${unnecessary_INTERFACE_}CUSTOM_C" # LINK_ONLY not pierced
TRANSITIVE_LINK_PROPERTIES "${unnecessary_INTERFACE_}CUSTOM_W" # LINK_ONLY pierced
CUSTOM_A "CUSTOM_A_OBJECT1"
CUSTOM_C "CUSTOM_C_OBJECT1"
CUSTOM_U "CUSTOM_U_OBJECT1"
CUSTOM_W "CUSTOM_W_OBJECT1"
INTERFACE_CUSTOM_A "CUSTOM_A_OBJECT1_IFACE"
INTERFACE_CUSTOM_C "CUSTOM_C_OBJECT1_IFACE"
INTERFACE_CUSTOM_U "CUSTOM_U_OBJECT1_IFACE"
INTERFACE_CUSTOM_W "CUSTOM_W_OBJECT1_IFACE"
)
target_compile_definitions(object1 PRIVATE
$<TARGET_PROPERTY:CUSTOM_A>
$<TARGET_PROPERTY:CUSTOM_C>
$<TARGET_PROPERTY:CUSTOM_U>
$<TARGET_PROPERTY:CUSTOM_W>
)
add_executable(CustomTransitiveProperties main.c)
@ -56,6 +75,9 @@ set_target_properties(CustomTransitiveProperties PROPERTIES
CUSTOM_A "CUSTOM_A_MAIN"
CUSTOM_B "CUSTOM_B_MAIN"
CUSTOM_C "CUSTOM_C_MAIN"
CUSTOM_U "CUSTOM_U_MAIN"
CUSTOM_V "CUSTOM_V_MAIN"
CUSTOM_W "CUSTOM_W_MAIN"
)
# Test TRANSITIVE_*_PROPERTY evaluation within usage requirements.
@ -63,6 +85,9 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE
$<TARGET_PROPERTY:CUSTOM_A>
$<TARGET_PROPERTY:CUSTOM_B>
$<TARGET_PROPERTY:CUSTOM_C>
$<TARGET_PROPERTY:CUSTOM_U>
$<TARGET_PROPERTY:CUSTOM_V>
$<TARGET_PROPERTY:CUSTOM_W>
)
# Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements.
@ -76,25 +101,46 @@ static1 CUSTOM_A: '$<TARGET_PROPERTY:static1,CUSTOM_A>'
static1 INTERFACE_CUSTOM_A: '$<TARGET_PROPERTY:static1,INTERFACE_CUSTOM_A>'
static1 CUSTOM_B: '$<TARGET_PROPERTY:static1,CUSTOM_B>'
static1 INTERFACE_CUSTOM_B: '$<TARGET_PROPERTY:static1,INTERFACE_CUSTOM_B>'
static1 CUSTOM_U: '$<TARGET_PROPERTY:static1,CUSTOM_U>'
static1 INTERFACE_CUSTOM_U: '$<TARGET_PROPERTY:static1,INTERFACE_CUSTOM_U>'
static1 CUSTOM_V: '$<TARGET_PROPERTY:static1,CUSTOM_V>'
static1 INTERFACE_CUSTOM_V: '$<TARGET_PROPERTY:static1,INTERFACE_CUSTOM_V>'
object1 CUSTOM_A: '$<TARGET_PROPERTY:object1,CUSTOM_A>'
object1 INTERFACE_CUSTOM_A: '$<TARGET_PROPERTY:object1,INTERFACE_CUSTOM_A>'
object1 CUSTOM_C: '$<TARGET_PROPERTY:object1,CUSTOM_C>'
object1 INTERFACE_CUSTOM_C: '$<TARGET_PROPERTY:object1,INTERFACE_CUSTOM_C>'
object1 CUSTOM_U: '$<TARGET_PROPERTY:object1,CUSTOM_U>'
object1 INTERFACE_CUSTOM_U: '$<TARGET_PROPERTY:object1,INTERFACE_CUSTOM_U>'
object1 CUSTOM_W: '$<TARGET_PROPERTY:object1,CUSTOM_W>'
object1 INTERFACE_CUSTOM_W: '$<TARGET_PROPERTY:object1,INTERFACE_CUSTOM_W>'
main CUSTOM_A: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_A>'
main INTERFACE_CUSTOM_A: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_A>'
main CUSTOM_B: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_B>'
main INTERFACE_CUSTOM_B: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_B>'
main CUSTOM_C: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_C>'
main INTERFACE_CUSTOM_C: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_C>'
main CUSTOM_U: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_U>'
main INTERFACE_CUSTOM_U: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_U>'
main CUSTOM_V: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_V>'
main INTERFACE_CUSTOM_V: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_V>'
main CUSTOM_W: '$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_W>'
main INTERFACE_CUSTOM_W: '$<TARGET_PROPERTY:CustomTransitiveProperties,INTERFACE_CUSTOM_W>'
")
add_custom_target(check ALL VERBATIM
COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIG> -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
COMMAND CustomTransitiveProperties
"$<TARGET_PROPERTY:static1,CUSTOM_A>" "CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_STATIC1"
"$<TARGET_PROPERTY:static1,CUSTOM_B>" "CUSTOM_B_STATIC1;CUSTOM_B_IFACE1"
"$<TARGET_PROPERTY:static1,CUSTOM_U>" "CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1"
"$<TARGET_PROPERTY:static1,CUSTOM_V>" "CUSTOM_V_STATIC1;CUSTOM_V_IFACE1"
"$<TARGET_PROPERTY:object1,CUSTOM_A>" "CUSTOM_A_OBJECT1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_OBJECT_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_OBJECT1"
"$<TARGET_PROPERTY:object1,CUSTOM_C>" "CUSTOM_C_OBJECT1;CUSTOM_C_IFACE1"
"$<TARGET_PROPERTY:object1,CUSTOM_U>" "CUSTOM_U_OBJECT1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_OBJECT_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_OBJECT1"
"$<TARGET_PROPERTY:object1,CUSTOM_W>" "CUSTOM_W_OBJECT1;CUSTOM_W_IFACE1"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_A>" "CUSTOM_A_MAIN"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_B>" "CUSTOM_B_MAIN;CUSTOM_B_STATIC1_IFACE"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_C>" "CUSTOM_C_MAIN;CUSTOM_C_OBJECT1_IFACE"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_U>" "CUSTOM_U_MAIN;CUSTOM_U_STATIC1_IFACE;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_EXECUTABLE;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_CUSTOMTRANSITIVEPROPERTIES;CUSTOM_U_OBJECT1_IFACE"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_V>" "CUSTOM_V_MAIN;CUSTOM_V_STATIC1_IFACE;CUSTOM_V_IFACE1"
"$<TARGET_PROPERTY:CustomTransitiveProperties,CUSTOM_W>" "CUSTOM_W_MAIN;CUSTOM_W_IFACE1;CUSTOM_W_OBJECT1_IFACE"
)

View File

@ -8,16 +8,30 @@ static1 CUSTOM_A: 'CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_
static1 INTERFACE_CUSTOM_A: 'CUSTOM_A_STATIC1_IFACE'
static1 CUSTOM_B: 'CUSTOM_B_STATIC1;CUSTOM_B_IFACE1'
static1 INTERFACE_CUSTOM_B: 'CUSTOM_B_STATIC1_IFACE'
static1 CUSTOM_U: 'CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1'
static1 INTERFACE_CUSTOM_U: 'CUSTOM_U_STATIC1_IFACE;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1'
static1 CUSTOM_V: 'CUSTOM_V_STATIC1;CUSTOM_V_IFACE1'
static1 INTERFACE_CUSTOM_V: 'CUSTOM_V_STATIC1_IFACE;CUSTOM_V_IFACE1'
object1 CUSTOM_A: 'CUSTOM_A_OBJECT1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_OBJECT_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_OBJECT1'
object1 INTERFACE_CUSTOM_A: 'CUSTOM_A_OBJECT1_IFACE'
object1 CUSTOM_C: 'CUSTOM_C_OBJECT1;CUSTOM_C_IFACE1'
object1 INTERFACE_CUSTOM_C: 'CUSTOM_C_OBJECT1_IFACE'
object1 CUSTOM_U: 'CUSTOM_U_OBJECT1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_OBJECT_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_OBJECT1'
object1 INTERFACE_CUSTOM_U: 'CUSTOM_U_OBJECT1_IFACE;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_OBJECT_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_OBJECT1'
object1 CUSTOM_W: 'CUSTOM_W_OBJECT1;CUSTOM_W_IFACE1'
object1 INTERFACE_CUSTOM_W: 'CUSTOM_W_OBJECT1_IFACE;CUSTOM_W_IFACE1'
main CUSTOM_A: 'CUSTOM_A_MAIN'
main INTERFACE_CUSTOM_A: ''
main CUSTOM_B: 'CUSTOM_B_MAIN;CUSTOM_B_STATIC1_IFACE'
main INTERFACE_CUSTOM_B: ''
main CUSTOM_C: 'CUSTOM_C_MAIN;CUSTOM_C_OBJECT1_IFACE'
main INTERFACE_CUSTOM_C: ''
main CUSTOM_U: 'CUSTOM_U_MAIN;CUSTOM_U_STATIC1_IFACE;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_EXECUTABLE;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_CUSTOMTRANSITIVEPROPERTIES;CUSTOM_U_OBJECT1_IFACE'
main INTERFACE_CUSTOM_U: ''
main CUSTOM_V: 'CUSTOM_V_MAIN;CUSTOM_V_STATIC1_IFACE;CUSTOM_V_IFACE1'
main INTERFACE_CUSTOM_V: ''
main CUSTOM_W: 'CUSTOM_W_MAIN;CUSTOM_W_IFACE1;CUSTOM_W_OBJECT1_IFACE'
main INTERFACE_CUSTOM_W: ''
]])
string(REGEX REPLACE "\r\n" "\n" expect "${expect}")
string(REGEX REPLACE "\n+$" "" expect "${expect}")

View File

@ -45,6 +45,75 @@
# error "CUSTOM_C_MAIN incorrectly not defined"
#endif
#ifndef CUSTOM_U_IFACE1
# error "CUSTOM_U_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_IFACE2
# error "CUSTOM_U_IFACE2 incorrectly not defined"
#endif
#ifndef CUSTOM_U_MAIN
# error "CUSTOM_U_MAIN incorrectly not defined"
#endif
#ifdef CUSTOM_U_STATIC1
# error "CUSTOM_U_STATIC1 incorrectly defined"
#endif
#ifndef CUSTOM_U_STATIC1_IFACE
# error "CUSTOM_U_STATIC1_IFACE incorrectly not defined"
#endif
#ifdef CUSTOM_U_OBJECT1
# error "CUSTOM_U_OBJECT1 incorrectly defined"
#endif
#ifndef CUSTOM_U_OBJECT1_IFACE
# error "CUSTOM_U_OBJECT1_IFACE incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_NAME_CUSTOMTRANSITIVEPROPERTIES
# error \
"CUSTOM_U_TARGET_NAME_CUSTOMTRANSITIVEPROPERTIES incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_TYPE_EXECUTABLE
# error "CUSTOM_U_TARGET_TYPE_EXECUTABLE incorrectly not defined"
#endif
#ifndef CUSTOM_V_IFACE1
# error "CUSTOM_V_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_V_MAIN
# error "CUSTOM_V_MAIN incorrectly not defined"
#endif
#ifdef CUSTOM_V_STATIC1
# error "CUSTOM_V_STATIC1 incorrectly defined"
#endif
#ifndef CUSTOM_V_STATIC1_IFACE
# error "CUSTOM_V_STATIC1_IFACE incorrectly not defined"
#endif
#ifndef CUSTOM_W_IFACE1
# error "CUSTOM_W_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_W_MAIN
# error "CUSTOM_W_MAIN incorrectly not defined"
#endif
#ifdef CUSTOM_W_OBJECT1
# error "CUSTOM_W_OBJECT1 incorrectly defined"
#endif
#ifndef CUSTOM_W_OBJECT1_IFACE
# error "CUSTOM_W_OBJECT1_IFACE incorrectly not defined"
#endif
extern int static1(void);
extern int object1(void);

View File

@ -30,6 +30,34 @@
# error "CUSTOM_C_OBJECT1_IFACE incorrectly defined"
#endif
#ifndef CUSTOM_U_IFACE1
# error "CUSTOM_U_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_IFACE2
# error "CUSTOM_U_IFACE2 incorrectly not defined"
#endif
#ifndef CUSTOM_U_OBJECT1
# error "CUSTOM_U_OBJECT1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_NAME_OBJECT1
# error "CUSTOM_U_TARGET_NAME_OBJECT1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_TYPE_OBJECT_LIBRARY
# error "CUSTOM_U_TARGET_TYPE_OBJECT_LIBRARY incorrectly not defined"
#endif
#ifndef CUSTOM_W_IFACE1
# error "CUSTOM_W_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_W_OBJECT1
# error "CUSTOM_W_OBJECT1 incorrectly not defined"
#endif
int object1(void)
{
return 0;

View File

@ -30,6 +30,34 @@
# error "CUSTOM_B_STATIC1_IFACE incorrectly defined"
#endif
#ifndef CUSTOM_U_IFACE1
# error "CUSTOM_U_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_IFACE2
# error "CUSTOM_U_IFACE2 incorrectly not defined"
#endif
#ifndef CUSTOM_U_STATIC1
# error "CUSTOM_U_STATIC1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_NAME_STATIC1
# error "CUSTOM_U_TARGET_NAME_STATIC1 incorrectly not defined"
#endif
#ifndef CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY
# error "CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY incorrectly not defined"
#endif
#ifndef CUSTOM_V_IFACE1
# error "CUSTOM_V_IFACE1 incorrectly not defined"
#endif
#ifndef CUSTOM_V_STATIC1
# error "CUSTOM_V_STATIC1 incorrectly not defined"
#endif
int static1(void)
{
return 0;

View File

@ -121,21 +121,29 @@ block()
add_library(testLib10 STATIC testLib10.c)
set_target_properties(testLib10 PROPERTIES
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_C"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_L"
INTERFACE_CUSTOM_C "TESTLIB10_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB10_INTERFACE_CUSTOM_L"
)
target_compile_definitions(testLib10 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_L>"
)
add_library(testLib11 STATIC testLib11.c)
target_link_libraries(testLib11 PRIVATE testLib10)
set_target_properties(testLib11 PROPERTIES
INTERFACE_CUSTOM_C "TESTLIB11_INTERFACE_CUSTOM_C"
INTERFACE_CUSTOM_L "TESTLIB11_INTERFACE_CUSTOM_L"
TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_D"
TRANSITIVE_LINK_PROPERTIES "CUSTOM_M"
INTERFACE_CUSTOM_D "TESTLIB11_INTERFACE_CUSTOM_D"
INTERFACE_CUSTOM_M "TESTLIB11_INTERFACE_CUSTOM_M"
)
target_compile_definitions(testLib11 INTERFACE
"$<TARGET_PROPERTY:CUSTOM_C>"
"$<TARGET_PROPERTY:CUSTOM_D>"
"$<TARGET_PROPERTY:CUSTOM_L>"
"$<TARGET_PROPERTY:CUSTOM_M>"
)
endblock()

View File

@ -2,6 +2,10 @@
# error "TESTLIB10_INTERFACE_CUSTOM_C incorrectly not defined!"
#endif
#ifndef TESTLIB10_INTERFACE_CUSTOM_L
# error "TESTLIB10_INTERFACE_CUSTOM_L incorrectly not defined!"
#endif
int testLib10(void);
int main(void)

View File

@ -10,6 +10,18 @@
# error "TESTLIB11_INTERFACE_CUSTOM_D incorrectly not defined!"
#endif
#ifndef TESTLIB10_INTERFACE_CUSTOM_L
# error "TESTLIB10_INTERFACE_CUSTOM_L incorrectly not defined!"
#endif
#ifndef TESTLIB11_INTERFACE_CUSTOM_L
# error "TESTLIB11_INTERFACE_CUSTOM_L incorrectly not defined!"
#endif
#ifndef TESTLIB11_INTERFACE_CUSTOM_M
# error "TESTLIB11_INTERFACE_CUSTOM_M incorrectly not defined!"
#endif
int testLib11(void);
int main(void)