[Error] in Exercise2.1 Unknown Cmake command

I have modified the CMake_Lists.txt file like this:

Compile and install cpp source file

add_executable(simple_publisher_node src/simple_topic_publisher)
ament_target_dependencies(simple_publisher_node rclcpp std_msgs)

but when I compiled the topic_publisher_pkg but failed, the error occurred as following :
CMake Error at CMakeLists.txt:12 (ament_target_dependencies):
** Unknown CMake command “ament_target_dependencies”.**

OK… I solved it.
we should put the ament_target_dependencies () behind the find_package()

2 Likes