ament / ament/ament_cmake

`ament_add_gtest_test` macro does not ensure `ament_cmake_test` is found

未关闭
#588 2 条评论 0 个 reaction 已指派 1 人 已被 @cottsay 认领 在 GitHub 查看
主要语言
CMake
星标
125
派生
147
PR 合并指标
30 天内没有已合并 PR

描述

I just wrote the following config

```cmake
# If ament_gtest is detected, make the tests visible in ROS 2.
find_package(ament_cmake_gtest QUIET)
if ( ament_cmake_gtest_FOUND )
ament_add_gtest_test(test_types)
endif()
```

When I try to build with this, I get the following error:

```
CMake Error at /opt/ros/rolling/share/ament_cmake_gtest/cmake/ament_add_gtest_test.cmake:95 (ament_add_test):
Unknown CMake command "ament_add_test".
Call Stack (most recent call first):
test/CMakeLists.txt:21 (ament_add_gtest_test)
```

It appears that the `ament_add_gtest_test` macro uses `ament_add_test` internally (see [here](https://github.com/ament/ament_cmake/blob/2338decc4f6edf043c953d3773d42cc9ff10974b/ament_cmake_gtest/cmake/ament_add_gtest_test.cmake#L95)), but nothing looks for a dependency on the `ament_cmake_test` package this comes from.

If I add this line

```cmake
find_package(ament_cmake_test REQUIRED)
```

to my config, things work as expected... but I think I shouldn't need to do that, right?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。