12sd 12sd - 16 days ago 7
C++ Question

OpenCV CLion (Cmake) linking issue - cmake reports a strange error

I can't get my CLion to build the project because of a weird error upon saving my CMakeLists and/or building the project:


Error:Found package configuration file:
/usr/share/opencv/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.


Source file: http://pastebin.com/n75DS8F8

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(Test)
find_package( OpenCV REQUIRED )
add_executable( Test main.cpp )
target_link_libraries( Test ${OpenCV_LIBS} )


$ pkg-config --cflags opencv

-I/usr/include/opencv


$ pkg-config --libs opencv

-L/lib64 -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -ltbb -lGL -lGLU -lrt -lpthread -lm -ldl


The fact is when I manually
cmake . & make
(with all the same CMakeLists file) my project from console it works just fine with no errors.

OpenCV version: 2.4.11-1 (arch linux)
CLion: latest.

OpenCVConfig.cmake difference compared to git version: https:// www.diffchecker. com/vtmmiu1w

(sorry, remove the spaces, can't post more than 2 links)
Manual build output:
http:// pastebin. com/E2sPQZ5M

Answer

I don't know what really happened, but I've added a line that manually sets the OpenCV_FOUND to 1 into OpenCVConfig.cmake and everything works fine:

set(OpenCV_FOUND 1)

Comments