解决“CMake Error at CMakeLists.txt:9 (find_package)”的方法
CMake Error at CMakeLists.txt:9 (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.
"此电脑"->"属性"->"环境变量"->"系统变量"->新建,添加“变量名”:OpenCV_DIR;变量值:C:\Program Files\OpenCV.3.4.10\opencv\build
在即将使用CMake编译的CMakeLists文件中找到下图所示设置的路径:
将CMakeLists文本中设置OpenCV_DIR改为:#set(OpenCV_DIR "/path/to/opencv/build"),然后编译,问题得解决!
参考博文: