Allow modern target_link_libraries with ament_cmake_gtest - #629
Conversation
As described in ament#405, the `ament_add_gtest()` and `ament_add_gtest_executable()` macros don't support subsequent calls to `target_link_libraries()` on the produced target with scope keywords (PRIVATE/PUBLIC/INTERFACE). Modern standards prefer to use scope keywords, so we should allow this. CMake requires that either _all_ or _no_ calls to `target_link_libraries()` for a given target use scope keywords ([CMP0023](https://cmake.org/cmake/help/latest/policy/CMP0023.html)), so for backwards compatibility to avoid breaking downstream packages, the old behaviour is kept as a default for now, with the ability to opt in to the new behaviour by passing in `LINKING_MODE SCOPED` to `ament_add_gtest()` and friends. Use of the old method will now emit a deprecation warning. After giving downstream users time to migrate, we can switch the default behaviour to `SCOPED` and eventually remove support for the unscoped behaviour. Signed-off-by: Nathan Wiebe Neufeldt <wn.nathan@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as
|
|
If you want to make the scoped mode the default, eventually (as stated in the warning), why not add something like |
@Zyrin I think the two approaches (single-value keyword or option) would be equivalent; either the default remains as I used a single-value keyword to indicate that only one of the two modes can be specified, but we could also just emit an error if the user specifies both the |
As described in #405, the
ament_add_gtest()andament_add_gtest_executable()macros don't support subsequent calls totarget_link_libraries()on the produced target with scope keywords (PRIVATE/PUBLIC/INTERFACE). Modern standards prefer to use scope keywords, so we should allow this.CMake requires that either all or no calls to
target_link_libraries()for a given target use scope keywords (CMP0023), so for backwards compatibility to avoid breaking downstream packages, the old behaviour is kept as a default for now, with the ability to opt in to the new behaviour by passing inLINKING_MODE SCOPEDtoament_add_gtest()and friends. Use of the old method will now emit a deprecation warning, like:Eventually, after giving downstream users time to migrate, we can switch the default behaviour to
SCOPED.See also #423.