CMake/Tests/CMakeCommands
Brad King c1e812ad4f target_link_libraries: Improve tolerance of unquoted generator expressions
Prior to commit 1d709ea2f5 (cmGeneratorTarget: Propagate backtraces from
INTERFACE_LINK_LIBRARIES, 2021-12-15, v3.23.0-rc1~228^2), the value of
`INTERFACE_LINK_LIBRARIES` was a single string.  If an unquoted
generator expression passed to `target_link_libraries` contained `;` and
became multiple arguments, they would all accumulate as a single
`;`-separated list in the value of `INTERFACE_LINK_LIBRARIES`.  Since
that commit, each argument to `target_link_libraries` is placed in
`INTERFACE_LINK_LIBRARIES` as a separate entry, as has long been the
case for `LINK_LIBRARIES`. That behavior change broke projects that were
accidentally relying on accumulation in `INTERFACE_LINK_LIBRARIES` to
produce complete generator expressions containing `;`.

Teach `target_link_libraries` to accumulate consecutive non-keyword
arguments into a single entry before placing them in `LINK_LIBRARIES` or
`INTERFACE_LINK_LIBRARIES`.  For example, treat `a b c` as if they were
written as `"a;b;c"`.  This restores the previously accidental support
for unquoted generator expressions in `INTERFACE_LINK_LIBRARIES`, and
also enables it for `LINK_LIBRARIES`.

For now, do not drop the `target_link_libraries` documentation that
recommends quoting generator expressions.  Quoting is still important to
populate `LINK_LIBRARIES` in CMake 3.22 and below, and is also good
practice to keep generator expressions whole.

Fixes: #23203
2022-02-15 17:38:33 -05:00
..
add_compile_definitions Revise C++ coding style using clang-format-6.0 2018-06-01 09:53:42 -04:00
add_compile_options LCC: Add policy CMP0129 regarding interpreting LCC as GNU 2021-10-21 17:24:22 +03:00
add_link_options LINK_OPTIONS: Add new family of properties 2018-06-06 17:22:39 +02:00
link_directories link_directories(): enhance capabilities 2018-09-25 23:59:59 +10:00
target_compile_definitions Tests: Bump CMake minimum required in tests to 2.8.12 2020-12-23 08:55:45 -05:00
target_compile_features Features: Record C features for MSVC 2018-03-29 10:40:13 -04:00
target_compile_options IBMClang: Add support for IBM Open XL C/C++ 2022-01-27 09:38:01 -05:00
target_include_directories Tests: Bump CMake minimum required in tests to 2.8.12 2020-12-23 08:55:45 -05:00
target_link_directories Tests: Fix CMakeCommands.target_link_directories for regex chars in path 2021-11-16 11:19:47 -05:00
target_link_libraries target_link_libraries: Improve tolerance of unquoted generator expressions 2022-02-15 17:38:33 -05:00
target_link_options target_link_options: fix erroneous handling of BEFORE keyword. 2018-09-14 18:10:58 +02:00
target_sources target_sources: Interpret relative paths as relative to the calling directory 2018-06-18 21:01:57 +02:00