ros的catkin_ws/src的CMakeList.txt原文件

ros的catkin_ws/src的CMakeList.txt原文件

不知道有没有人跟我一样不小心把catkin_ws/src的CMakeLists.txt文件改掉导致出现以下错误的。

CMake Error: File /home/weiwie/catkin_ws/src/package.xml does not exist.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/stamp.cmake:10 (configure_file):
....
....
....
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkin_package.cmake:116 (message):
catkin_package() 'catkin' must be listed as a buildtool dependency in the
  package.xml

因为网络上找不到这一个文件,所以我就自己又重新下载了一遍ros,并且把它备份下来,希望对那些不小心修改了该文件的人有所帮助。

下面便是ros的catkin_ws/src的CMakeList.txt文件原先的代码:

也是/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake的代码

因为这两个的是动态链接来的,修改一个另一个也会被更改,而且如果你修改了你的那个主CMakeLists.txt文件的话,你的下一个工作空间也会一直用已经修改的那个文件的代码,导致无法挽回的错误。

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

cmake_minimum_required(VERSION 2.8.3)

set(CATKIN_TOPLEVEL TRUE)

# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
  RESULT_VARIABLE _res
  OUTPUT_VARIABLE _out
  ERROR_VARIABLE _err
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_STRIP_TRAILING_WHITESPACE
)
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}")
endif()

# 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)
  add_subdirectory("${_out}")

else()
  # use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
  # or CMAKE_PREFIX_PATH from the environment
  if(NOT DEFINED CMAKE_PREFIX_PATH)
    if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
      string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
    endif()
  endif()

  # 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})
      endif()
    endif()
  endforeach()

  # search for catkin in all workspaces
  set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
  find_package(catkin QUIET
    NO_POLICY_SCOPE
    PATHS ${catkin_search_path}
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  unset(CATKIN_TOPLEVEL_FIND_PACKAGE)

  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 setup.sh was sourced before.")
  endif()
endif()

catkin_workspace()

你可能感兴趣的:(ros笔记)