cmake_minimum_required(VERSION 2.8.3)
project(grapher)

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

#add_definitions(-std=c++11 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2)

find_package(OpenMP)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
FIND_PACKAGE(CUDA REQUIRED)


set(CMAKE_CXX_FLAGS "-std=c++11 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2")
set(CMAKE_BUILD_TYPE "RELEASE")

get_directory_property(dir_defs DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
set(vtk_flags)
foreach(it ${dir_defs})
    if(it MATCHES "vtk*")
    list(APPEND vtk_flags ${it})
    endif()
endforeach()

foreach(d ${vtk_flags})
    remove_definitions(-D${d})
endforeach()

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_61,code=sm_61;-G;-g)

find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  nav_msgs
  sensor_msgs
  roscpp
  rospy
  std_msgs
  tf)

#find_package(Eigen3 REQUIRED)

include_directories(
  /usr/local/include/csm
  include
	${catkin_INCLUDE_DIRS} 
#	${EIGEN3_INCLUDE_DIR}
  ${PCL_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

catkin_package(
)

link_directories("/usr/local/lib")

aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/TaskQueue TASK_SRC )
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/ndt NDT_SRC )
set(SRC_LIST  src/steger/detectlines.cpp src/steger/detectlines.h src/steger/Steger.cpp src/steger/Steger.cu)
cuda_add_executable(${PROJECT_NAME}_node src/grapher_node.cpp src/scanGrapher.cpp 
                      src/kalmanFilter.cpp ${TASK_SRC} ${NDT_SRC} ${SRC_LIST})
#add_executable(grapher_node })
target_include_directories(${PROJECT_NAME}_node PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src/TaskQueue/threadpp" )
target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} ${CUDA_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} libcsm.so)

add_executable(location_node src/location_node.cpp src/kalmanFilter.cpp ${NDT_SRC} )
target_link_libraries(location_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} libcsm.so)

#add_executable(laserOdometry src/laserOdometry.cpp)
#target_link_libraries(laserOdometry ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES} ${glog_LIBS})

#add_executable(laserMapping src/laserMapping.cpp)
#target_link_libraries(laserMapping ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS})

#add_executable(transformMaintenance src/transformMaintenance.cpp)
#target_link_libraries(transformMaintenance ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS})
