cmake_minimum_required(VERSION 2.8.3)
project(robot_control)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
FIND_PACKAGE(Protobuf REQUIRED)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages


catkin_package(
)
find_package(catkin REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        tf
        nav_msgs
        )

aux_source_directory(src/can_card/can CAN_SRC )
aux_source_directory(src/can_card/can_SDK CAN_SDK )
aux_source_directory(src/can_card/error_code ERROR_SRC )
aux_source_directory(src/can_card/tool TOOL_SRC )
aux_source_directory(src/can_card/communication_can COMMUNICATION_CAN_SRC )
aux_source_directory(src/can_card/motor MOTOR_SRC )

#aux_source_directory(src/cifx CIFX_SRC)
#MESSAGE(WARN "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n${CIFX_SRC}")

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
  #/usr/local/include/cifx
  #${CIFX_SRC}
  ${CAN_SRC}
  ${CAN_SDK}
  ${ERROR_SRC}
  ${TOOL_SRC}
  ${COMMUNICATION_CAN_SRC}
  ${MOTOR_SRC}
  ${PROTOBUF_INCLUDE_DIRS}
)

#if(CIFX_HEADER OR CIFX_INC_LIB)
#    set(LIBCIFX_INCLUDE_DIRS  ${CIFX_HEADER})
#    set(LIBCIFX_LIBRARIES "-pthread -lrt -lcifx -L${CIFX_INC_LIB}")
#else(CIFX_HEADER OR CIFX_INC_LIB)
#    include(FindPkgConfig)
#    pkg_check_modules(LIBCIFX REQUIRED cifx)
#endif(CIFX_HEADER OR CIFX_INC_LIB)

# cifx 通信卡
#add_executable(${PROJECT_NAME}_node src/robot_control_node.cpp src/Agv_card.cpp ${CIFX_SRC})
#link_directories("/usr/local/lib")
#target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES}) ${LIBCIFX_LIBRARIES})

# 小乌龟
# add_executable(${PROJECT_NAME}_node src/robot_control_node.cpp src/turtle_robot.h)
# link_directories("/usr/local/lib")
# target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES})

# CAN通信
add_executable(${PROJECT_NAME}_node src/robot_control_node.cpp src/Agv_card.cpp   
      ${CAN_SRC}
      ${CAN_SDK}
      ${ERROR_SRC}
      ${TOOL_SRC}
      ${COMMUNICATION_CAN_SRC}
      ${MOTOR_SRC})

link_directories("/usr/local/lib")
target_link_libraries(${PROJECT_NAME}_node 
      ${catkin_LIBRARIES} 
      -lpthread 
      ${PROTOBUF_LIBRARIES}
      /usr/local/lib/libglog.a
      /usr/local/lib/libgflags.a
      /home/youchen/extra_space/agv_200731/src/robot_control/src/can_card/can_SDK/libcontrolcan.so
      )