mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Update CMakeList for ROS2
This commit is contained in:
parent
683e12d2f6
commit
64fad1f7c9
@ -1,8 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.3)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(serial)
|
project(serial)
|
||||||
|
|
||||||
|
## C++ compiler sets
|
||||||
|
|
||||||
|
# Default to C99
|
||||||
|
if(NOT CMAKE_C_STANDARD)
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Default to C++14
|
||||||
|
if(NOT CMAKE_CXX_STANDARD)
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find catkin
|
# Find catkin
|
||||||
find_package(catkin REQUIRED)
|
find_package(ament_cmake REQUIRED)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
find_library(IOKIT_LIBRARY IOKit)
|
find_library(IOKIT_LIBRARY IOKit)
|
||||||
@ -10,20 +26,8 @@ if(APPLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
# If Linux, add rt and pthread
|
find_library(pthread_LIBRARY pthread)
|
||||||
set(rt_LIBRARIES rt)
|
find_library(rt_LIBRARY 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()
|
endif()
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
@ -47,7 +51,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
## Add serial library
|
## Add serial library
|
||||||
add_library(${PROJECT_NAME} ${serial_SRCS})
|
add_library(${PROJECT_NAME} SHARED ${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)
|
||||||
@ -58,23 +62,37 @@ endif()
|
|||||||
|
|
||||||
## Uncomment for example
|
## Uncomment for example
|
||||||
add_executable(serial_example examples/serial_example.cc)
|
add_executable(serial_example examples/serial_example.cc)
|
||||||
add_dependencies(serial_example ${PROJECT_NAME})
|
#ament_target_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)
|
include_directories(include)
|
||||||
|
|
||||||
## 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
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
)
|
)
|
||||||
|
|
||||||
## 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 share/${PROJECT_NAME})
|
||||||
|
|
||||||
|
# Install executable
|
||||||
|
install(TARGETS serial_example
|
||||||
|
RUNTIME DESTINATION lib/${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
if(CATKIN_ENABLE_TESTING)
|
#if(BUILD_TESTING)
|
||||||
add_subdirectory(tests)
|
# add_subdirectory(tests)
|
||||||
endif()
|
#endif()
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
|
ament_package()
|
||||||
@ -23,4 +23,8 @@
|
|||||||
|
|
||||||
<test_depend>boost</test_depend>
|
<test_depend>boost</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
|
||||||
</package>
|
</package>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user