0

I have a project which uses cmake and would like to include opencv in it. I need this dependency to be used from my local disk at ./third_party/opencv. I have there the git repo contents https://github.com/opencv/opencv.

I'm new to CMake and not sure how to include this project within mine.

I've tried various things, most recently adding this to my CMakeLists.txt include_directories(${PROJECT_SOURCE_DIR}/third_party/opencv). Which does not work. I get errors such as:

 undefined reference to `cv::rectangle(cv::Mat&, cv::Rect_<int>, cv::Scalar_<double> const&, int, int, int)

Here is my full CMakeLists.txt

cmake_minimum_required(VERSION 3.1)
project(root)

include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

FIND_PACKAGE(PkgConfig REQUIRED)

find_package(ZXing CONFIG)

# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

include_directories(
  ${PROJECT_SOURCE_DIR}/third_party
)
include_directories(${PROJECT_SOURCE_DIR}/third_party/opencv)

add_executable(application ${PROJECT_SOURCE_DIR}/main.cpp)
add_executable(run_tests ${PROJECT_SOURCE_DIR}/tests/tests.cpp)
target_link_libraries(
  application
  ${GTEST_LIBRARIES} pthread ${ZBAR_LIBRARIES} ZXingCore
)
target_link_libraries(
  run_tests
  ${GTEST_LIBRARIES} pthread ${ZBAR_LIBRARIES} ZXingCore
)

Any idea of how I can do this correctly? Thanks

Fred joe
  • 105
  • 8

0 Answers0