cmake_minimum_required(VERSION 2.8.3)
project(prbt_ikfast_manipulator_plugin)
add_compile_options(-std=c++11)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-unused-variable)
add_compile_options(-Werror)

find_package(catkin REQUIRED COMPONENTS
  moveit_core
  pluginlib
  roscpp
  tf_conversions
)

include_directories(${catkin_INCLUDE_DIRS})

catkin_package(
  LIBRARIES
  CATKIN_DEPENDS
    moveit_core
    pluginlib
    roscpp
    tf_conversions
)

include_directories(include)

set(IKFAST_LIBRARY_NAME prbt_manipulator_moveit_ikfast_plugin)

find_package(LAPACK REQUIRED)

add_library(${IKFAST_LIBRARY_NAME} src/prbt_manipulator_ikfast_moveit_plugin.cpp)
target_link_libraries(${IKFAST_LIBRARY_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES})

install(TARGETS ${IKFAST_LIBRARY_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

install(
  FILES
  prbt_manipulator_moveit_ikfast_plugin_description.xml
  DESTINATION
  ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

# unittest of ikfast plugin
if(CATKIN_ENABLE_TESTING)

  find_package(rostest REQUIRED)

  include_directories(include ${catkin_INCLUDE_DIR})

  add_rostest_gtest(unittest_prbt_ikfast_manipulator_plugin
    test/unittests/tst_prbt_ikfast_manipulator_plugin.test
    test/unittests/tst_prbt_ikfast_manipulator_plugin.cpp
  )

  target_link_libraries(unittest_prbt_ikfast_manipulator_plugin ${catkin_LIBRARIES})
endif()
