mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-29 18:51:05 -05:00
8ac826a5f2
The historic implementation of `$<CONFIG>` had some errors that could result in multiple configurations matching. First, it always considered the configuration of the consuming target, even if a consumed imported target selected a different configuration. Second, it matched the entire list of `MAP_IMPORTED_CONFIG_<CONFIG>` configurations, even if none of those were actually selected. The latter in particular is redundant at best, as we also consider the selected configuration of an imported target, which is the correct configuration to match for imported targets. Refactor the implementation so that only one configuration is considered. Fixes: #23660 Issue: #27022
33 lines
1.3 KiB
CMake
33 lines
1.3 KiB
CMake
# Under CMP0199 OLD, $<CONFIG> matches not just the selected configuration, but
|
|
# every entry in MAP_IMPORTED_CONFIG_<CONFIG>. Under NEW, it should only match
|
|
# the selected configuration.
|
|
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()
|
|
|
|
# Under CMake CMP0199 OLD, $<CONFIG> matches both the consumer's configuration
|
|
# AND the selected configuration of the library being consumed. Under NEW, it
|
|
# should only match the selected configuration.
|
|
function(do_unique_config_test)
|
|
add_library(lib_unique INTERFACE IMPORTED)
|
|
set_target_properties(lib_unique PROPERTIES
|
|
IMPORTED_CONFIGURATIONS "DEBUG"
|
|
INTERFACE_COMPILE_DEFINITIONS
|
|
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>"
|
|
)
|
|
|
|
add_executable(exe_unique configtest.c)
|
|
target_compile_definitions(exe_unique PRIVATE ${ARGN})
|
|
target_link_libraries(exe_unique PRIVATE lib_unique)
|
|
endfunction()
|