mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-29 04:09:35 +03:00
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
42 lines
1.9 KiB
CMake
42 lines
1.9 KiB
CMake
# TODO: $<CONFIG> matches both the conumer's configuration AND the selected
|
|
# configuration of the imported target. This is ungood, and eventually we need
|
|
# a way to match only the selected configuration of the imported target. For
|
|
# historic reasons, that will probably not be $<CONFIG>, which means $<CONFIG>
|
|
# should eventually stop matching the selected configuration of the imported
|
|
# target. When that happens, this test should be changed to use the new
|
|
# mechanism, and the test cases adjusted accordingly.
|
|
|
|
# Under CMP0200 OLD, CMake fails to select a valid configuration for an
|
|
# imported INTERFACE library with no location, and will (as an implementation
|
|
# artifact) select the last configuration in IMPORTED_CONFIGURATIONS.
|
|
#
|
|
# Under NEW, CMake should select a configuration which matches the current
|
|
# build type, if available in IMPORTED_CONFIGURATIONS.
|
|
function(do_match_config_test)
|
|
add_library(lib_match INTERFACE IMPORTED)
|
|
set_target_properties(lib_match PROPERTIES
|
|
IMPORTED_CONFIGURATIONS "TEST;RELEASE;DEBUG"
|
|
INTERFACE_COMPILE_DEFINITIONS
|
|
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>;$<$<CONFIG:test>:TEST>"
|
|
)
|
|
|
|
add_executable(exe_match configtest.c)
|
|
target_compile_definitions(exe_match PRIVATE ${ARGN})
|
|
target_link_libraries(exe_match PRIVATE lib_match)
|
|
endfunction()
|
|
|
|
# Under NEW, CMake should select the first of IMPORTED_CONFIGURATIONS if no
|
|
# mapping exists and no configuration matching the current build type exists.
|
|
function(do_first_config_test)
|
|
add_library(lib_first INTERFACE IMPORTED)
|
|
set_target_properties(lib_first PROPERTIES
|
|
IMPORTED_CONFIGURATIONS "TEST;DEBUG"
|
|
INTERFACE_COMPILE_DEFINITIONS
|
|
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:test>:TEST>"
|
|
)
|
|
|
|
add_executable(exe_first configtest.c)
|
|
target_compile_definitions(exe_first PRIVATE ${ARGN})
|
|
target_link_libraries(exe_first PRIVATE lib_first)
|
|
endfunction()
|