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

Convert catkin to ament

This commit is contained in:
Zachary Michaels 2019-11-07 14:24:06 -08:00
parent 683e12d2f6
commit eefc0ef616
2 changed files with 73 additions and 45 deletions

View File

@ -1,59 +1,74 @@
cmake_minimum_required(VERSION 2.8.3) cmake_minimum_required(VERSION 3.5)
project(serial) project(serial)
# Add support for C++11
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
find_package(ament_cmake REQUIRED)
set(INCLUDE_DIRS include ${ament_cmake_INCLUDE_DIRS})
include_directories(${INCLUDE_DIRS})
set(LIBRARY_DIRS ${ament_cmake_LIBRARY_DIRS})
link_directories(${LIBRARY_DIRS})
set(LIBS ${ament_cmake_LIBRARIES})
# Add support for C++11
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
find_package(ament_cmake REQUIRED)
set(INCLUDE_DIRS include ${ament_cmake_INCLUDE_DIRS})
set(LIBRARY_DIRS ${ament_cmake_LIBRARY_DIRS})
set(LIBS ${ament_cmake_LIBRARIES})
# Find catkin # Find catkin
find_package(catkin REQUIRED)
if(APPLE) if(APPLE)
find_library(IOKIT_LIBRARY IOKit) find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation) find_library(FOUNDATION_LIBRARY Foundation)
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
# If Linux, add rt and pthread # If Linux, add rt and pthread
set(rt_LIBRARIES rt) set(rt_LIBRARIES rt)
set(pthread_LIBRARIES pthread) set(pthread_LIBRARIES pthread)
catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
DEPENDS rt pthread
)
else() else()
# Otherwise normal call # Otherwise normal call
catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
)
endif() endif()
## Sources ## Sources
set(serial_SRCS set(serial_SRCS src/serial.cc include/serial/serial.h include/serial/v8stdint.h)
src/serial.cc
include/serial/serial.h
include/serial/v8stdint.h
)
if(APPLE) if(APPLE)
# If OSX # If OSX
list(APPEND serial_SRCS src/impl/unix.cc) list(APPEND serial_SRCS src/impl/unix.cc)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc) list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
elseif(UNIX) elseif(UNIX)
# If unix # If unix
list(APPEND serial_SRCS src/impl/unix.cc) list(APPEND serial_SRCS src/impl/unix.cc)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc) list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
else() else()
# If windows # If windows
list(APPEND serial_SRCS src/impl/win.cc) list(APPEND serial_SRCS src/impl/win.cc)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc) list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc)
endif() endif()
## Add serial library ## Add serial library
add_library(${PROJECT_NAME} ${serial_SRCS}) add_library(${PROJECT_NAME} ${serial_SRCS})
if(APPLE) if(APPLE)
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
elseif(UNIX) elseif(UNIX)
target_link_libraries(${PROJECT_NAME} rt pthread) target_link_libraries(${PROJECT_NAME} rt pthread)
else() else()
target_link_libraries(${PROJECT_NAME} setupapi) target_link_libraries(${PROJECT_NAME} setupapi)
endif() endif()
## Uncomment for example ## Uncomment for example
@ -62,19 +77,27 @@ add_dependencies(serial_example ${PROJECT_NAME})
target_link_libraries(serial_example ${PROJECT_NAME}) target_link_libraries(serial_example ${PROJECT_NAME})
## Include headers ## Include headers
include_directories(include)
## Install executable ## Install executable
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
## Install headers ## Install headers
install(FILES include/serial/serial.h include/serial/v8stdint.h install(FILES include/serial/serial.h include/serial/v8stdint.h
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial) DESTINATION include/serial)
## Tests ## Tests
if(CATKIN_ENABLE_TESTING) if(BUILD_TESTING)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
ament_export_dependencies(ament_cmake)
ament_export_include_directories(${INCLUDE_DIRS})
ament_export_libraries(${PROJECT_NAME} ${LIBS})
ament_package()
ament_export_dependencies(ament_cmake)
ament_export_include_directories(${INCLUDE_DIRS})
ament_export_libraries(${PROJECT_NAME} ${LIBS})
ament_package()

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version='1.0' encoding='utf-8'?>
<package> <package format="2">
<name>serial</name> <name>serial</name>
<version>1.2.1</version> <version>1.2.1</version>
<description> <description>
@ -19,8 +19,13 @@
<author email="wjwwood@gmail.com">William Woodall</author> <author email="wjwwood@gmail.com">William Woodall</author>
<author email="ash.gti@gmail.com">John Harrison</author> <author email="ash.gti@gmail.com">John Harrison</author>
<buildtool_depend>catkin</buildtool_depend> <buildtool_depend>ament_cmake</buildtool_depend>
<test_depend>boost</test_depend> <test_depend>boost</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
<buildtool_depend>ament_cmake</buildtool_depend>
</package> </package>