相当于 cmake 的 find_package 的命令行?

Command line equivalent of cmake's find_package?

我正在调试无法找到某些包的 cmake 文件(使用 find_package())。 find_package() 在搜索包时实际上做了什么,我可以用命令行调用模拟它(不调用 cmake)吗?

1. find_package 的作用:

来自documentation of find_package()

CMake searches for a file called Find.cmake in the CMAKE_MODULE_PATH followed by the CMake installation. If the file is found, it is read and processed by CMake.

在 Linux 上,默认脚本通常位于此处:

ls /usr/share/cmake*/Modules/Find*.cmake

2。如何在命令行中使用find_package:

# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST
Boost found

# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE
-I/usr/include

# cmake --find-package -DNAME=Boost -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
   -rdynamic