-
Notifications
You must be signed in to change notification settings - Fork 38
Catkin Eclipse
This guide explains how to set up an Eclipse project for a single catkin package when using the catkin command line tools.
We first need to tweak Eclipse to recognize includes from the compilation commands and to properly recognize C++11 traits (if we are using C++11): Go to Window->Preferences->C/C++->Build->Settings and select the "Discovery" tab. In "CDT GCC Buid Output Parser [ Shared ]" prepend ".*" to the regular expressions, e.g.:
(.*gcc)|(.*[gc]\+\+)|(.*clang)
This will help Eclipse CDT recognize compiler calls that also contain the path to the compiler. Then, in "CDT GCC Built-in Compiler Settings [ Shared ]" add the "-std=c++11" flag to obtain e.g.:
${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"
Reminder: This guide is tailored to the catkin command line tools, which keep separate build directories for each package. Also, "package" does not include meta-packages (packages containing other packages and no source files of their own).
File->New->Project... , C/C++->"Makefile Project with Existing Code" , "Next", enter a name and browse to your package location in "Existing Code Location", hit Finish
Right-click the project and go to Properties->"C/C++ Build". In the "Builder Settings" Tab, change the "Build directory" to the folder corresponding to your package in the catkin build folder (typically ~/catkin_ws/build/<project name>). You may also want to check "Enable parallel build" in the "Behavior" tab. "Apply".
In "C/C++ Build"->Environment add a variable VERBOSE with value 1, add to all configurations. "Apply"
In "C/C++ General"->"Paths and Symbols", tab "Symbols", add __GXX_EXPERIMENTAL_CXX0X__ in "GNU C++" with no value, "Apply".
Go to "C/C++ General"->"Preprocessor Includes", "Providers" tab. Check "CDT GCC Build Output Parser" and "CDT GCC Built-in Compiler Settings" and verify that you "Use global provider shared between projects" in both. "Apply" and "OK".
Hitting Ctrl+B should now build your project. You should see a folder "Includes" appear in your project. If there is nothing to build, modify and save a file and re-build. Erroneous error messages should from now on disappear the more you build and the more project files you open.
At this point you should probably make sure that git ignores the eclipse configuration files. In your package, append to .gitignore (create if nonexistent):
.cproject
.project
.settings
In /usr/local/bin create a file "run-catkin-tests" with the following contents:
#!/bin/bash
source /opt/ros/hydro/setup.bash
make run_tests
Then, in your project properties, go to "C/C++ Build" and click "Manage Configurations". Add a configuration "Tests" that copies the settings from default. Switch to that configuration and under "Builder Settings" set your custom build command to "run-catkin-tests". In "Behaviour", disable the parallel build (if enabled). "Apply" and "OK".
You can now launch the unit tests by selecting "Tests" in the drop-down menu next to the hammer-shaped icon in the eclipse toolbar.