# Copyright (c) 2017, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 
# All rights reserved.
# 
# The Astrobee platform is licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

project(traj_opt_ros)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-deprecated-declarations  -Werror=return-type")


set(LIBS
  ${TRAJ_OPT_BASIC_LIBRARIES}
)
set(INCLUDES
  ${TRAJ_OPT_BASIC_INCLUDE_DIRS}
)
set(LIBRARIES traj_ros_bridge)
set(CAT_DEP roscpp)

set(TRAJ_OPT_ROS_INCLUDE_DIRS
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${INCLUDES}
  PARENT_SCOPE)
set(TRAJ_OPT_ROS_LIBRARIES ${LIBRARIES} ${LIBS} ${catkin_LIBRARIES} PARENT_SCOPE)

# build rviz plugin if not cross compiling
if(NOT USE_CTC)
  set(CMAKE_AUTOMOC ON)
  find_package(catkin COMPONENTS rviz QUIET)
  if(rviz_QT_VERSION)
    message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
    find_package(Qt5 ${rviz_QT_VERSION} REQUIRED Core Widgets)
    set(QT_LIBRARIES Qt5::Widgets)

    set(LIBRARIES ${LIBRARIES} traj_opt_ros)
    set(CAT_DEP ${CAT_DEP} rviz)
    set(LIBS ${LIBS} ${QT_LIBRARIES} ${rviz_DEFAULT_PLUGIN_LIBRARIES})
    set(INCLUDES ${INCLUDES} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
  endif()
endif()
find_package(catkin REQUIRED COMPONENTS ${CAT_DEP})


catkin_package(
  LIBRARIES ${LIBRARIES}
  DEPENDS traj_opt_basic traj_opt_msgs
  CATKIN_DEPENDS ${CAT_DEP}
)


create_library(TARGET traj_ros_bridge
  INC  ${INCLUDES} ${catkin_INCLUDE_DIRS}
  LIBS  ${LIBS} ${catkin_LIBRARIES}
  DEPS traj_opt_basic traj_opt_msgs
  ADD_SRCS  src/ros_bridge.cpp
)

if(NOT USE_CTC)
  if(rviz_QT_VERSION)
    create_library(TARGET traj_opt_ros
      INC  ${INCLUDES} ${catkin_INCLUDE_DIRS}
      LIBS  ${LIBS} ${catkin_LIBRARIES} traj_ros_bridge
      DEPS traj_opt_basic traj_ros_bridge
      ADD_SRCS  src/trajectory_visual.cpp src/trajectory_display.cpp ${MOC_FILES}
    )
endif()
endif()




