Files
CMake/Tests/RunCMake/GeneratorExpression/CMP0199-cases.cmake
T
Matthew Woehlke 35d5a4fd6d GenEx: Partially restore pre-CMP0199 behavior of $<CONFIG>
Modify the implementation of policy CMP0199 to only remove the oddball
configuration map matching of `$<CONFIG>` in `NEW` mode, restoring the
old behavior of matching BOTH the consumer's configuration and the
selected configuration of the imported target. It turns out that users
are more dependent on the former than the latter, and while matching
more than one thing is still dodgy, we will likely need to introduce a
new generator expression to match the selected configuration of the
imported target.

Meanwhile, `$<CONFIG>` on targets imported from CPS still only matches
the selected configuration of the imported target, which is the behavior
specified by CPS. However, this can only happen for `$<CONFIG>`
expressions that were generated internally during import.

Update documentation and test cases accordingly.

Fixes: #27487
Fixes: #27495
2026-01-12 10:58:08 -05:00

18 lines
760 B
CMake

# Under CMP0199 OLD, $<CONFIG> matches the selected configuration and every
# entry in MAP_IMPORTED_CONFIG_<CONFIG>. Under NEW, it should only match the
# configuration of the consuming target and the selected configuration of the
# library being consumed.
function(do_mapped_config_test)
add_library(lib_mapped INTERFACE IMPORTED)
set_target_properties(lib_mapped PROPERTIES
IMPORTED_CONFIGURATIONS "TEST"
INTERFACE_COMPILE_DEFINITIONS
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>;$<$<CONFIG:test>:TEST>"
MAP_IMPORTED_CONFIG_RELEASE "RELEASE;DEBUG;TEST"
)
add_executable(exe_mapped configtest.c)
target_compile_definitions(exe_mapped PRIVATE ${ARGN})
target_link_libraries(exe_mapped PRIVATE lib_mapped)
endfunction()