Ask Your Question

ROS Kinetic 'catkin_make' fails because PROJECT_NAME is set to Project

asked 2019-07-08 16:33:55 -0600

jaquattro gravatar image

updated 2019-07-10 11:31:25 -0600

I have been using ROS Kinetic for a while,but I do not have very much experience with CMake. Today when I went to make a new catkin workspace following the ROS tutorials page ( I get a CMake Error stating that PROJECT_NAME is set to Project, which is invalid. I have never run into this issue with any of my other work spaces I have created.

I do not want to mess with toplevel.cmake out of fear of screwing up my other work spaces.

Any ideas why this is happening?

The error message:

CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake:91 (message):
  catkin_package() PROJECT_NAME is set to 'Project', which is not a valid
  project name.  You must call project() before calling catkin_package().

The CMakeLists.txt file:

# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake

cmake_minimum_required(VERSION 2.8.3)


# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
  # searching fot catkin resulted in an error
  string(REPLACE ";" " " _cmd_str "${_cmd}")
  message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")

# include catkin from workspace or via find_package()
if(_res EQUAL 0)
  set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
  # include all.cmake without add_subdirectory to let it operate in same scope
  include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)

  # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
  # or CMAKE_PREFIX_PATH from the environment

  # list of catkin workspaces
  set(catkin_search_path "")
  foreach(path ${CMAKE_PREFIX_PATH})
    if(EXISTS "${path}/.catkin")
      list(FIND catkin_search_path ${path} _index)
      if(_index EQUAL -1)
        list(APPEND catkin_search_path ${path})

  # search for catkin in all workspaces
  find_package(catkin QUIET
    PATHS ${catkin_search_path}

  if(NOT catkin_FOUND)
    message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS was sourced before.")


Thank you.

edit retag flag offensive close merge delete


As @Pulkit123 asks: please show the CMakeLists.txt of your ROS package.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-10 04:46:55 -0600 )edit

I edited the question to show the correct file. However it is a sym link to toplevel.cmake, so I think they are the same. Maybe that is the issue? I am new to cmake.

jaquattro gravatar image jaquattro  ( 2019-07-10 11:33:35 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-07-10 11:37:24 -0600

gvdhoorn gravatar image

updated 2019-07-10 14:49:49 -0600

So the CMakeLists.txt in the directory of your ROS package (ie: not the catkin_ws/src directory) is a symlink to /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake?

If yes: yes, that would be a problem.

Edit: Ok. One final check.

Open $HOME/.bashrc. Scroll to the end. Make sure there are no source lines that source any workspaces. Not even /opt/ros. If there are, comment them (#) then save the file.

Now open a new terminal and run this:

mkdir -p /tmp/abcd/catkin_ws/src
cd /tmp/abcd/catkin_ws
source /opt/ros/kinetic/setup.bash

Does that build successfully?

If it does, again open a new terminal, then:

mkdir -p /tmp/efgh/catkin_ws/src
cd /tmp/efgh/catkin_ws/src
source /opt/ros/kinetic/setup.bash
catkin_create_pkg bar_pkg roscpp
cd /tmp/efgh/catkin_ws

Finally, show us the output of:

sudo apt install -y tree
tree -L 2 /tmp/efgh/catkin_ws/src
edit flag offensive delete link more


Thank you! Now to figure out how this happened.

jaquattro gravatar image jaquattro  ( 2019-07-10 11:45:04 -0600 )edit

If you unlink the CMakeLists.txt in your package's root, things start working?

gvdhoorn gravatar image gvdhoorn  ( 2019-07-10 13:01:26 -0600 )edit

If I do that, then CMakeLists.txt gets deleted. Just to clarify, the CMakeLists.txt file in my new workspace is auto generated, and placed in src, when I run catkin_make in the top folder (catkin_ws directory for example). If I unlink and then rerun catkin_make, the same problem arises.

I am aware I could make my own CMakeLists.txt, but I am very confused why following the tutorial to make a new workspace is having this problem.

jaquattro gravatar image jaquattro  ( 2019-07-10 13:14:02 -0600 )edit

Apologies, I just realized you asked if it made a sym link to /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake. It is actually making a sym link to /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake.

jaquattro gravatar image jaquattro  ( 2019-07-10 13:16:10 -0600 )edit

Doesn't matter: the CMakeLists.txt of any ROS pkg should be an actual file, not a symlink to anything else.

If you create a new workspace, then source /opt/ros/kinetic/setup.bash and then in the src space of the new workspace run catkin_create_pkg foo_pkg roscpp, it (ie: foo_pkg) ends up with a CMakeLists.txt that is a symlink to some other file?

gvdhoorn gravatar image gvdhoorn  ( 2019-07-10 14:06:40 -0600 )edit

In which directory do you attempt to run catkin_make? In catkin_ws or in catkin_ws/src or in catkin_ws/src/foo_pkg/src?

gvdhoorn gravatar image gvdhoorn  ( 2019-07-10 14:07:52 -0600 )edit

I run it in catkin_ws per this example without making catkin_create_pkg foo_pkg roscpp. I just tried again after running catkin_create_pkg foo_pkg roscpp and I get the same problem when I run catkin_make in catkin_ws. Does it matter that I am calling it test_ws?

jaquattro gravatar image jaquattro  ( 2019-07-10 14:27:20 -0600 )edit

Running (after removing all the sourcing from my .bashrc)

mkdir -p /tmp/abcd/catkin_ws/src
cd /tmp/abcd/catkin_ws
source /opt/ros/kinetic/setup.bash

gives the same error. :(

jaquattro gravatar image jaquattro  ( 2019-07-10 14:42:30 -0600 )edit

answered 2019-07-08 23:54:28 -0600

Pulkit123 gravatar image

Try changing 'Project' to some another name and can you please show the CMakeLists.txt file for your project

edit flag offensive delete link more


Try changing 'Project' to some another name

the error message that OP shows suggests he should do that in /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake, which is a file he doesn't want to edit.

Where do you suggest OP changes "'Project' to some other name" exactly?

gvdhoorn gravatar image gvdhoorn  ( 2019-07-09 01:46:39 -0600 )edit

Thank you for your responses.

If I were to change the PROJECT_NAME in /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake, then wouldn't all future catkin work spaces I run catkin_make on be given that project name?

I have edited the question to include the cmake file.

jaquattro gravatar image jaquattro  ( 2019-07-09 15:38:33 -0600 )edit

You should not edit files in non-world-writable locations (ie: in /opt/ros), even if they are symlinked into your home directory.

That's why I asked @Pulkit123where exactly he recommends you edit 'Project'.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-09 15:42:51 -0600 )edit

I understand and can see now why this would be unwise.

jaquattro gravatar image jaquattro  ( 2019-07-09 15:53:11 -0600 )edit

Is this still a problem for you?

Does it also occur when you create a new workspace and try to build it? Make sure to not have the old workspace sourced.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-10 04:46:23 -0600 )edit

It does occur when I make a completely new workspace and try to build it. I did also get the error after removing any sourcing for other workspaces from my .bashrc file.

jaquattro gravatar image jaquattro  ( 2019-07-10 11:36:02 -0600 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2019-07-08 16:33:55 -0600

Seen: 734 times

Last updated: Jul 10 '19