Ask Your Question

Problems with findpackage in cmake

asked 2018-01-09 05:31:10 -0500

blightzyear gravatar image

updated 2018-01-10 12:30:09 -0500

clyde gravatar image

Hi there,

I am using CLion for Ros-MoveIt development. Now I want to compile a simple testprogram, but that does not work. My OS is Xubuntu 16.04. When I am adding

find_package(catkin REQUIRED COMPONENTS roscpp moveit_ros_planning_interface)

to my CMakeLists.txt this error occures:

CMake Error at CMakeLists.txt:5 (find_package):
  By not providing "Findcatkin.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "catkin", but
  CMake did not find one.

  Could not find a package configuration file provided by "catkin" with any
  of the following names:


  Add the installation prefix of "catkin" to CMAKE_PREFIX_PATH or set
  "catkin_DIR" to a directory containing one of the above files.  If "catkin"
  provides a separate development package or SDK, be sure it has been

Here is my simple source code:

#include <iostream>
#include <ros/ros.h>
#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>

using namespace std;
using namespace moveit;

int main()

//planning_interface::MoveGroup group("right_arm");
moveit::planning_interface::PlanningSceneInterface planning_scene_interface;

cout << "Test" << endl;

return 0;

catkin is installed on my system, I can compile another testprogram from the terminal.

Thx for helping :-)

YS, buzzzz

Edit Ok, meanwhile i get these errors:

    /home/myName/MyPrograms/apps/CLion/ch-0/172.4343.16/bin/cmake/bin/cmake --build /home/myName

    /ClionProjects/IKMoveIt --target IKMoveIt -- -j 2
    -- Boost version: 1.58.0
    -- Found the following Boost libraries:
    --   system
    --   filesystem
    --   thread
    --   chrono
    --   date_time
    --   atomic
    -- Using CATKIN_DEVEL_PREFIX: /home/myName/ClionProjects/IKMoveIt/devel
    -- Using CMAKE_PREFIX_PATH: 
    -- Using PYTHON_EXECUTABLE: /usr/bin/python
    -- Using Debian Python package layout
    -- Using empy: /usr/bin/empy
    -- Call enable_testing()
    -- Using CATKIN_TEST_RESULTS_DIR: /home/myName/ClionProjects/IKMoveIt/test_results
    -- Found gtest: gtests will be built
    -- Using Python nosetests: /usr/bin/nosetests-2.7
    -- catkin 0.7.8
    Traceback (most recent call last):
      File "/home/myName/ClionProjects/IKMoveIt/catkin_generated/", line 20, in <module>
        from catkin.environment_cache import generate_environment_script
    ImportError: No module named catkin.environment_cache
    CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
   returned error code 1

Any ideas?

edit retag flag offensive close merge delete


Did you source your ROS Environment? Do you build with catkin_make or catkin build?

mgruhler gravatar image mgruhler  ( 2018-01-09 07:32:21 -0500 )edit

What do you mean with source your ROS Environment? I have builded the testproject with catkin build. YS

blightzyear gravatar image blightzyear  ( 2018-01-09 07:39:41 -0500 )edit

Oh, do you mean the enviroment variables? I have on set them for the testproject...

blightzyear gravatar image blightzyear  ( 2018-01-09 07:49:27 -0500 )edit

Please provide additional Information by editing your question, not answering it.

mgruhler gravatar image mgruhler  ( 2018-01-09 09:38:28 -0500 )edit
mgruhler gravatar image mgruhler  ( 2018-01-09 09:41:24 -0500 )edit

echo $ROS_PACKAGE_PATH gives me that back... /opt/ros/kinetic/share I think this should be the right one...

blightzyear gravatar image blightzyear  ( 2018-01-09 09:49:01 -0500 )edit

It looks like you're trying to build w/ cmake, but the environment isn't set up correctly. For example, the catkin_generated directory should be in IKMoveIt/build, not IKMoveIt. Build with either catkin_make or catkin -- this will generate the correct structure.

clyde gravatar image clyde  ( 2018-01-09 10:39:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-01-09 17:20:08 -0500

ivaughn gravatar image

updated 2018-01-09 17:50:02 -0500

As has been mentioned in several of the comments, using CLion requires building with cmake directly rather than through Catkin. This is off the "garden path" for both CLion and Catkin, so user beware.

That being said.... we found a way that works for us. Usually. When the stars are aligned. From a clean checkout of your intended workspace:

  1. Run catkin_make like you normally would
  2. Run source devel/setup.bash to load the workspace's environment variables correctly. Also like would when regularly using catkin.
  3. Start CLion from the same terminal you just sourced that setup.bash in in order to start CLion with the right environment variables
  4. Import the workspace's src/CMakeLists.txt as an existing CMake project
  5. Under project settings, change
  6. Generation Path to ../build
  7. CMake options to -DCATKIN_DEVEL_PREFIX:PATH=/path/to/your/workspace_ws/devel

It's definitely dodgy though, and does not work well with the catkin tool at all. When in doubt, wipe your build and devel directories and start over using regular catkin_make outside of CLion. It helps to think of it like "making CLion load catkin projects" rather than "use CLion to build catkin projects."

Still, this technique does mostly work (as of Jan 2018) and CLion is a very powerful tool when hacking on ROS stuff.

For those interested, I created an issue with the CLion dev team and it was closed as a duplicate of: ... with a comment that "we have no plans to support ...etc"

There are many versions of this approach scattered around the Internet; this is just the one that seems to work for us, on Ubuntu 16.04 / ROS-Kinetic, this week.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-01-09 05:31:10 -0500

Seen: 3,235 times

Last updated: Jan 09 '18