问题描述
demo指路:https://github.com/EdVince/Stable-Diffusion-NCNN
在Linux端使用cmake
编译文件时,
cd x86/linux
mkdir -p build && cd build
cmake ..
make -j$(nproc)
执行cmake ..
命令,报错:
CMake Error at CMakeLists.txt:14 (FIND_PACKAGE):
By not providing "Findncnn.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "ncnn", but
CMake did not find one.
Could not find a package configuration file provided by "ncnn" with any of
the following names:
ncnnConfig.cmake
ncnn-config.cmake
Add the installation prefix of "ncnn" to CMAKE_PREFIX_PATH or set
"ncnn_DIR" to a directory containing one of the above files. If "ncnn"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux/CMakeFiles/CMakeOutput.log".
问题原因
拉取ncnn
的代码库(包括submodule)后没有build and Install
,所以cmake
时找不到对应的包,只需要让它找到对应的包即可,分为2步:
- 生成对应的cmake文件(
ncnnConfig.cmake
、ncnn-config.cmake
) - 设置环境变量(
CMAKE_PREFIX_PATH
或者ncnn_DIR
)
解决方法
-
build and Install
ncnn
需要执行以下命令:
cd ncnn
mkdir -p build
cd build
cmake ..
cmake
之后继续在build目录下,执行:
make install
发现弹出的信息中有:
这其中的ncnnConfig.cmake、ncnn.cmake
就是我们需要找的包,找到上一级目录,右键复制路径
- 设置环境变量
export ncnn_DIR=/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/ncnn/build/install/lib/cmake/ncnn
这个环境变量就是上一步复制的路径
- 重新运行
cmake
cmake ..
看到:文章来源:https://www.toymoban.com/news/detail-511587.html
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux
成功!文章来源地址https://www.toymoban.com/news/detail-511587.html
到了这里,关于CMake Error at CMakeLists.txt: (FIND_PACKAGE)找不到ncnn包的解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!