How to use arbitrary version of OpenCV
Hi, i have ROS Kinetic installed and it comes with OpenCV. I also have the latested OpenCV that i downloaded from github and installed in /usr/local. The following code that i wrote will always use OpenCV that came with the ROS installation, can i make it use an arbitrary version of OpenCV that i have on the system? Here's the CMakeLists.txt file:
cmake_minimum_required(VERSION 2.6)
project(my_project)
find_package(OpenCV 3.0.0 REQUIRED)
message("OpenCV version: ${OpenCV_VERSION}")
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIB_DIR})
set(SRC
main.cpp
)
add_executable(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
When i run it i get:
Found OpenCV: /opt/ros/kinetic (found suitable version "3.2.0", minimum required is "3.0.0")
OpenCV version: 3.2.0
UPDATE
I found a way to make it work. I'am open for alternatives to this. This is the CMakeLists.txt that i have now:
cmake_minimum_required(VERSION 2.6)
project(tut)
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})
link_directories(${OpenCV_LIB_DIR})
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})