From 7174d62e1b7fa3e4a9f36855a161280edc580f80 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Tue, 23 Oct 2012 23:47:11 -0700 Subject: [PATCH] Adding catkin build files and a new Makefile. --- CMakeLists.txt | 73 +++++++++++++++++++++++++++++++++++++------------- Makefile | 40 ++++++++++++++++++++++++--- package.xml | 23 ++++++++++++++++ 3 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 package.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 5140966..c78c314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,58 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 2.8.3) +project(serial) -set(ROS_ROOT $ENV{ROS_ROOT}) +# Find catkin +find_package(catkin REQUIRED) -if(DEFINED ROS_ROOT) - option(SERIAL_BUILD_WIHOUT_ROS "Build without ROS?" OFF) -else(DEFINED ROS_ROOT) - option(SERIAL_BUILD_WIHOUT_ROS "Build without ROS?" ON) -endif(DEFINED ROS_ROOT) +if(UNIX AND NOT APPLE) + # If Linux, add rt and pthread + catkin_package( + LIBRARIES ${PROJECT_NAME} + INCLUDE_DIRS include + DEPENDS rt pthread + ) +else () + # Otherwise normal call + catkin_package( + LIBRARIES ${PROJECT_NAME} + INCLUDE_DIRS include + ) +endif () -if(DEFINED ROS_ROOT AND NOT SERIAL_BUILD_WIHOUT_ROS) - # Build with ROS - include(serial_ros.cmake) - message("Building with ROS") - build_serial() -else(DEFINED ROS_ROOT AND NOT SERIAL_BUILD_WIHOUT_ROS) - # Build normally - include(serial.cmake) - message("Building stand alone") - build_serial() -endif(DEFINED ROS_ROOT AND NOT SERIAL_BUILD_WIHOUT_ROS) +## Sources +set(serial_SRCS + src/serial.cc + # include/serial/serial.h + # include/serial/v8stdint.h +) +if (UNIX) + # If unix + list (APPEND serial_SRCS src/impl/unix.cc) +else() + # If windows + list (APPEND serial_SRCS src/impl/win.cc) +endif() + +## Add serial library +add_library(${PROJECT_NAME} + ${serial_SRCS} +) + +## Uncomment for example +add_executable(serial_example examples/serial_example.cc) +add_dependencies(serial_example ${PROJECT_NAME}) +target_link_libraries(serial_example ${PROJECT_NAME}) + +## Include headers +include_directories(include) + +## Install executable +install( + TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +) + +## Tests +catkin_add_gtest(${PROJECT_NAME}-test tests/serial_tests.cc) +target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) diff --git a/Makefile b/Makefile index 5df6eab..5816275 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,39 @@ -ifdef ROS_ROOT -include $(shell rospack find mk)/cmake.mk +all: serial + +CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=/tmp/usr/local + +install: + cd build && make install + +uninstall: + cd build && make uninstall + +serial: + @mkdir -p build + cd build && cmake $(CMAKE_FLAGS) .. +ifneq ($(MAKE),) + cd build && $(MAKE) else -include serial.makefile + cd build && make +endif + +.PHONY: clean +clean: + rm -rf build + +.PHONY: doc +doc: + @doxygen doc/Doxyfile +ifeq ($(UNAME),Darwin) + @open doc/html/index.html +endif + +.PHONY: test +test: + @mkdir -p build + cd build && cmake $(CMAKE_FLAGS) .. +ifneq ($(MAKE),) + cd build && $(MAKE) run_tests +else + cd build && make run_tests endif diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..e84b56f --- /dev/null +++ b/package.xml @@ -0,0 +1,23 @@ + + + serial + 1.1.0 + + Serial is a cross-platform, simple to use library for using serial ports on computers. This library provides a C++, object oriented interface for interacting with RS-232 like devices on Linux and Windows. + + + William Woodall + + BSD + + http://wjwwood.github.com/serial/ + https://github.com/wjwwood/serial + https://github.com/wjwwood/serial/issues + + William Woodall + John Harrison + + cmake + catkin + + \ No newline at end of file