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:
parent
683e12d2f6
commit
eefc0ef616
107
CMakeLists.txt
107
CMakeLists.txt
@ -1,59 +1,74 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
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_package(catkin REQUIRED)
|
||||
|
||||
if(APPLE)
|
||||
find_library(IOKIT_LIBRARY IOKit)
|
||||
find_library(FOUNDATION_LIBRARY Foundation)
|
||||
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
|
||||
)
|
||||
# If Linux, add rt and pthread
|
||||
set(rt_LIBRARIES rt)
|
||||
set(pthread_LIBRARIES pthread)
|
||||
else()
|
||||
# Otherwise normal call
|
||||
catkin_package(
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
INCLUDE_DIRS include
|
||||
)
|
||||
# Otherwise normal call
|
||||
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 include/serial/v8stdint.h)
|
||||
if(APPLE)
|
||||
# If OSX
|
||||
list(APPEND serial_SRCS src/impl/unix.cc)
|
||||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc)
|
||||
# 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
|
||||
list(APPEND serial_SRCS src/impl/unix.cc)
|
||||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
|
||||
# If unix
|
||||
list(APPEND serial_SRCS src/impl/unix.cc)
|
||||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc)
|
||||
else()
|
||||
# If windows
|
||||
list(APPEND serial_SRCS src/impl/win.cc)
|
||||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc)
|
||||
# If windows
|
||||
list(APPEND serial_SRCS src/impl/win.cc)
|
||||
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc)
|
||||
endif()
|
||||
|
||||
## Add serial library
|
||||
add_library(${PROJECT_NAME} ${serial_SRCS})
|
||||
if(APPLE)
|
||||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
|
||||
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
|
||||
elseif(UNIX)
|
||||
target_link_libraries(${PROJECT_NAME} rt pthread)
|
||||
target_link_libraries(${PROJECT_NAME} rt pthread)
|
||||
else()
|
||||
target_link_libraries(${PROJECT_NAME} setupapi)
|
||||
target_link_libraries(${PROJECT_NAME} setupapi)
|
||||
endif()
|
||||
|
||||
## Uncomment for example
|
||||
@ -62,19 +77,27 @@ 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}
|
||||
)
|
||||
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
|
||||
|
||||
## Install headers
|
||||
install(FILES include/serial/serial.h include/serial/v8stdint.h
|
||||
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial)
|
||||
DESTINATION include/serial)
|
||||
|
||||
## Tests
|
||||
if(CATKIN_ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
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()
|
||||
|
||||
11
package.xml
11
package.xml
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<package>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<package format="2">
|
||||
<name>serial</name>
|
||||
<version>1.2.1</version>
|
||||
<description>
|
||||
@ -19,8 +19,13 @@
|
||||
<author email="wjwwood@gmail.com">William Woodall</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>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
</package>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user