-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downstream packaging patchset #231
base: main
Are you sure you want to change the base?
Changes from all commits
cb35d69
ed0e389
742555a
00cbd2c
c0e9292
e1dabd8
5f1ab38
94743a6
9662bf6
13ac389
2070f8a
a56c97e
a459c7c
ba8745b
7abad93
9dcca36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
version: 2 | ||
jobs: | ||
build-focal: | ||
docker: | ||
- image: circleci/buildpack-deps:focal-scm | ||
steps: | ||
- checkout | ||
- run: sudo apt install build-essential cmake libcppunit-dev doxygen graphviz | ||
- run: git clone https://github.com/google/googletest | ||
- run: mkdir googletest/build; cd googletest/build; cmake .. | ||
- run: cd googletest/build; make; sudo make install | ||
- run: mkdir build | ||
- run: cd build && cmake -DDISABLE_CATKIN=ON .. | ||
- run: cd build && make && make test | ||
build-macos: | ||
macos: | ||
xcode: "10.0.0" | ||
steps: | ||
- checkout | ||
- restore-cache: | ||
keys: | ||
- 2020-09-29-v1 | ||
- run: brew update | ||
- run: brew upgrade git | ||
- run: > | ||
for p in llvm cmake cppunit doxygen; do | ||
brew list --version $p || brew install $p; | ||
brew link $p; | ||
done | ||
- run: > | ||
brew list --version graphviz | ||
|| brew install graphviz || brew install graphviz || :; | ||
brew link graphviz | ||
- run: git clone https://github.com/google/googletest | ||
- run: mkdir googletest/build; cd googletest/build; cmake .. | ||
- run: cd googletest/build; make; sudo make install | ||
- save-cache: | ||
key: 2020-09-29-v1 | ||
paths: | ||
- /usr/local/Homebrew | ||
- /usr/local/Cellar | ||
- run: mkdir build | ||
- run: > | ||
cd build && cmake | ||
-DDISABLE_CATKIN=ON | ||
-DENABLE_CATKIN_TESTING=ON | ||
.. | ||
- run: cd build && make | ||
- run: cd build && ARGS="--verbose" make test | ||
|
||
|
||
workflows: | ||
version: 2 | ||
build_all: | ||
jobs: | ||
- build-focal: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
- build | ||
- build-macos: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
- build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,52 @@ | ||
os: | ||
- linux | ||
- osx | ||
--- | ||
language: cpp | ||
install: | ||
- make install_deps | ||
- source setup.bash | ||
script: | ||
- mkdir build && cd build && cmake .. -DPYTHON_EXECUTABLE=$(which python2) && make && make tests && make run_tests | ||
- catkin_test_results . | ||
matrix: | ||
include: | ||
- os: linux | ||
dist: focal | ||
compiler: gcc | ||
script: | ||
- sudo apt update | ||
- > | ||
sudo apt install | ||
build-essential cmake doxygen graphviz googletest libgtest-dev | ||
- mkdir build && cd build | ||
- cmake -DDISABLE_CATKIN=ON .. | ||
- make | ||
- make test | ||
- os: linux | ||
dist: xenial | ||
compiler: gcc | ||
script: | ||
- sudo apt update | ||
- > | ||
sudo apt install | ||
build-essential catkin cmake doxygen graphviz libgtest-dev | ||
- mkdir build && cd build | ||
- cmake -DDISABLE_CATKIN=OFF -DCATKIN_ENABLE_TESTING=OFF .. | ||
- make | ||
|
||
|
||
# Does not build, breaks in make install_deps. | ||
# - os: linux | ||
# dist: precise | ||
# compiler: gcc | ||
# install: | ||
# - make install_deps | ||
# - source setup.bash | ||
# script: | ||
# - mkdir build && cd build | ||
# - cmake -DPYTHON_EXECUTABLE=$(which python2) .. | ||
# - make | ||
# - make test | ||
|
||
# - os: osx | ||
# compiler: clang | ||
# install: | ||
# - make install_deps | ||
# - source setup.bash | ||
# script: | ||
# - mkdir build && cd build | ||
# - cmake -DPYTHON_EXECUTABLE=$(which python2) .. | ||
# - make | ||
# - make run_tests |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,150 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(serial) | ||
cmake_minimum_required(VERSION 3.5.0) | ||
|
||
# Find catkin | ||
find_package(catkin REQUIRED) | ||
# Public options and command line configuration | ||
option(ENABLE_TEST_PROGRAM "Build test program" OFF) | ||
option(CATKIN_ENABLE_TESTING "Enable catkin unit tests" ON) | ||
|
||
if(APPLE) | ||
find_library(IOKIT_LIBRARY IOKit) | ||
find_library(FOUNDATION_LIBRARY Foundation) | ||
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 | ||
option(USE_CXX_SERIAL "build package name cxx-serial" OFF) | ||
if (USE_CXX_SERIAL) | ||
set(PKG_NAME cxx-serial) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not renaming this library as wjwserial? This remove useless clashes and make the cmakelist simpler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because renaming the library basically means to fork it, and this is not what I intend to do. |
||
else () | ||
set(PKG_NAME serial) | ||
endif () | ||
message(STATUS "Building package ${PKG_NAME}") | ||
|
||
set(SERIAL_DOCDIR ${CMAKE_INSTALL_PREFIX}/share/doc/${PKG_NAME} | ||
CACHE STRING "Installation root for doxygen docs." | ||
) | ||
option(DISABLE_CATKIN "Disable build of catkin package and tests" OFF) | ||
if (DISABLE_CATKIN AND "${CATKIN_ENABLE_TESTING}" STREQUAL "" ) | ||
set(CATKIN_ENABLE_TESTING OFF) | ||
endif () | ||
|
||
set(PROJ_SOVERSION 1) | ||
project(${PKG_NAME} | ||
VERSION 1.2.1 | ||
DESCRIPTION "Cross-platform, Serial Port library written in C++" | ||
HOMEPAGE_URL "http://wjwwood.io/serial/" | ||
) | ||
include(GNUInstallDirs) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
# Locate packages, headers and libraries | ||
if (NOT DISABLE_CATKIN) | ||
find_package(catkin REQUIRED) | ||
endif () | ||
|
||
find_path(HAVE_STDINT_H NAMES stdint.h) | ||
|
||
if (NOT DISABLE_CATKIN) | ||
# Build the catkin library | ||
find_library(PTHREAD_LIB NAMES pthread REQUIRED) | ||
if (PTHREAD_LIB) | ||
set(PTHREAD_LIBRARIES ${PTHREAD_LIB}) | ||
endif () | ||
find_package(Rt) | ||
if (RT_FOUND) | ||
set(_RT RT) | ||
endif () | ||
configure_file(package.xml.in ${PROJECT_SOURCE_DIR}/package.xml @ONLY) | ||
catkin_package( | ||
LIBRARIES ${PROJECT_NAME} | ||
INCLUDE_DIRS include | ||
DEPENDS ${_RT} PTHREAD | ||
) | ||
endif() | ||
set(CMAKE_INSTALL_LIBDIR ${CATKIN_PACKAGE_LIB_DESTINATION}) | ||
set(CMAKE_INSTALL_BINDIR ${CATKIN_GLOBAL_BIN_DESTINATION}) | ||
set(CMAKE_INSTALL_INCLUDEDIR ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) | ||
endif () | ||
|
||
## Sources | ||
set(serial_SRCS | ||
src/serial.cc | ||
include/serial/serial.h | ||
include/serial/v8stdint.h | ||
) | ||
set(serial_SRCS src/serial.cc include/serial/serial.h) | ||
if (NOT HAVE_STDINT_H) | ||
list(APPEND serial_SRCS include/serial/v8stdint.h) | ||
endif () | ||
|
||
if(APPLE) | ||
# If OSX | ||
list(APPEND serial_SRCS src/impl/unix.cc) | ||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc) | ||
elseif(UNIX) | ||
# If unix | ||
# linux | ||
list(APPEND serial_SRCS src/impl/unix.cc) | ||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc) | ||
else() | ||
# If windows | ||
# win32 | ||
list(APPEND serial_SRCS src/impl/win.cc) | ||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc) | ||
endif() | ||
|
||
## Add serial library | ||
set(serial_HEADERS include/serial/serial.h) | ||
if (NOT HAVE_STDINT_H) | ||
list(APPEND serial_HEADERS include/serial/v8stdint.h) | ||
endif () | ||
|
||
# Build and link main library | ||
add_library(${PROJECT_NAME} ${serial_SRCS}) | ||
if(APPLE) | ||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) | ||
elseif(UNIX) | ||
target_link_libraries(${PROJECT_NAME} rt pthread) | ||
else() | ||
target_link_libraries(${PROJECT_NAME} setupapi) | ||
endif() | ||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJ_SOVERSION} | ||
PUBLIC_HEADER "${serial_HEADERS}" | ||
) | ||
target_include_directories(${PROJECT_NAME} PUBLIC include) | ||
if (HAVE_STDINT_H) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE -DHAVE_STDINT_H) | ||
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}) | ||
if (APPLE) | ||
find_library(IOKIT_LIB IOKit) | ||
find_library(FOUNDATION_LIB Foundation) | ||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIB} ${IOKIT_LIB}) | ||
elseif (UNIX) | ||
target_link_libraries(${PROJECT_NAME} ${RT_LIBRARIES} ${PTHREAD_LIBRARIES}) | ||
else () | ||
target_link_libraries(${PROJECT_NAME} setupapi) | ||
endif () | ||
|
||
## Include headers | ||
include_directories(include) | ||
|
||
## Install executable | ||
## Install main library, possibly the catkin one. | ||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
) | ||
|
||
## Install headers | ||
install(FILES include/serial/serial.h include/serial/v8stdint.h | ||
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) | ||
|
||
## Tests | ||
if(CATKIN_ENABLE_TESTING) | ||
# Other targets: test program, pkg-config and tests. | ||
if (CATKIN_ENABLE_TESTING) | ||
include(CTest) | ||
find_package(GTest REQUIRED) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
if (DISABLE_CATKIN) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this has been if'ed on CATKINS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it can be built without the catkins dependency. |
||
configure_file(serial.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) | ||
install( | ||
FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
) | ||
endif() | ||
|
||
if (ENABLE_TEST_PROGRAM) | ||
add_executable(serial_example examples/serial_example.cc) | ||
add_dependencies(serial_example ${PROJECT_NAME}) | ||
target_link_libraries(serial_example ${PROJECT_NAME}) | ||
endif() | ||
|
||
find_package(Doxygen) | ||
if (DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND) | ||
set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile) | ||
add_custom_target(doc ALL | ||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMENT "Generating API documentation with Doxygen" | ||
VERBATIM | ||
) | ||
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html | ||
DESTINATION ${SERIAL_DOCDIR} | ||
) | ||
endif () |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Try to find real time libraries | ||
# Once done, this will define | ||
# | ||
# RT_FOUND - system has rt library | ||
# RT_LIBRARIES - rt libraries directory | ||
|
||
if(RT_LIBRARIES) | ||
set(RT_FIND_QUIETLY TRUE) | ||
endif(RT_LIBRARIES) | ||
|
||
find_library(RT_LIBRARY rt) | ||
set(RT_LIBRARIES ${RT_LIBRARY}) | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set | ||
# RT_FOUND to TRUE if all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Rt DEFAULT_MSG RT_LIBRARY) | ||
|
||
mark_as_advanced(RT_LIBRARY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefix all options using SERIAL_ so it can be properly regrouped in cmake GUI. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late to the party... but really no opinion about it, I never use the GUI...