Catkinize

Update CMakeLists.txt configuration and install rules
Add package.xml
Add config.cmake.in
This commit is contained in:
Jacob Perron 2016-10-13 13:51:55 -07:00
parent 2297d1da08
commit 6b90694a84
4 changed files with 142 additions and 26 deletions

View file

@ -1,16 +1,28 @@
cmake_minimum_required(VERSION 2.8.3) # After installation this project can be found by 'find_package(... CONFIG)' command:
project(libcreate) #
# find_package(libcreate CONFIG REQUIRED)
# target_link_libraries(... libcreate::create)
#
# Reference for this file:
# https://github.com/forexample/package-example/blob/cf2ea1d6a209fb9eca2ab83fdd0ac15fe4d3e807/Foo/CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(libcreate VERSION 1.2.0)
find_package(Boost REQUIRED system thread) find_package(Boost REQUIRED system thread)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
## Specify additional locations of header files #########
# Build #
#########
# Specify locations of header files
include_directories( include_directories(
include include
) )
## Declare cpp library # Declare cpp library
add_library(create add_library(create SHARED
src/create.cpp src/create.cpp
src/serial.cpp src/serial.cpp
src/serial_stream.cpp src/serial_stream.cpp
@ -20,6 +32,15 @@ add_library(create
src/types.cpp src/types.cpp
) )
# Global includes. Used by all targets
# * header can be included by C++ code `#include <create/create.h>`
target_include_directories(
create PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
)
# Manually link to thread library for build on ARM
if(THREADS_HAVE_PTHREAD_ARG) if(THREADS_HAVE_PTHREAD_ARG)
set_property(TARGET create PROPERTY COMPILE_OPTIONS "-pthread") set_property(TARGET create PROPERTY COMPILE_OPTIONS "-pthread")
set_property(TARGET create PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") set_property(TARGET create PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
@ -29,16 +50,17 @@ if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(create "${CMAKE_THREAD_LIBS_INIT}") target_link_libraries(create "${CMAKE_THREAD_LIBS_INIT}")
endif() endif()
# Link to Boost
target_link_libraries(create target_link_libraries(create
${Boost_LIBRARIES} ${Boost_LIBRARIES}
) )
## Declare example executables # Declare example executables
add_executable(create_demo examples/create_demo.cpp) add_executable(create_demo examples/create_demo.cpp)
add_executable(bumper_example examples/bumper_example.cpp) add_executable(bumper_example examples/bumper_example.cpp)
add_executable(odom_example examples/odom_example.cpp) add_executable(odom_example examples/odom_example.cpp)
## Specify libraries to link a library or executable target against # Specify libraries to link executable targets against
target_link_libraries(create_demo target_link_libraries(create_demo
${Boost_LIBRARIES} ${Boost_LIBRARIES}
create create
@ -52,13 +74,78 @@ target_link_libraries(odom_example
create create
) )
## Install ###########
install(TARGETS create DESTINATION lib) # Install #
install(FILES ###########
include/create/create.h
include/create/serial.h # Layout. This works for all platforms:
include/create/types.h # * <prefix>/lib/cmake/<PROJECT-NAME>
include/create/data.h # * <prefix>/lib/
include/create/packet.h # * <prefix>/include/
include/create/util.h set(config_install_dir "lib/cmake/${PROJECT_NAME}")
DESTINATION include/create) set(include_install_dir "include")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}-config-version.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}-config.cmake")
set(targets_export_name "${PROJECT_NAME}-targets")
set(namespace "${PROJECT_NAME}::")
# Include module with function 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>-config-version.cmake'
write_basic_package_version_file(
"${version_config}"
COMPATIBILITY SameMajorVersion
)
# Configure '<PROJECT-NAME>-config.cmake'
# Use variables:
# * targets_export_name
# * PROJECT_NAME
configure_package_config_file(
"config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
# Install targets
install(
TARGETS create
EXPORT "${targets_export_name}"
ARCHIVE DESTINATION "lib"
LIBRARY DESTINATION "lib"
RUNTIME DESTINATION "bin"
INCLUDES DESTINATION "${include_install_dir}"
)
# Install headers
install(DIRECTORY include/create
DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
# Install config
# * <prefix>/lib/cmake/libcreate/libcreate-config.cmake
# * <prefix>/lib/cmake/libcreate/libcreate-config-version.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
# Install config
# * <prefix>/lib/cmake/libcreate/libcreate-targets.cmake
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
# Install package.xml (for catkin)
install(FILES package.xml
DESTINATION share/${PROJECT_NAME}
)

View file

@ -1,6 +1,6 @@
# libcreate # libcreate #
C++ library for interfacing with iRobot's [Create 1 and 2](http://www.irobot.com/About-iRobot/STEM/Create-2.aspx) as well as most models of Roombas. This library forms the basis of the ROS driver in [create_autonomy](https://github.com/autonomylab/create_autonomy). C++ library for interfacing with iRobot's [Create 1 and 2](http://www.irobot.com/About-iRobot/STEM/Create-2.aspx) as well as most models of Roomba. [create_autonomy](http://wiki.ros.org/create_autonomy) is a [ROS](http://www.ros.org/) wrapper for this library.
* Documentation: TODO * Documentation: TODO
* Code API: TODO * Code API: TODO
@ -11,28 +11,28 @@ C++ library for interfacing with iRobot's [Create 1 and 2](http://www.irobot.com
* Author: [Jacob Perron](http://jacobperron.ca) ([Autonomy Lab](http://autonomylab.org), [Simon Fraser University](http://www.sfu.ca)) * Author: [Jacob Perron](http://jacobperron.ca) ([Autonomy Lab](http://autonomylab.org), [Simon Fraser University](http://www.sfu.ca))
* Contributors: [Mani Monajjemi](http:mani.im), [Ben Wolsieffer](https://github.com/lopsided98) * Contributors: [Mani Monajjemi](http:mani.im), [Ben Wolsieffer](https://github.com/lopsided98)
## Dependencies ## Dependencies ##
* [Boost System Library](http://www.boost.org/doc/libs/1_59_0/libs/system/doc/index.html) * [Boost System Library](http://www.boost.org/doc/libs/1_59_0/libs/system/doc/index.html)
* [Boost Thread Library](http://www.boost.org/doc/libs/1_59_0/doc/html/thread.html) * [Boost Thread Library](http://www.boost.org/doc/libs/1_59_0/doc/html/thread.html)
## Install ## Install ##
* `cmake CMakeLists.txt` * `cmake CMakeLists.txt`
* `make` * `make`
* `sudo make install` * `sudo make install`
## Example ## Example ##
See source for examples. See source for examples.
Example compile line: `g++ create_demo.cpp -lcreate -lboost_system -lboost_thread` Example compile line: `g++ create_demo.cpp -lcreate -lboost_system -lboost_thread`
## Bugs ## Known issues ##
* _Clock_ and _Schedule_ button presses are not detected. This is a known problem to the developers at iRobot. * _Clock_ and _Schedule_ buttons are not functional. This is a known bug related to the firmware.
* Inaccurate odometry angle for Create 1 ([#22](https://github.com/AutonomyLab/libcreate/issues/22)) * Inaccurate odometry angle for Create 1 ([#22](https://github.com/AutonomyLab/libcreate/issues/22))
## Build Status ## Build Status ##
![Build Status](https://api.travis-ci.org/AutonomyLab/libcreate.svg?branch=master) ![Build Status](https://api.travis-ci.org/AutonomyLab/libcreate.svg?branch=master)

4
config.cmake.in Normal file
View file

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("@PROJECT_NAME@")

25
package.xml Normal file
View file

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<package>
<name>libcreate</name>
<version>1.2.0</version>
<description>C++ library for interfacing with iRobot's Create 1 and Create 2</description>
<maintainer email="jperron@sfu.ca">Jacob Perron</maintainer>
<license>BSD</license>
<url type="website">http://wiki.ros.org/libcreate</url>
<author email="jperron@sfu.ca">Jacob Perron</author>
<buildtool_depend>cmake</buildtool_depend>
<build_depend>boost</build_depend>
<run_depend>boost</run_depend>
<run_depend>catkin</run_depend>
<export>
<build_type>cmake</build_type>
</export>
</package>