Reputation: 8108
I compiled the opencv-2.4.13
version, and now I want to compile a project using cmake.
If I do:
cmake_minimum_required(VERSION 3.5.1)
project(phase)
find_package(Opencv REQUIRED)
include_directories(INCLUDE_DIR include)
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE}
I get the following error:
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "FindOpencv.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Opencv", but
CMake did not find one.
Could not find a package configuration file provided by "Opencv" with any
of the following names:
OpencvConfig.cmake
opencv-config.cmake
Add the installation prefix of "Opencv" to CMAKE_PREFIX_PATH or set
"Opencv_DIR" to a directory containing one of the above files. If "Opencv"
provides a separate development package or SDK, be sure it has been
installed.
So I created a folder named cmake-modules
and copied the OpenCVConfig.cmake
file generated by the compiled OpenCV project.
Then:
cmake_minimum_required(VERSION 3.5.1)
project(phase)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
find_package(Opencv REQUIRED)
include_directories(INCLUDE_DIR include)
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE})
But I still getting the same error.
How do I should include the .cmake
file to find OpenCV?
Upvotes: 0
Views: 592
Reputation: 8108
I solved the problem with the following:
cmake_minimum_required(VERSION 3.5.1)
project(phase)
SET(OpenCV_INCLUDE_DIRS "/home/facu/opencv-2.4.13/include/opencv")
include_directories(INCLUDE_DIR include ${OpenCV_INCLUDE_DIRS})
set(OpenCV_LIB_DIR "/home/facu/opencv-2.4.13/release/lib")
link_directories(${OpenCV_LIB_DIR})
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE})
Upvotes: 1