ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Add files to project in CMakefile

asked 2013-10-22 09:46:03 -0500

dimonic gravatar image

updated 2014-01-28 17:18:19 -0500

ngrennan gravatar image

In the instructions, it is not clear how I edit the CMakefile.txt to add files to the project (http://wiki.ros.org/catkin/Tutorials/using_a_workspace)

$ cd ~/catkin_ws/src/beginner_tutorials/src

# Add/Edit source files

$ cd ~/catkin_ws/src/beginner_tutorials

# Update CMakeFiles.txt to reflect any changes to your sources

$ cd ~/catkin_ws

$ catkin_make 
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-23 05:10:25 -0500

Artem gravatar image

You have to be more specific. What files do you want to add? If it's a library that your code depend on then,

add_library(SOURCE_LIB src/some_lib_source.c)
target_link_libraries(SOURCE_LIB ${catkin_LIBRARIES})

now you can add SOURCE_LIB to link it with your code

target_link_libraries(your_node ${catkin_LIBRARIES} SOURCE_LIB)
edit flag offensive delete link more

Comments

Actually your answer illustrates part of the problem. I wanted to add another source file, but I assume the instructions would differ depending on the type of file that one wanted to add. Perahps that guide is assuming a level of understanding of cmake that is not "beginner"? BTW - I assumed (C++ programmer background) that a source file is source code, as in a cpp file. For now I am ignoring the packaging stuff and moving on with example_node, assuming that clarity will emerge later.

dimonic gravatar image dimonic  ( 2013-10-23 05:18:13 -0500 )edit

Yes, it would help if you had just a bit more of cmake understanding, such as by doing this tutorial (http://web.cs.swarthmore.edu/~adanner/tips/cmake.php). Some explanations also here: (http://wiki.ros.org/catkin/CMakeLists.txt)

KruseT gravatar image KruseT  ( 2013-10-23 06:01:53 -0500 )edit

And then there is the confusion caused by some tutorial examples using catkin and others using some other build technique (publisher subscriber with dynamic reconfigure example). Am I right in assuming that catkin is the way forward ?

dimonic gravatar image dimonic  ( 2013-10-23 06:27:53 -0500 )edit

@dimonic I would recommend using catkin, though it has a steeper learning curve than the old system (rosbuild) I think it would serve you best to learn that. Can you post a link to the tutorial that is out of date?

William gravatar image William  ( 2013-10-23 07:31:22 -0500 )edit

Thank you, I will use catkin going forward. The tutorial using rosbuild is here <http://wiki.ros.org/ROSNodeTutorialC%2B%2B> (at least I think it uses rosbuild - it lacks a package.xml file).

dimonic gravatar image dimonic  ( 2013-10-23 07:39:03 -0500 )edit

Question Tools

Stats

Asked: 2013-10-22 09:46:03 -0500

Seen: 934 times

Last updated: Oct 23 '13