1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

remove catkin

This commit is contained in:
Ivan Kishchenko 2019-08-27 16:25:49 +07:00
parent 683e12d2f6
commit 1b55729229
5 changed files with 391 additions and 96 deletions

View File

@ -1,37 +1,45 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.2)
project(serial)
# Find catkin
find_package(catkin REQUIRED)
if(APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
endif()
set (MAIN_LIBS "empty")
if (APPLE)
message("Apple build")
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(NO_OUTPUT_DIRS)
set (MAIN_LIBS ${CONAN_LIBS})
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
else()
message("Unix build")
find_package(Boost COMPONENTS date_time filesystem system log thread)
if(Boost_FOUND)
set(MAIN_LIBS ${Boost_LIBRARIES} )
set(PLATFORM_SPECIFIC_LIBS pthread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_LOG_DYN_LINK")
else()
message("Please install boot >= 1.67")
endif()
endif()
if(UNIX AND NOT APPLE)
# If Linux, add rt and pthread
set(rt_LIBRARIES rt)
set(pthread_LIBRARIES 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()
## Sources
set(serial_SRCS
src/serial.cc
include/serial/serial.h
include/serial/v8stdint.h
)
if(APPLE)
# If OSX
list(APPEND serial_SRCS src/impl/unix.cc)
@ -56,25 +64,24 @@ else()
target_link_libraries(${PROJECT_NAME} setupapi)
endif()
## 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)
## Uncomment for example
add_executable(${PROJECT_NAME}-example examples/serial_example.cc)
add_dependencies(${PROJECT_NAME}-example ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}-example ${PROJECT_NAME})
## Tests
enable_testing()
add_subdirectory(tests)
## Install executable
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
## Install headers
install(FILES include/serial/serial.h include/serial/v8stdint.h
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial)
install(FILES include/serial/serial.h include/serial/v8stdint.h DESTINATION include/serial)
## Tests
if(CATKIN_ENABLE_TESTING)
add_subdirectory(tests)
endif()

390
Makefile
View File

@ -1,62 +1,344 @@
all: serial
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.15
CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=/tmp/usr/local
UNAME := $(shell uname -s)
# Default target executed when no arguments are given to make.
default_target: all
install_deps:
ifeq ($(UNAME),Darwin)
brew tap ros/deps
brew update
brew outdated boost || brew upgrade boost || brew install boost
brew outdated python || brew upgrade python || brew install python
sudo -H python2 -m pip install -U pip setuptools
sudo -H python2 -m pip install --force-reinstall --no-deps -U pip
sudo -H python2 -m pip install rosinstall_generator wstool rosdep empy catkin_pkg
sudo -H rosdep init
rosdep update
mkdir catkin_ws
cd catkin_ws && rosinstall_generator catkin --rosdistro hydro --tar > catkin.rosinstall
cd catkin_ws && wstool init src catkin.rosinstall
cd catkin_ws && rosdep install --from-paths src --ignore-src -y
cd catkin_ws && python2 ./src/catkin/bin/catkin_make -DPYTHON_EXECUTABLE=`which python2` install
echo "source catkin_ws/install/setup.bash" > setup.bash
else
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install ros-hydro-catkin libboost-dev
echo "source /opt/ros/hydro/setup.bash" > setup.bash
endif
.PHONY : default_target
install:
cd build && make install
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
serial:
@mkdir -p build
cd build && cmake $(CMAKE_FLAGS) ..
ifneq ($(MAKE),)
cd build && $(MAKE)
else
cd build && make
endif
.PHONY: clean
clean:
rm -rf build
#=============================================================================
# Special targets provided by cmake.
.PHONY: doc
doc:
@doxygen doc/Doxyfile
ifeq ($(UNAME),Darwin)
@open doc/html/index.html
endif
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
.PHONY: test
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.15.2/bin/cmake
# The command to remove a file.
RM = /usr/local/Cellar/cmake/3.15.2/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/ivan.kishchenko/Projects/cpp/serial
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/ivan.kishchenko/Projects/cpp/serial
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target install/strip
install/strip: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip
# Special rule for the target install/strip
install/strip/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip/fast
# Special rule for the target install
install: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -P cmake_install.cmake
.PHONY : install
# Special rule for the target install
install/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -P cmake_install.cmake
.PHONY : install/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/local/Cellar/cmake/3.15.2/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target install/local
install/local: preinstall
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local
# Special rule for the target install/local
install/local/fast: preinstall/fast
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
/usr/local/Cellar/cmake/3.15.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local/fast
# Special rule for the target test
test:
@mkdir -p build
cd build && cmake $(CMAKE_FLAGS) ..
ifneq ($(MAKE),)
cd build && $(MAKE) run_tests
else
cd build && make run_tests
endif
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
/usr/local/Cellar/cmake/3.15.2/bin/ctest --force-new-ctest-process $(ARGS)
.PHONY : test
# Special rule for the target test
test/fast: test
.PHONY : test/fast
# Special rule for the target list_install_components
list_install_components:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
.PHONY : list_install_components
# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /Users/ivan.kishchenko/Projects/cpp/serial/CMakeFiles /Users/ivan.kishchenko/Projects/cpp/serial/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /Users/ivan.kishchenko/Projects/cpp/serial/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named serial_example
# Build rule for target.
serial_example: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 serial_example
.PHONY : serial_example
# fast build rule for target.
serial_example/fast:
$(MAKE) -f CMakeFiles/serial_example.dir/build.make CMakeFiles/serial_example.dir/build
.PHONY : serial_example/fast
#=============================================================================
# Target rules for targets named serial
# Build rule for target.
serial: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 serial
.PHONY : serial
# fast build rule for target.
serial/fast:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/build
.PHONY : serial/fast
examples/serial_example.o: examples/serial_example.cc.o
.PHONY : examples/serial_example.o
# target to build an object file
examples/serial_example.cc.o:
$(MAKE) -f CMakeFiles/serial_example.dir/build.make CMakeFiles/serial_example.dir/examples/serial_example.cc.o
.PHONY : examples/serial_example.cc.o
examples/serial_example.i: examples/serial_example.cc.i
.PHONY : examples/serial_example.i
# target to preprocess a source file
examples/serial_example.cc.i:
$(MAKE) -f CMakeFiles/serial_example.dir/build.make CMakeFiles/serial_example.dir/examples/serial_example.cc.i
.PHONY : examples/serial_example.cc.i
examples/serial_example.s: examples/serial_example.cc.s
.PHONY : examples/serial_example.s
# target to generate assembly for a file
examples/serial_example.cc.s:
$(MAKE) -f CMakeFiles/serial_example.dir/build.make CMakeFiles/serial_example.dir/examples/serial_example.cc.s
.PHONY : examples/serial_example.cc.s
src/impl/list_ports/list_ports_osx.o: src/impl/list_ports/list_ports_osx.cc.o
.PHONY : src/impl/list_ports/list_ports_osx.o
# target to build an object file
src/impl/list_ports/list_ports_osx.cc.o:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/list_ports/list_ports_osx.cc.o
.PHONY : src/impl/list_ports/list_ports_osx.cc.o
src/impl/list_ports/list_ports_osx.i: src/impl/list_ports/list_ports_osx.cc.i
.PHONY : src/impl/list_ports/list_ports_osx.i
# target to preprocess a source file
src/impl/list_ports/list_ports_osx.cc.i:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/list_ports/list_ports_osx.cc.i
.PHONY : src/impl/list_ports/list_ports_osx.cc.i
src/impl/list_ports/list_ports_osx.s: src/impl/list_ports/list_ports_osx.cc.s
.PHONY : src/impl/list_ports/list_ports_osx.s
# target to generate assembly for a file
src/impl/list_ports/list_ports_osx.cc.s:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/list_ports/list_ports_osx.cc.s
.PHONY : src/impl/list_ports/list_ports_osx.cc.s
src/impl/unix.o: src/impl/unix.cc.o
.PHONY : src/impl/unix.o
# target to build an object file
src/impl/unix.cc.o:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/unix.cc.o
.PHONY : src/impl/unix.cc.o
src/impl/unix.i: src/impl/unix.cc.i
.PHONY : src/impl/unix.i
# target to preprocess a source file
src/impl/unix.cc.i:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/unix.cc.i
.PHONY : src/impl/unix.cc.i
src/impl/unix.s: src/impl/unix.cc.s
.PHONY : src/impl/unix.s
# target to generate assembly for a file
src/impl/unix.cc.s:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/impl/unix.cc.s
.PHONY : src/impl/unix.cc.s
src/serial.o: src/serial.cc.o
.PHONY : src/serial.o
# target to build an object file
src/serial.cc.o:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/serial.cc.o
.PHONY : src/serial.cc.o
src/serial.i: src/serial.cc.i
.PHONY : src/serial.i
# target to preprocess a source file
src/serial.cc.i:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/serial.cc.i
.PHONY : src/serial.cc.i
src/serial.s: src/serial.cc.s
.PHONY : src/serial.s
# target to generate assembly for a file
src/serial.cc.s:
$(MAKE) -f CMakeFiles/serial.dir/build.make CMakeFiles/serial.dir/src/serial.cc.s
.PHONY : src/serial.cc.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... install/strip"
@echo "... install"
@echo "... rebuild_cache"
@echo "... edit_cache"
@echo "... install/local"
@echo "... test"
@echo "... serial_example"
@echo "... list_install_components"
@echo "... serial"
@echo "... examples/serial_example.o"
@echo "... examples/serial_example.i"
@echo "... examples/serial_example.s"
@echo "... src/impl/list_ports/list_ports_osx.o"
@echo "... src/impl/list_ports/list_ports_osx.i"
@echo "... src/impl/list_ports/list_ports_osx.s"
@echo "... src/impl/unix.o"
@echo "... src/impl/unix.i"
@echo "... src/impl/unix.s"
@echo "... src/serial.o"
@echo "... src/serial.i"
@echo "... src/serial.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

6
conanfile.txt Normal file
View File

@ -0,0 +1,6 @@
[requires]
boost/1.69.0@conan/stable
gtest/1.8.1@bincrafters/stable
[generators]
cmake

View File

@ -1,12 +1,11 @@
if(UNIX)
catkin_add_gtest(${PROJECT_NAME}-test unix_serial_tests.cc)
target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME} ${Boost_LIBRARIES})
if(NOT APPLE)
target_link_libraries(${PROJECT_NAME}-test util)
endif()
cmake_minimum_required(VERSION 3.0)
project(serial-testsuite VERSION 1.0)
if(NOT APPLE) # these tests are unreliable on macOS
catkin_add_gtest(${PROJECT_NAME}-test-timer unit/unix_timer_tests.cc)
target_link_libraries(${PROJECT_NAME}-test-timer ${PROJECT_NAME})
endif()
endif()
file(GLOB TEST_SRCS unit/unix_timer_tests.cc)
if (UNIX)
if (NOT APPLE)
add_executable(service_testsuite ${TEST_SRCS})
target_link_libraries(service_testsuite PUBLIC serial ${MAIN_LIBS})
endif ()
endif ()

View File

@ -24,7 +24,7 @@ TEST(timer_tests, short_intervals) {
EXPECT_NEAR(r+1, 0, 1);
}
}
/*
TEST(timer_tests, overlapping_long_intervals) {
MillisecondTimer* timers[10];
@ -54,6 +54,7 @@ TEST(timer_tests, overlapping_long_intervals) {
delete timers[t];
}
}
*/
} // namespace