命令行等效于cmake的find_package? [英] Command line equivalent of cmake's find_package?

查看:136
本文介绍了命令行等效于cmake的find_package?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一个cmake文件,该文件无法找到某些软件包(使用 find_package())。 find_package()在搜索软件包时实际上是做什么的,我可以使用命令行调用(不调用cmake)对其进行仿真吗?

I'm debugging a cmake file which fails to find certain packages (using find_package()). What does find_package() actually do when it searches for packages, and can I simulate it with a command line call (without invoking cmake)?

推荐答案

1。 find_package的作用是:

来自 find_package()的文档


CMake搜索名为Find的文件。在CMAKE_MODULE_PATH中进行cmake,然后进行CMake安装。如果找到了文件,则由CMake读取并处理。

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上,默认脚本通常位于以下位置:

On Linux, the default scripts usually are located here:

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

这篇关于命令行等效于cmake的find_package?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆