title: Use custom OpenCV install in ROS package
body: <p>I am trying to build a ROS package in which I use a custom OpenCV 3.4 install in which I have CUDA enabled. The OpenCV install, in /usr/local, is working just fine, I can build and run samples from the GPU folder no problem using </p>
  
  <pre><code>g++ -o houghlines houghlines.cpp `pkg-config opencv --cflags --libs`
  </code></pre>
  
  <p>However, I just cannot get catkin to use my install of OpenCV, rather than the one that ships with ROS. Here is my CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.3)
  project(motion_segmentation_cuda)
  
  set(CMAKE_CUDA_COMPILER  /usr/local/cuda-9.1/bin/nvcc)
  find_package(catkin_simple REQUIRED)
  
  set(OpenCV_INCLUDE_DIRS
    /usr/local/include
    /usr/local/include/opencv2
  )
  set(OpenCV_LIB_DIR
    /usr/local/lib
  )
  set(OpenCV_LIBS
    opencv_core
    opencv_highgui
    opencv_imgcodecs
  )
  include_directories(${OpenCV_INCLUDE_DIRS})
  
  find_package(CUDA REQUIRED)
  catkin_simple()
  
  #Here you can set any gcc/cmake compiler flags, if you so wish
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")
  link_directories(${OpenCV_LIB_DIR})
  
  #Add all of your sources here
  cuda_add_executable(
    cuda_test_cu
    src/main.cpp
    src/motion_segmenter.cpp
    src/kernel.cu
    src/segmenter.cpp
  )
  
  #Link the executable to the necessary libs
  target_link_libraries(
     cuda_test_cu
     ${catkin_LIBRARIES}
     ${OpenCV_LIBS}
     ${CUDA_LIBRARIES}
  )
  
  # CMake Indexing
  FILE(GLOB_RECURSE LibFiles "include/*")
  add_custom_target(headers SOURCES ${LibFiles})
  
  cs_install()
  </code></pre>
  
  <p>On the advice of various forums I have also tried to</p>
  
  <pre><code>export CMAKE_PREFIX_PATH="/usr/lib/:$CMAKE_PREFIX_PATH"
  export LD_LIBRARY_PATH="/usr/lib/:$LD_LIBRARY_PATH"
  </code></pre>
  
  <p>And a whole myriad of tweaks in the CMakeLists. And my package compiles just fine! But in the end, I inevitably get:</p>
  
  <pre><code>OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/core/include/opencv2/core/private.cuda.hpp, line 107
  </code></pre>
  
  <p>As soon as I try to actually use any of the GPU enabled OpenCV classes.</p>
  
  <p>Many thanks!</p>