cmake_minimum_required(VERSION 3.0.2)

# #####################################
# Build Toposens Sensor Library (TSL) beforehand
# #####################################

set(TSL_RELATIVE_PATH
  toposens-library/toposens_sensor_library
)

include_directories(
  ${TSL_RELATIVE_PATH}/include
)

add_subdirectory(${TSL_RELATIVE_PATH})

# #####################################
# ECHO Driver Project ##
# #####################################

project(toposens_echo_driver)

add_compile_options(-std=c++17 -Werror)

set(${PROJECT_NAME}_DEPS
  cmake_modules
  dynamic_reconfigure
  genmsg
  message_generation
  message_runtime
  roscpp
  std_msgs
  toposens_msgs
  tf
  tf2_ros
)

find_package(
  catkin REQUIRED COMPONENTS
  ${${PROJECT_NAME}_DEPS}
)

find_package(Boost REQUIRED COMPONENTS system)

# #####################################
# Config ##
# #####################################

generate_dynamic_reconfigure_options(
  cfg/EchoOneDriver.cfg
)

add_service_files(
  DIRECTORY srv
  FILES RequestAdcDump.srv
)

generate_messages(
  DEPENDENCIES std_msgs
)

# ######################################
# catkin specific configuration ##
# ######################################

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS ${${PROJECT_NAME}_DEPS}
)

# #####################################
# Build ##
# #####################################

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
  include
  ${Boost_INCLUDE_DIR}
  ${catkin_INCLUDE_DIRS}
)

add_subdirectory(src)

install(
  DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
install(
  DIRECTORY launch param
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
