# Revision history [back]

You can take a look at this example of one of my packages. Where I create a library "costmap2d" out of my source files costmap.cpp and cnmap.cpp then I share it in my workspace so i would be able to use it by other packages. here I assumed you lib depends on an example external lib named xxx.

cmake_minimum_required(VERSION 2.8.3)
project(costmap)

find_package(catkin REQUIRED COMPONENTS
geometry_msgs
nav_msgs
roscpp
std_msgs
tf
xxx
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES costmap2d
CATKIN_DEPENDS geometry_msgs nav_msgs roscpp std_msgs tf xxx
DEPENDS system_lib
)

include_directories(
${catkin_INCLUDE_DIRS} ) add_library(costmap2d include/${PROJECT_NAME}/costmap.cpp include/${PROJECT_NAME}/cnmap.cpp) target_link_libraries(costmap2d xxx${catkin_LIBRARIES}
)

install(TARGETS costmap2d
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION \${CATKIN_PACKAGE_BIN_DESTINATION}
)


note that here I am sharing this lib across the ws meaning that other packages of mine can also use it. if you just want to use if inside your package you don't need to install