Camera Display CMakeLists.txt

From wikidb
Revision as of 12:31, 9 August 2015 by Edc (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

cmake_minimum_required(VERSION 2.8.3) project(follow)

    1. Find catkin macros and libraries
    2. if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
    3. is used, also find other catkin packages

find_package(catkin REQUIRED COMPONENTS

 roscpp
 rospy
 std_msgs
 cv_bridge 
 genmsg 
 image_transport 
 sensor_msgs

)

    1. System dependencies are found with CMake's conventions
  1. find_package(Boost REQUIRED COMPONENTS system)


    1. Uncomment this if the package has a setup.py. This macro ensures
    2. modules and global scripts declared therein get installed
    3. See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
  1. catkin_python_setup()
    1. Declare ROS messages, services and actions ##
    1. To declare and build messages, services or actions from within this
    2. package, follow these steps:
    3. * Let MSG_DEP_SET be the set of packages whose message types you use in
    4. your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
    5. * In the file package.xml:
    6. * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
    7. * If MSG_DEP_SET isn't empty the following dependencies might have been
    8. pulled in transitively but can be declared for certainty nonetheless:
    9. * add a build_depend tag for "message_generation"
    10. * add a run_depend tag for "message_runtime"
    11. * In this file (CMakeLists.txt):
    12. * add "message_generation" and every package in MSG_DEP_SET to
    13. find_package(catkin REQUIRED COMPONENTS ...)
    14. * add "message_runtime" and every package in MSG_DEP_SET to
    15. catkin_package(CATKIN_DEPENDS ...)
    16. * uncomment the add_*_files sections below as needed
    17. and list every .msg/.srv/.action file to be processed
    18. * uncomment the generate_messages entry below
    19. * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
  1. add_message_files(DIRECTORY msg
  2. FILES ResizedImage.msg
  3. )
    1. Generate messages in the 'msg' folder
  1. add_message_files(
  2. FILES
  3. Message1.msg
  4. Message2.msg
  5. )
    1. Generate services in the 'srv' folder
  1. add_service_files(
  2. FILES
  3. Service1.srv
  4. Service2.srv
  5. )
    1. Generate actions in the 'action' folder
  1. add_action_files(
  2. FILES
  3. Action1.action
  4. Action2.action
  5. )
    1. Generate added messages and services with any dependencies listed here

generate_messages(

 DEPENDENCIES
 std_msgs

)

    1. catkin specific configuration ##
    2. The catkin_package macro generates cmake config files for your package
    3. Declare things to be passed to dependent projects
    4. INCLUDE_DIRS: uncomment this if you package contains header files
    5. LIBRARIES: libraries you create in this project that dependent projects also need
    6. CATKIN_DEPENDS: catkin_packages dependent projects also need
    7. DEPENDS: system dependencies of this project that dependent projects also need

catkin_package(

  1. INCLUDE_DIRS include
  2. LIBRARIES follow
  3. CATKIN_DEPENDS roscpp rospy std_msgs
  4. DEPENDS system_lib

)

find_package(OpenCV)

    1. Build ##
    1. Specify additional locations of header files
    2. Your package locations should be listed before other locations
  1. include_directories(include)

include_directories(

 ${catkin_INCLUDE_DIRS}

)

    1. Declare a cpp library
  1. add_library(follow
  2. src/${PROJECT_NAME}/follow.cpp
  3. )
    1. Declare a cpp executable
  1. add_executable(follow_node src/follow_node.cpp)
  2. add_executable(move_it_pid src/move_it_pid.cpp)

add_executable(move_it src/move_it.cpp)

    1. Add cmake target dependencies of the executable/library
    2. as an example, message headers may need to be generated before nodes
  1. add_dependencies(follow_node follow_generate_messages_cpp)
    1. Specify libraries to link a library or executable target against

target_link_libraries(move_it

 ${catkin_LIBRARIES}

)

add_executable(camera_display src/camera_display.cpp) target_link_libraries(camera_display

 ${catkin_LIBRARIES} 
 ${OpenCV_LIBRARIES}

)

add_executable(hough_tracker src/hough_tracker.cpp) target_link_libraries(hough_tracker

 ${catkin_LIBRARIES} 
 ${OpenCV_LIBRARIES}

)

    1. Install ##
  1. all install targets should use catkin DESTINATION variables
  2. See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
    1. Mark executable scripts (Python etc.) for installation
    2. in contrast to setup.py, you can choose the destination
  1. install(PROGRAMS
  2. scripts/my_python_script
  3. DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  4. )
    1. Mark executables and/or libraries for installation
  1. install(TARGETS follow follow_node
  2. ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  3. LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  4. RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  5. )
    1. Mark cpp header files for installation
  1. install(DIRECTORY include/${PROJECT_NAME}/
  2. DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  3. FILES_MATCHING PATTERN "*.h"
  4. PATTERN ".svn" EXCLUDE
  5. )
    1. Mark other files for installation (e.g. launch and bag files, etc.)
  1. install(FILES
  2. # myfile1
  3. # myfile2
  4. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  5. )
    1. Testing ##
    1. Add gtest based cpp test target and link libraries
  1. catkin_add_gtest(${PROJECT_NAME}-test test/test_follow.cpp)
  2. if(TARGET ${PROJECT_NAME}-test)
  3. target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
  4. endif()
    1. Add folders to be run by python nosetests
  1. catkin_add_nosetests(test)