cmake_minimum_required(VERSION 3.0.2)
project(moveit_planners_srmp)

## Compile as C++17
add_compile_options(-std=c++17)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
  moveit_msgs
  dynamic_reconfigure
  moveit_core
  moveit_ros_planning
  moveit_ros_planning_interface
  roscpp rospy
  std_msgs
  eigen_conversions
)

## Find required packages
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED)
find_package(PkgConfig REQUIRED)

# Find the installed manipulation_planning package
find_package(manipulation_planning REQUIRED)

# Find the installed search library
find_package(search REQUIRED)

## System dependencies are found with CMake's conventions
find_package(PkgConfig REQUIRED)
pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)

###################################
## catkin specific configuration ##
###################################
catkin_package(
  INCLUDE_DIRS
    include
  LIBRARIES
    moveit_planners_srmp
  CATKIN_DEPENDS
    moveit_msgs
    dynamic_reconfigure
    moveit_core
    moveit_ros_planning
    moveit_ros_planning_interface
    roscpp rospy
    std_msgs
    eigen_conversions
  DEPENDS
    EIGEN3
    Boost
    YAML_CPP
)

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

## Specify additional locations of header files
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIRS}
  ${YAML_CPP_INCLUDE_DIRS}
)

## Declare a C++ library
add_library(${PROJECT_NAME}
  src/srmp_interface.cpp
  src/srmp_planning_context.cpp
  src/srmp_planner_manager.cpp
  src/factories.cpp
)

## Add cmake target dependencies of the library
add_dependencies(${PROJECT_NAME}
  ${${PROJECT_NAME}_EXPORTED_TARGETS}
  ${catkin_EXPORTED_TARGETS}
)

## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
  ${manipulation_planning_LIBRARIES}
  ${search_LIBRARIES}
  ${eigen_LIBRARIES}
  ${Boost_LIBRARIES}
  ${YAML_CPP_LIBRARIES}
)

#############
## Install ##
#############

# Install plugin description file
install(FILES srmp_interface_plugin_description.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

# Install launch files
install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
  FILES_MATCHING PATTERN "*.launch"
)

# Install config files
install(DIRECTORY config/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
  FILES_MATCHING PATTERN "*.yaml"
)

# Install include files
install(DIRECTORY include/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.hpp"
  PATTERN ".svn" EXCLUDE
)

#############
## Testing ##
#############

