CMake深入理解find_package

官方文档:

cmake-modules(7) — Ccmake-modules(7) — C

 

1. 系统预定义模块

可以查看上述链接,存在CURL,则

find_package(CURL)

 

2. 非系统预定义模块 

依赖于cmake编译的库 

find_package(YOUR_LIB)

回顾

find_package从上述两个例子有一个疑问,他是如何找到对应路径的? 

find_package — CMake 3.21.3 Documentation

Module模式(即上述1引用CURL):

In Module mode, CMake searches for a file called Find<PackageName>.cmake. The file is first searched in the CMAKE_MODULE_PATH, then among the Find Modules provided by the CMake installation. If the file is found, it is read and processed by CMake

Config模式(即上述1引用YOUR_LIB)::

Config mode search attempts to locate a configuration file provided by the package to be found. A cache entry called <PackageName>_DIR is created to hold the directory containing the file. By default the command searches for a package with the name <PackageName>. If the NAMES option is given the names following it are used instead of <PackageName>. The command searches for a file called <PackageName>Config.cmake or <lower-case-package-name>-config.cmake for each name specified. 

交叉编译环境

cmake .. -DCMAKE_TOOLCHAIN_FILE

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值