Could not find module FindOpenCV.cmake ( Error in configuration process)

前端 未结 12 2214
既然无缘
既然无缘 2020-11-29 02:04

I wrote a CMakeLists.txt for a project in C++, which uses OpenCV libraries. When I try to create the project using cmake, I ge

12条回答
  •  攒了一身酷
    2020-11-29 02:33

    Another possibility is to denote where you can find OpenCV_DIR in the CMakeLists.txt file. For example, the following cmake scripts work for me:

    cmake_minimum_required(VERSION 2.8)
    
    project(performance_test)
    
    set(OpenCV_STATIC ON)
    set(OpenCV_CUDA OFF)
    set(OpenCV_DIR "${CMAKE_SOURCE_DIR}/../install")
    
    find_package(OpenCV REQUIRED)
    
    include_directories(${OpenCV_INCLUDE_DIRS})
    
    link_directories(${OpenCV_LIB_DIR})
    
    file(GLOB my_source_files ./src/*)
    
    add_executable( performance_test ${my_source_files})
    
    target_link_libraries(performance_test ${OpenCV_LIBS})
    

    Just to remind that you should set OpenCV_STATIC and OpenCV_CUDA as well before you invoke OpenCVConfig.cmake. In my case the built library is static library that does not use CUDA.

提交回复
热议问题