mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Add an APPLY action to $<LIST:TRANSFORM> that evaluates an arbitrary <body> once per selected element, with $<_0> bound to the element, so a list can be mapped through any generator expression at generate time. Unlike the configure-time list(TRANSFORM ... APPLY <function>) command, the genex form has no side effects and returns the body's value directly, and a list-valued result expands into multiple elements. The body evaluates in its own binding scope, so nested APPLY actions can shadow $<_0>, and context-sensitive state it observes (such as target dependencies) still propagates to the enclosing expression. APPLY accepts the same AT/FOR/REGEX selectors as the canned actions. Issue: #27892
7 lines
327 B
CMake
7 lines
327 B
CMake
add_library(libA INTERFACE)
|
|
target_include_directories(libA INTERFACE /a/inc)
|
|
add_library(libB INTERFACE)
|
|
target_include_directories(libB INTERFACE /b/inc1 /b/inc2)
|
|
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/tp.txt"
|
|
CONTENT "$<LIST:TRANSFORM,libA;libB,APPLY,$<TARGET_PROPERTY:$<_0>,INTERFACE_INCLUDE_DIRECTORIES>>\n")
|