In CMaKeList.txt, you can use function packages that are not installed on the system by setting the cmake path.

1、find_package(xx REQUIRED)

The function of find_package(xx REQUIRED) is to find function packages. For example, if we need to use opencv when compiling a certain project, then our CMakeList.txt needs to have find_package(OpenCV REQUIRED). Its principle is simply to find OpenCVConfig .cmake file, and then the library path and header file path of opencv will be specified in the OpenCVConfig.cmake file, so that you will find the corresponding header file and library file when compiling.

If we do not intervene, then find_package (OpenCV REQUIRED) will look for OpenCVConfig.cmake in the default path. Then if the opencv version in the default path of our system is not what we want, we ourselves will compile a higher version of cmake in a certain path. version of opencv, and then when we compile the project, we want cmake to find the OpenCVConfig.cmake of a higher version of opencv compiled by ourselves. What should we do? At this time, we need to use set (CMAKE_PREFIX_PATH xx).

2、set(CMAKE_PREFIX_PATH xx)

This actually means asking cmake to search for xxxxConfig.cmake in the directory we specified. If it is opencv, then we put the install folder path when compiling our own version of opencv into set(CMAKE_PREFIX_PATH /xxx/xxx/build).

Guess you like

Origin blog.csdn.net/weixin_44884561/article/details/129810428