project(measure_wj_proj)

cmake_minimum_required(VERSION 3.5)

set (CMAKE_CXX_STANDARD 14)
set(CMAKE_BUILD_TYPE "Release")

# set(PCL_DIR "/home/youchen/pcl-1.8/share/pcl-1.8")
#nanomsg
find_package(PkgConfig REQUIRED)
pkg_check_modules(nanomsg REQUIRED nanomsg)

#yaml
pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
find_path(YAML_CPP_INCLUDE_DIR
          NAMES yaml_cpp.h
          PATHS ${YAML_CPP_INCLUDE_DIRS})
find_library(YAML_CPP_LIBRARY
             NAMES YAML_CPP
             PATHS ${YAML_CPP_LIBRARY_DIRS})
link_directories(${YAML_CPP_LIBRARY_DIRS})
if(NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")
  add_definitions(-DHAVE_NEW_YAMLCPP)
endif(NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")

# MESSAGE(WARNING ${YAML_CPP_VERSION}    ${YAML_CPP_INCLUDE_DIRS}     ${YAML_CPP_LIBRARY_DIRS}) 

#other libs
FIND_PACKAGE(Protobuf REQUIRED)
# FIND_PACKAGE(Glog REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(PCL REQUIRED)
FIND_PACKAGE(Ceres REQUIRED)

add_subdirectory(${PROJECT_SOURCE_DIR}/rslidar/rs_driver)
find_package(rs_driver REQUIRED)

MESSAGE(WARN "pcl:: ${PCL_INCLUDE_DIRS} --- ${PCL_LIBRARIES}")
include_directories(
        /usr/local/include
        ${PCL_INCLUDE_DIRS}
        ${OpenCV_INCLUDE_DIRS}
        ${PROTOBUF_INCLUDE_DIRS}
    ${CERES_INCLUDE_DIRS}
    ${rs_driver_INCLUDE_DIRS}
        communication
        message
        error_code
        tool
	system
)
link_directories("/usr/local/lib")

message(STATUS ${EXECUTABLE_OUTPUT_PATH})


aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/error_code ERROR_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/message message_src )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/wanji_lidar WANJI_LIDAR_SRC )

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/task TASK_MANAGER_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/tool TOOL_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/communication COMMUNICATION_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/system SYSTEM_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/verify VERIFY_SRC )

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/velodyne_lidar/match3d/common VELODYNE_LIDAR_COMMON)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/velodyne_lidar/match3d/ VELODYNE_LIDAR_MATCH)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/velodyne_lidar/velodyne_driver VELODYNE_LIDAR_DRIVER)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/velodyne_lidar VELODYNE_LIDAR)

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/rabbitmq RABBIT_MQ)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/rslidar RSLIDAR)

add_executable(measure_wj
        main.cpp
        ${ERROR_SRC}
        ${message_src}

		${WANJI_LIDAR_SRC}
        ${TASK_MANAGER_SRC}
        ${TOOL_SRC}
        ${COMMUNICATION_SRC}
        ${SYSTEM_SRC}
		${VERIFY_SRC}

    ${VELODYNE_LIDAR_COMMON}
    ${VELODYNE_LIDAR_MATCH}
    ${VELODYNE_LIDAR_DRIVER}
    ${VELODYNE_LIDAR}
    ${RABBIT_MQ}
    ${RSLIDAR}
		)

target_link_libraries(measure_wj
        /usr/local/lib/libglog.a
        /usr/local/lib/libgflags.a
        # /usr/lib/x86_64-linux-gnu/libglog.so
        # /usr/lib/x86_64-linux-gnu/libgflags.so
        /usr/local/lib/librabbitmq.a
        nnxx
        nanomsg

        ${PROTOBUF_LIBRARIES}
        ${OpenCV_LIBS}
        ${GLOG_LIBRARIES}
        ${PCL_LIBRARIES}
		${CERES_LIBRARIES}
    ${YAML_CPP_LIBRARIES}
    ${rs_driver_LIBRARIES}

        -lpthread
        )




# vlp16 driver test
add_executable(vlp16 tests/vlp16_driver_test.cpp 
${ERROR_SRC}
${message_src}

${WANJI_LIDAR_SRC}
${TASK_MANAGER_SRC}
${TOOL_SRC}
${COMMUNICATION_SRC}
${SYSTEM_SRC}
${RABBIT_MQ}
${VERIFY_SRC}

${VELODYNE_LIDAR_COMMON}
${VELODYNE_LIDAR_MATCH}
${VELODYNE_LIDAR_DRIVER}
${VELODYNE_LIDAR}
${RSLIDAR}
)
target_link_libraries(vlp16 
        /usr/local/lib/libglog.a
        /usr/local/lib/libgflags.a
        # /usr/lib/x86_64-linux-gnu/libglog.so
        # /usr/lib/x86_64-linux-gnu/libgflags.so
nnxx
nanomsg

${PROTOBUF_LIBRARIES}
${OpenCV_LIBS}
${GLOG_LIBRARIES}
${PCL_LIBRARIES}
${CERES_LIBRARIES}
${YAML_CPP_LIBRARIES}
${rs_driver_LIBRARIES}
/usr/local/lib/librabbitmq.a
)

# helios 16P driver test
add_executable(rshelios16 tests/rslidar_test.cpp 
${ERROR_SRC}
${message_src}

${WANJI_LIDAR_SRC}
${TASK_MANAGER_SRC}
${TOOL_SRC}
${COMMUNICATION_SRC}
${SYSTEM_SRC}
${RABBIT_MQ}
${VERIFY_SRC}

${VELODYNE_LIDAR_COMMON}
${VELODYNE_LIDAR_MATCH}
${VELODYNE_LIDAR_DRIVER}
${VELODYNE_LIDAR}
${RSLIDAR}
)
target_link_libraries(rshelios16 
        /usr/local/lib/libglog.a
        /usr/local/lib/libgflags.a
        # /usr/lib/x86_64-linux-gnu/libglog.so
        # /usr/lib/x86_64-linux-gnu/libgflags.so
nnxx
nanomsg

${PROTOBUF_LIBRARIES}
${OpenCV_LIBS}
${GLOG_LIBRARIES}
${PCL_LIBRARIES}
${CERES_LIBRARIES}
${YAML_CPP_LIBRARIES}
${rs_driver_LIBRARIES}
/usr/local/lib/librabbitmq.a
)

add_executable(lidar_calib_tool ./tests/lidar_calib_tools.cpp ./tool/point_tool.cpp)
target_link_libraries(lidar_calib_tool
  ${PCL_LIBRARIES}
  ${OpenCV_LIBS}
)
