CMake Error at CMakeLists.txt: (FIND_PACKAGE) The solution to the ncnn package cannot be found

Problem Description

demo guide: https://github.com/EdVince/Stable-Diffusion-NCNN When using compiled files
on the Linux side ,cmake

cd x86/linux
mkdir -p build && cd build
cmake ..
make -j$(nproc)

Execute cmake ..the command and report an error:

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".

problem causes

The pulled ncnncode library (including submodule) is not there build and Install, so cmakethe corresponding package cannot be found sometimes, just let it find the corresponding package, which is divided into 2 steps:

  1. Generate the corresponding cmake file ( ncnnConfig.cmake, ncnn-config.cmake)
  2. Set the environment variable ( CMAKE_PREFIX_PATHor ncnn_DIR)

Solution

  1. build and Installncnn

The following commands need to be executed:

cd ncnn
mkdir -p build
cd build
cmake ..

cmakeThen continue in the build directory and execute:

make install

It is found that the pop-up information includes:

This ncnnConfig.cmake、ncnn.cmakeis the package we need to find, find the upper level directory, right click to copy the path

  1. set environment variables
export ncnn_DIR=/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/ncnn/build/install/lib/cmake/ncnn

This environment variable is the path copied in the previous step

  1. reruncmake
cmake ..

See:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux

success!

Guess you like

Origin blog.csdn.net/qq_45510888/article/details/129248757
Recommended