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

Merge ae46504ae7d4a199ea9bba0e73a6f083bf172f80 into 683e12d2f6a26c80bfa07f276845be618237ae5b

This commit is contained in:
Dan Rose 2020-09-08 17:45:21 +00:00 committed by GitHub
commit 2c6450976b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 59 deletions

View File

@ -1,80 +1,66 @@
cmake_minimum_required(VERSION 2.8.3) cmake_minimum_required(VERSION 3.5)
project(serial) project(serial)
# Find catkin find_package(ament_cmake REQUIRED)
find_package(catkin REQUIRED)
if(APPLE) ament_export_include_directories(include)
find_library(IOKIT_LIBRARY IOKit) ament_export_libraries(${PROJECT_NAME})
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
catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
)
endif()
## Sources ## Sources
set(serial_SRCS ## Add serial library
add_library(${PROJECT_NAME}
src/serial.cc src/serial.cc
include/serial/serial.h include/serial/serial.h
include/serial/v8stdint.h include/serial/v8stdint.h
) )
if(APPLE)
# If OSX if(APPLE) # macOS
list(APPEND serial_SRCS src/impl/unix.cc) find_library(IOKIT_LIBRARY IOKit)
list(APPEND serial_SRCS src/impl/list_ports/list_ports_osx.cc) find_library(FOUNDATION_LIBRARY Foundation)
elseif(UNIX) target_sources(${PROJECT_NAME} PRIVATE
# If unix src/impl/unix.cc
list(APPEND serial_SRCS src/impl/unix.cc) src/impl/list_ports/list_ports_osx.cc
list(APPEND serial_SRCS src/impl/list_ports/list_ports_linux.cc) )
else() target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
# If windows elseif(UNIX) # .*nix
list(APPEND serial_SRCS src/impl/win.cc) target_sources(${PROJECT_NAME} PRIVATE
list(APPEND serial_SRCS src/impl/list_ports/list_ports_win.cc) src/impl/unix.cc
src/impl/list_ports/list_ports_linux.cc
)
target_link_libraries(${PROJECT_NAME} rt pthread)
elseif(WIN32) # Windows
target_sources(${PROJECT_NAME} PRIVATE
src/impl/win.cc
src/impl/list_ports/list_ports_win.cc
)
target_link_libraries(${PROJECT_NAME} setupapi)
ament_export_libraries(setupapi)
endif() endif()
## Add serial 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()
## 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 headers
include_directories(include) target_include_directories(${PROJECT_NAME} PRIVATE include)
## Uncomment for example
# add_executable(serial_example examples/serial_example.cc)
# add_dependencies(serial_example ${PROJECT_NAME})
# target_link_libraries(serial_example ${PROJECT_NAME})
## Install executable ## Install executable
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} ARCHIVE DESTINATION lib
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION lib
) )
## 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_package()

View File

@ -19,8 +19,12 @@
<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>
</package> </package>