Compiling opencv samples: unknown cmake command ocv_check_dependencies

后端 未结 8 1124
余生分开走
余生分开走 2020-12-06 02:05

I am trying to build the OpenCV samples which come with the source package and I get the following:

CMake Error at CMakeLists.txt:10 (ocv_check_dependencies)         


        
8条回答
  •  臣服心动
    2020-12-06 02:17

    Reason

    error message context:

    CMake Error at CMakeLists.txt:10 (ocv_check_dependencies):
      Unknown CMake command "ocv_check_dependencies".
    

    This error message happens because cmake can't find the definition of ocv_check_dependencies

    That's why the console said Unknown CMake command

    Solution

    If cmake cannot find where ocv_check_dependencies is defined

    Just like @Nick Hockings Said:

    ocv_check_dependencies is a macro defined in Your/OpenCV/path/OpenCVModule.cmake

    macro(ocv_check_dependencies)
      set(OCV_DEPENDENCIES_FOUND TRUE)
      foreach(d ${ARGN})
        if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
          set(OCV_DEPENDENCIES_FOUND FALSE)
          break()
        endif()
      endforeach()
    endmacro()
    

    The fastest way is to copy this snippet above to your CMakeList.txt file right above where ocv_check_dependencies is

    Therefore, cmake can finally understand what it is

    That should do the trick, i hope no one else will bother with this question in the future

提交回复
热议问题