|
| 1 | +cmake_minimum_required(VERSION 3.8) |
| 2 | +project(cserialport_wrapper) |
| 3 | + |
| 4 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 5 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 6 | +endif() |
| 7 | + |
| 8 | +set (CMAKE_CXX_STANDARD 20) |
| 9 | + |
| 10 | +# find dependencies |
| 11 | +find_package(ament_cmake REQUIRED) |
| 12 | +find_package(ament_cmake_auto REQUIRED) |
| 13 | +ament_auto_find_build_dependencies() |
| 14 | + |
| 15 | +set(CSerialPortRootPath "${CMAKE_CURRENT_SOURCE_DIR}/CSerialPort") |
| 16 | +list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPort.cpp ${CSerialPortRootPath}/src/SerialPortBase.cpp ${CSerialPortRootPath}/src/SerialPortInfo.cpp ${CSerialPortRootPath}/src/SerialPortInfoBase.cpp) |
| 17 | +list(APPEND CSerialPortSourceFiles ${CSerialPortRootPath}/src/SerialPortInfoUnixBase.cpp ${CSerialPortRootPath}/src/SerialPortUnixBase.cpp) |
| 18 | + |
| 19 | +ament_auto_add_library( ${PROJECT_NAME} SHARED ${CSerialPortSourceFiles}) |
| 20 | +target_include_directories(${PROJECT_NAME} PUBLIC ${CSerialPortRootPath}/include) |
| 21 | + |
| 22 | +# remove prefix |
| 23 | +# set_target_properties( ${PROJECT_NAME} PROPERTIES PREFIX "") |
| 24 | + |
| 25 | +# preprocessor definitions for compiling CSerialPort library |
| 26 | +# set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCSERIALPORT) |
| 27 | + |
| 28 | +ament_export_include_directories("${CSerialPortRootPath}/include") |
| 29 | +install( |
| 30 | + DIRECTORY ${CSerialPortRootPath}/include |
| 31 | + DESTINATION include |
| 32 | +) |
| 33 | + |
| 34 | +target_link_libraries( ${PROJECT_NAME} pthread) |
| 35 | + |
| 36 | +if(BUILD_TESTING) |
| 37 | + find_package(ament_lint_auto REQUIRED) |
| 38 | + # the following line skips the linter which checks for copyrights |
| 39 | + # comment the line when a copyright and license is added to all source files |
| 40 | + set(ament_cmake_copyright_FOUND TRUE) |
| 41 | + # the following line skips cpplint (only works in a git repo) |
| 42 | + # comment the line when this package is in a git repo and when |
| 43 | + # a copyright and license is added to all source files |
| 44 | + set(ament_cmake_cpplint_FOUND TRUE) |
| 45 | + ament_lint_auto_find_test_dependencies() |
| 46 | +endif() |
| 47 | + |
| 48 | +ament_auto_package() |
0 commit comments