Debian Codegraph @

Tests/RunCMake/GeneratorExpression/CMP0200-cases.cmake

raw
1 # TODO: $<CONFIG> matches both the conumer's configuration AND the selected
2 # configuration of the imported target. This is ungood, and eventually we need
3 # a way to match only the selected configuration of the imported target. For
4 # historic reasons, that will probably not be $<CONFIG>, which means $<CONFIG>
5 # should eventually stop matching the selected configuration of the imported
6 # target. When that happens, this test should be changed to use the new
7 # mechanism, and the test cases adjusted accordingly.
8
9 # Under CMP0200 OLD, CMake fails to select a valid configuration for an
10 # imported INTERFACE library with no location, and will (as an implementation
11 # artifact) select the last configuration in IMPORTED_CONFIGURATIONS.
12 #
13 # Under NEW, CMake should select a configuration which matches the current
14 # build type, if available in IMPORTED_CONFIGURATIONS.
15 function(do_match_config_test)
16 add_library(lib_match INTERFACE IMPORTED)
17 set_target_properties(lib_match PROPERTIES
18 IMPORTED_CONFIGURATIONS "TEST;RELEASE;DEBUG"
19 INTERFACE_COMPILE_DEFINITIONS
20 "$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>;$<$<CONFIG:test>:TEST>"
21 )
22
23 add_executable(exe_match configtest.c)
24 target_compile_definitions(exe_match PRIVATE ${ARGN})
25 target_link_libraries(exe_match PRIVATE lib_match)
26 endfunction()
27
28 # Under NEW, CMake should select the first of IMPORTED_CONFIGURATIONS if no
29 # mapping exists and no configuration matching the current build type exists.
30 function(do_first_config_test)
31 add_library(lib_first INTERFACE IMPORTED)
32 set_target_properties(lib_first PROPERTIES
33 IMPORTED_CONFIGURATIONS "TEST;DEBUG"
34 INTERFACE_COMPILE_DEFINITIONS
35 "$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:test>:TEST>"
36 )
37
38 add_executable(exe_first configtest.c)
39 target_compile_definitions(exe_first PRIVATE ${ARGN})
40 target_link_libraries(exe_first PRIVATE lib_first)
41 endfunction()