cmake_minimum_required(VERSION 3.8)
project(ir_camera)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(
  include
)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs)

add_executable(ir_camera_node src/ir_camera_node.cpp)

ament_target_dependencies(ir_camera_node
  rclcpp
  sensor_msgs
)

target_link_libraries(ir_camera_node
  iruvc
  irparse
  irtemp
  irprocess
  usb-1.0
  pthread
  m
)

# 运行时在 install/lib/ir_camera 中优先查找同目录下的第三方 so
set_target_properties(ir_camera_node PROPERTIES
  BUILD_RPATH "${CMAKE_CURRENT_SOURCE_DIR}/libs"
  INSTALL_RPATH "\$ORIGIN"
)

install(TARGETS ir_camera_node
  DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/
  DESTINATION include/
)

install(DIRECTORY libs/
  DESTINATION lib/${PROJECT_NAME}
  FILES_MATCHING PATTERN "*.so"
)

ament_package()

