CMakeLists.txt

Tramite 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!

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})