User Tools

Site Tools


neurali:ros_cmakelists.txt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

neurali:ros_cmakelists.txt [2018/04/25 07:55]
neurali:ros_cmakelists.txt [2020/06/08 22:20] (current)
Line 1: Line 1:
 +====== CMakeLists.txt ======
  
 +
 +Tramite [[neurali:ros catkin]] si può automatizzare la compilazione dei package.
 +
 +Il file CMakeLists.txt descrive le impostazioni di compilazione, e si può personalizzare.
 +
 +http://wiki.ros.org/catkin/CMakeLists.txt
 +
 +Anche in Python! http://docs.ros.org/api/catkin/html/howto/format2/installing_python.html
 +===== Struttura =====
 +
 +L'ordine delle voci è importante!
 +
 +<code>
 +cmake_minimum_required(VERSION 2.8.3)
 +project(node_del_package)
 +find_package(catkin REQUIRED COMPONENTS package_dip)
 +find_package(catkin REQUIRED COMPONENTS   roscpp  std_msgs)
 +find_package(Boost REQUIRED COMPONENTS thread) #if you wanted to use Boost threads
 +find_package(Qt REQUIRED COMPONENTS QtXml)
 +
 +catkin_package(
 +   INCLUDE_DIRS include
 +   LIBRARIES ${PROJECT_NAME}
 +   CATKIN_DEPENDS roscpp nodelet # sono package
 +   DEPENDS eigen opencv) # non sono package
 +   
 +include_directories(<dir1>, <dir2>, ..., <dirN>)
 +include_directories(include ${Boost_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
 +#improbabile link_directories(<dir1>, <dir2>, ..., <dirN>
 +
 +add_executable(myProgram src/main.cpp src/some_file.cpp src/another_file.cpp)
 +target_link_libraries(driver ${catkin_LIBRARIES}) # altre librerie da linkare. 
 +
 +#improbabile add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS})
 +target_link_libraries(myLib ${catkin_LIBRARIES}) 
 +
 +#output dir
 +set_target_properties(python_module_library
 +  PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION})
 +
 +  
 +</code>
 +
 +  * Required CMake Version (cmake_minimum_required)
 +  * Package Name (project())
 +  * Find other CMake/Catkin packages needed for build (find_package())
 +  * Message/Service/Action Generators (add_message_files(), add_service_files(), add_action_files())
 +  * Invoke message/service/action generation (generate_messages())
 +  * Specify package build info export (catkin_package())
 +  * Libraries/Executables to build (add_library()/add_executable()/target_link_libraries())
 +  * Tests to build (catkin_add_gtest())
 +  * Install rules (install())